Hello-SimpleAI/HC3
Viewer โข Updated โข 48.6k โข 6.69k โข 244
How to use spatialgeography/bert-tiny-ai-human-text-detector with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="spatialgeography/bert-tiny-ai-human-text-detector") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("spatialgeography/bert-tiny-ai-human-text-detector")
model = AutoModelForSequenceClassification.from_pretrained("spatialgeography/bert-tiny-ai-human-text-detector", device_map="auto")A very small model (about 4.4M parameters, 17.5 MB) that labels an English answer or paragraph as HUMAN (written by a person) or AI (written by ChatGPT). It was made as a teaching demo. Read the limitations before using it.
from transformers import pipeline
detector = pipeline("text-classification", model="spatialgeography/bert-tiny-ai-human-text-detector")
print(detector("There are several factors to consider. Ultimately, it depends on your situation.", truncation=True))
# [{'label': 'AI', 'score': ...}]
| Setting | Value |
|---|---|
| Epochs | 3 (1,209 steps) |
| Batch size | 32 |
| Learning rate | 1e-4, linear decay, 100 warm-up steps |
| Max length | 256 tokens |
| Hardware | Laptop CPU (4 threads), 18 min 41 s |
| Epoch | Accuracy | F1 | Precision (AI) | Recall (AI) |
|---|---|---|---|---|
| 0 (before) | 68.5% | 0.641 | 0.746 | 0.561 |
| 1 | 94.7% | 0.945 | 0.988 | 0.905 |
| 2 | 96.3% | 0.962 | 0.980 | 0.946 |
| 3 | 96.9% | 0.968 | 0.977 | 0.959 |
| Test subset | Texts | Accuracy |
|---|---|---|
| medicine | 266 | 98.5% |
| finance | 756 | 98.0% |
| open_qa | 262 | 94.3% |
| wiki_csai | 148 | 92.6% |
The model weights are released under CC-BY-SA-4.0 to match the HC3 dataset license.
Base model
google/bert_uncased_L-2_H-128_A-2