CoolFace
Modelpublic

Eslzzyl/aigc-detector-en-onnx

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes33downloads
Model Card

AIGC English Text Detector (ONNX, INT8)

ONNX INT8 quantized model exported from yuchuantian/AIGC_detector_env3, for detecting whether English text is AI-generated.

  • —Architecture: RobertaForSequenceClassification (RoBERTa-base, 12-layer, 768-hidden)
  • —Quantization: INT8 dynamic quantization (UInt8 weights)
  • —Model size: ~120 MB
  • —Inputs: input_ids, attention_mask (int64) — note: no token_type_ids
  • —Output: logits (float32, shape [batch, 2]) → [Human_Written, AI_Generated]
  • —Max sequence length: 512 tokens

Quick Start

python
from tokenizers import Tokenizer
import onnxruntime as ort
import numpy as np

tokenizer = Tokenizer.from_file("tokenizer.json")
tokenizer.enable_padding(pad_id=1, pad_token="<pad>")
tokenizer.enable_truncation(max_length=512)

session = ort.InferenceSession("onnx/model_quantized.onnx")

text = "This is a text to detect."
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),
})[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]

Runtime dependencies: onnxruntime + tokenizers only. No PyTorch or Transformers needed.