Downloads · 30 days
8.2K
17% of all-time downloads
AnxForever/chinese-ai-detector-bert
chinese-ai-detector-bert is a text classification model from AnxForever. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
中文 AI 生成文本检测器(本科毕业设计最终版) A fine-tuned BERT model that classifies Chinese text as either human-written (0) or AI-generated (1). The main released model is a document-level binary classifier; mixed-text boundary detecti…
Downloads · 30 days
8.2K
17% of all-time downloads
All-time downloads
48.4K
Public
Parameters
102M
818 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors409 MB · 100%
From the Hugging Face model README
中文 AI 生成文本检测器(本科毕业设计最终版)
A fine-tuned BERT model that classifies Chinese text as either human-written (0) or AI-generated (1). The main released model is a document-level binary classifier; mixed-text boundary detection is an experimental extension provided by a separate span model.
中文:本模型是基于 bert-base-chinese 微调的中文 AI 生成文本二分类器,为本科毕业设计「基于 BERT 微调的中文 AI 生成文本检测系统」的最终生产模型(v11c boundary-fix 版本)。当前主链路输出 Human / AI 二分类;[SEP] 边界标记与 Token 级 span detector 是配套的实验性扩展,用于探索构造型人机混写样本中的片段级分析。
English: A binary classifier fine-tuned on bert-base-chinese for Chinese AI-generated text detection. This is the final production checkpoint (v11c boundary-fix) of an undergraduate thesis project. [SEP] boundary markers and the token-level span detector are experimental extensions for constructed human/AI mixed-text analysis, not the default production inference path.
| Dataset | Samples | Accuracy | Precision | Recall | F1 |
|---|---|---|---|---|---|
| Validation set | 7,452 | 98.75 % | 98.30 % | 99.37 % | 98.83 % |
core_v1_test_clean | 545 | 97.98 % | 97.87 % | 98.77 % | 98.32 % |
| Independent eval (910) | 910 | 98.57 % | 93.08 % | 98.67 % | 95.79 % |
| Three-set average | — | 98.56 % | — | — | — |
The metrics above evaluate the document-level binary classifier. The historical token-level boundary result belongs to the separate
chinese-ai-detector-spanexperimental model and should not be mixed with the main classifier metrics.
| Source | Samples | Accuracy |
|---|---|---|
| Toutiao News (all) | 377 | 100.0 % |
| Wikipedia CN | 119 | 99.16 % |
| formal_collected | 200 | 96.5 % |
| real_ai_gemini-3-pro-preview | 24 | 100.0 % |
| real_ai_deepseek-v3.2 | 8 | 100.0 % |
bert-base-chinese (12 layers, hidden 768, 12 heads, vocab 21,128)BertForSequenceClassification (2 labels: 0 = human, 1 = AI)transformers 4.57.3, PyTorch 2.0+| Setting | Value |
|---|---|
| Base model | bert-base-chinese (via bert_v7_improved intermediate checkpoint) |
| Train samples | 63,113 |
| Validation samples | 7,452 |
| Epochs | 5 (best at epoch 2) |
| Batch size | 8 × 4 grad accum |
| Learning rate | 1e-5 |
| Label smoothing | 0.05 |
| Max length | 256 |
| Early stopping patience | 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
MODEL_ID = "AnxForever/chinese-ai-detector-bert"
TEMPERATURE = 0.8165 # Temperature scaling, calibrated on 910 samples (ECE=0.0034)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
model.eval()
text = "这是一段需要检测的中文文本。"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
logits = model(**inputs).logits
# Apply temperature scaling for calibrated confidence
probs = torch.softmax(logits / TEMPERATURE, dim=-1)[0]
pred_idx = int(probs.argmax())
label = model.config.id2label[pred_idx] # "human-written" or "AI-generated"
print(f"{label} (confidence: {probs[pred_idx].item():.2%})")
0 → human-written (人类撰写)1 → AI-generated (AI 生成)Note on Temperature Scaling:
T = 0.8165was calibrated on a held-out 910-sample set and brings ECE from 0.0121 down to 0.0034. For uncalibrated probabilities, setTEMPERATURE = 1.0.
Data-centric risk governance The v11c model keeps the BERT backbone fixed and improves robustness through data cleaning, weak-domain supplementation, long-AI supplementation, and calibrated inference.
[SEP] boundary-marker experiment
In constructed C2-style mixed samples, [SEP] was used as an explicit boundary hint between known human and AI segments. This is an engineering experiment for mixed-text modeling, not a claim that [SEP] itself can identify authorship without labels.
Two-stage experimental extension
AnxForever/chinese-ai-detector-spanLong-AI boundary-fix (v11c) 针对长 AI 段落在边界处易被误判的问题,补充 2,131 条长 AI 边界样本,使 256+ token 桶的准确率恢复到 V10 水平。
The boundary module was trained on a relatively small constructed mixed-text set. It is useful for demonstration, teaching, and secondary development, but it should be treated as an experimental prototype. For real business scenarios, mixed human/AI data from the target domain should be collected, labeled, retrained, and evaluated before deployment.
AnxForever/chinese-ai-detection-datasetAnxForever/chinese-ai-detector-spanMIT License Copyright (c) 2026 AnxForever
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@misc{anxforever2026chineseaidetectorbert,
title = {Chinese AI-Generated Text Detector with Boundary Markers (BERT v11c)},
author = {AnxForever},
year = {2026},
howpublished = {\url{https://huggingface.co/AnxForever/chinese-ai-detector-bert}},
note = {Undergraduate thesis project}
}