AIGC 中文文本检测器 (ONNX, INT8)
基于 yuchuantian/AIGC_detector_zhv3 导出的 ONNX INT8 量化模型,用于检测中文文本是否由 AI 生成。
- 架构:
BertForSequenceClassification(BERT-base, 12-layer, 768-hidden) - 量化: INT8 动态量化 (UInt8 weights)
- 模型大小: ~98 MB
- 输入:
input_ids,attention_mask,token_type_ids(int64) - 输出:
logits(float32, shape [batch, 2]) →[Human_Written, AI_Generated] - 最大序列长度: 512 tokens
快速使用
from tokenizers import Tokenizer
import onnxruntime as ort
import numpy as np
tokenizer = Tokenizer.from_file("tokenizer.json")
tokenizer.enable_padding(pad_id=0, pad_token="[PAD]")
tokenizer.enable_truncation(max_length=512)
session = ort.InferenceSession("onnx/model_quantized.onnx")
text = "这是一段待检测的文本"
enc = tokenizer.encode(text)
logits = session.run(None, {
"input_ids": np.array([enc.ids], dtype=np.int64),
"attention_mask": np.array([enc.attention_mask], dtype=np.int64),
"token_type_ids": np.array([enc.type_ids], dtype=np.int64),
})[0]
# softmax → [human_prob, ai_prob]
probs = np.exp(logits - logits.max(axis=-1, keepdims=True))
probs = probs / probs.sum(axis=-1, keepdims=True)
is_ai = probs[0][1] > probs[0][0]
运行时仅需 onnxruntime + tokenizers,不需要 PyTorch 或 Transformers。
Model tree for Eslzzyl/aigc-detector-zh-onnx
Base model
yuchuantian/AIGC_detector_zhv3