Instructions to use Tamarillo/ai-text-forensics-guard-small-en with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Tamarillo/ai-text-forensics-guard-small-en with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Tamarillo/ai-text-forensics-guard-small-en")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Tamarillo/ai-text-forensics-guard-small-en") model = AutoModelForSequenceClassification.from_pretrained("Tamarillo/ai-text-forensics-guard-small-en", device_map="auto") - Transformers.js
How to use Tamarillo/ai-text-forensics-guard-small-en with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'Tamarillo/ai-text-forensics-guard-small-en'); - Notebooks
- Google Colab
- Kaggle
- Tamarillo/ai-text-forensics-guard-small-en
Tamarillo/ai-text-forensics-guard-small-en
Balanced Production Tier (150M) β Apache-2.0, zero-trust_remote_code, long-context (2,048 trained / 8,192 RoPE native) English AI-generated text and agent-output provenance detector built on standard ModernBertForSequenceClassification (0=human, 1=ai_generated) with parity-verified FP32 & FP16 ONNX exports.
Part of the Tamarillo open-model security & forensics suite (companion browser demo Space: Tamarillo/ai-text-forensics-guard-demo).
Quickstart (< 30 Seconds)
Requires transformers>=4.48 (native ModernBERT support, zero trust_remote_code):
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_id = "Tamarillo/ai-text-forensics-guard-small-en"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id).eval()
texts = [
"We chased a bizarre connection pool leak in prod last Tuesday after bumping our Postgres driver. Switching to per-attempt timeouts fixed it, though we still need a failover regression test.",
"Effective observability in distributed agentic systems requires a comprehensive, multi-layered strategy that combines structured telemetry, automated anomaly detection, and continuous latency profiling.",
]
inputs = tokenizer(texts, padding=True, truncation=True, max_length=2048, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
# Raw probabilities (T=1.0, used with thr_5fpr_val=0.56506 / thr_1fpr_val=0.93046)
probs = torch.softmax(logits, dim=-1)
# Optional temperature-scaled probabilities from calibration.json (T=0.9446)
probs_cal = torch.softmax(logits / 0.9446, dim=-1)
for text, p, pc in zip(texts, probs, probs_cal):
p_ai = float(p[1])
label = model.config.id2label[int(p_ai >= 0.5)]
print(f"{label:12s} | P_raw(ai)={p_ai:.4f} | P_cal(ai)={float(pc[1]):.4f} | {text[:55]}...")
ONNX Runtime (Python CPU/Edge) & Transformers.js (Browser WASM) Snippets
ONNX Runtime (Python)
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer
model_id = "Tamarillo/ai-text-forensics-guard-small-en"
tokenizer = AutoTokenizer.from_pretrained(model_id)
onnx_path = hf_hub_download(model_id, "onnx/model.onnx") # or "onnx/model_fp16.onnx"
session = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])
enc = tokenizer(
"Effective observability in distributed agentic systems requires a comprehensive, multi-layered strategy.",
truncation=True,
max_length=2048,
return_tensors="np",
)
logits = session.run(
None,
{"input_ids": enc["input_ids"].astype(np.int64), "attention_mask": enc["attention_mask"].astype(np.int64)},
)[0][0]
probs = np.exp(logits - logits.max())
probs = probs / probs.sum()
print({"human": float(probs[0]), "ai_generated": float(probs[1])})
Transformers.js (Browser / Node.js, @huggingface/transformers>=3.5.1)
import { AutoTokenizer, AutoModelForSequenceClassification } from "@huggingface/transformers";
const modelId = "Tamarillo/ai-text-forensics-guard-small-en";
const tokenizer = await AutoTokenizer.from_pretrained(modelId);
const model = await AutoModelForSequenceClassification.from_pretrained(modelId, { dtype: "fp16" });
const inputs = tokenizer("Effective observability in distributed agentic systems requires a comprehensive strategy.", {
truncation: true,
max_length: 2048,
});
const { logits } = await model(inputs);
const [z0, z1] = logits.data;
const mx = Math.max(z0, z1);
const pAi = Math.exp(z1 - mx) / (Math.exp(z0 - mx) + Math.exp(z1 - mx));
console.log({ label: pAi >= 0.5 ? "ai_generated" : "human", p_ai: pAi });
Why This Family Exists
Most high-download open AI text detectors on Hugging Face suffer from four production blockers:
- Broken or non-standard
transformersloading:desklib/ai-text-detector-v1.01requires pasting a customDesklibAIDetectionModelsubclass and ships noid2labelmapping or ONNX weights. - Short context truncation: RoBERTa/DeBERTa incumbents truncate at 512β768 tokens, missing synthetic continuations in long reports, RAG outputs, and agent transcripts (dropping to
0.50β0.54AUC on our long-context tail stress test). - High Non-Native English (ESL) false positives & formatting shortcuts: In
liamdugan/raid,0.0%of human texts contain\n\nparagraph breaks while58β78%of AI texts do. Naively trained RAID detectors memorize\n\n -> AIand falsely flag49.5%of real human IELTS ESL essays (desklib). - No parity-verified ONNX / browser artifacts: None of
desklib,fakespot,RADAR, oropenai-roberta-detectorship verified FP32/FP16 ONNX weights.
Tamarillo/ai-text-forensics-guard-small-en fixes all four:
- 2.9Γ smaller and 1.94Γ faster on GPU than
desklib/ai-text-detector-v1.01while reading 2.67Γ longer context (2,048 vs. 768 tok),53.2 msCPU @ 64 tok,0.911unseen-domain AUC (+6.3pp overtiny-en),0.0200calibrated validation ECE, and 2.63Γ lower ESL human FPR thandesklib(18.8%vs.49.5%). - Symmetric Paragraph Deconfounding: Trained on a near-balanced corpus (
60,768docs:51.8%AI /48.2%human) where\n\nand\nparagraph breaks are symmetrically normalized and re-injected identically across human and AI texts (I(\n\n; y) = 0), yielding formatting-invariant detection (0.9986raw vs.0.9988with all newlines stripped) and reducing IELTS ESL human false positives by 2.63Γ onsmall-en(up to 5.17Γ onbase-en) vs.desklib. - Single-Pass Adversarial Consistency + Low-FPR Objective: Asymmetric human-FP penalty (
fp_weight=1.50) + paired clean-vs-attacked symmetric KL consistency across 10 adversarial evasion attacks + validation temperature calibration (calibration.json).
Family Ladder
| Model | Backbone | Params | OOD-5 Mean AUC | 2025β26 Open-Weight AUC / F1 | ESL IELTS FPR@0.50 | A100 @ 2K | CPU @ 64 tok (FP32 ONNX) | FP16 ONNX |
|---|---|---|---|---|---|---|---|---|
Tamarillo/ai-text-forensics-guard-tiny-en |
jhu-clsp/ettin-encoder-32m |
32.0M | 0.960 | 0.9988 / 0.978 | 19.8% | 28.1 ms | 9.3 ms | 61.3 MB |
Tamarillo/ai-text-forensics-guard-small-en |
answerdotai/ModernBERT-base |
149.6M | 0.971 | 0.9986 / 0.969 | 18.8% | 34.7 ms | 53.2 ms | 285.8 MB |
Tamarillo/ai-text-forensics-guard-base-en |
answerdotai/ModernBERT-large |
395.8M | 0.976 | 0.9996 / 0.987 | 9.6% | 45.5 ms | 155.7 ms | 755.6 MB |
Strictly OOD Pareto Frontier
Head-to-Head Evaluation (7 Models, Same NVIDIA A100-SXM4-40GB)
All 7 models were evaluated on the exact same GPU and exact same splits using raw softmax/sigmoid outputs (T = 1.0). desklib/ai-text-detector-v1.01 was evaluated using its official DesklibAIDetectionModel class and documented max_len=768.
Table 1: Strictly OOD 5-Suite Benchmarks (ROC-AUC / TPR@5%FPR)
| Model | Params | Context | Compatibility | 2025β26 Open-Weight 4B/8B (n=2,088) |
RAID Unseen Models (n=970) |
RAID Unseen Domains (n=1,200) |
RAID Unseen Attacks (n=796) |
External dmitva (n=1,600) |
OOD-5 Mean AUC | A100 @ 2Kβ‘ |
|---|---|---|---|---|---|---|---|---|---|---|
| Tamarillo tiny-en | 32.0M | 2,048 (8K) | Standard AutoModel |
0.999 / 0.99 | 0.997 / 0.99 | 0.848 / 0.39 | 0.989 / 0.95 | 0.968 / 0.84 | 0.960 | 28.1 ms |
| Tamarillo small-en | 149.6M | 2,048 (8K) | Standard AutoModel |
0.999 / 0.99 | 0.992 / 0.97 | 0.911 / 0.60 | 0.989 / 0.96 | 0.964 / 0.83 | 0.971 | 34.7 ms |
| Tamarillo base-en | 395.8M | 2,048 (8K) | Standard AutoModel |
1.000 / 1.00 | 0.993 / 0.98 | 0.908 / 0.44 | 0.995 / 0.98 | 0.984 / 0.94 | 0.976 | 45.5 ms |
desklib/ai-text-detector-v1.01* (MIT) |
434.0M | 768 (DeBERTa) | Custom DesklibAIDetectionModel |
0.999 / 1.00 | 0.988 / 0.96 | 0.980 / 0.93 | 0.989 / 0.95 | 0.999 / 1.00 | 0.991 | 67.2 ms |
fakespot-ai/roberta-base-ai-text-detection-v1β |
124.7M | 512 | Standard AutoModel |
0.999 / 1.00 | 0.987 / 0.91 | 0.993 / 0.95 | 0.988 / 0.95 | 1.000 / 1.00 | 0.993 | 12.0 ms |
TrustSafeAI/RADAR-Vicuna-7B |
355.4M | 512 | Standard AutoModel |
0.987 / 0.92 | 0.964 / 0.87 | 0.883 / 0.52 | 0.907 / 0.64 | 0.962 / 0.74 | 0.941 | 24.1 ms |
openai-community/roberta-base-openai-detector |
124.7M | 512 | Standard AutoModel |
0.768 / 0.42 | 0.807 / 0.52 | 0.784 / 0.41 | 0.842 / 0.58 | 0.615 / 0.20 | 0.763 | 12.9 ms |
Dataset-overlap & context disclosure:
- β‘Latency note: Tamarillo models process full
2,048-token inputs; baselines truncate at their native context caps (768fordesklib,512for RoBERTa/RADAR). 2025β26 Open-Weight 4B/8B(ood_frontier_2026): Self-constructed evaluation set covering two 2025 open-weight 4B/8B models (Qwen/Qwen3-4B+deepseek-ai/DeepSeek-R1-Distill-Llama-8B, clean + 5 adversarial attacks, 49.7% AI / 50.3% human; does not cover closed commercial API models). All test prompts and human source documents are strictly partitioned bysource_idto be 100% disjoint from ourMistral-7B-Instruct-v0.3/Phi-4-mini-instructtraining slice (zero Qwen, DeepSeek, or Llama texts in the 2025β2026 train slice), making this suite 100% OOD for all 7 evaluated models.- *
desklib/ai-text-detector-v1.01listsliamdugan/raidin its training metadata, soRAID Unseen Domains(recipes+poetry) andRAIDsplits are in-distribution fordesklibwhile strictly held out (zero rows in train/val) for Tamarillo. - β
fakespot-ai/roberta-base-ai-text-detection-v1scores1.0000AUC /0.9994F1 /0.0006ECE ondmitva, indicating direct training-set overlap withdmitva/ Kaggle DAIGT essays (whereasdmitvais 100% OOD for Tamarillo).
Table 2: Fairness (ESL Human FPR), Formatting Invariance, Long-Context Stress & Held-Out MAGE
(Reported separately from the OOD-5 headline composite above; never mixed into the Pareto chart. All benchmark metrics use raw logits T = 1.0.)
| Model | ESL IELTS FPR@0.50 β (n=1,200) |
ESL Mean P(AI) β |
2025β26 Open-Weight Macro-F1 β | 2025β26 ECE β | 2025β26 Flat AUC (no \n) |
Qwen3-4B / DeepSeek-R1 AUC |
Long-Context Tail Stress (n=400, synthetic >900-tok pfx) |
MAGE Test (ID for Tamarillo) (n=2,000) |
|---|---|---|---|---|---|---|---|---|
| Tamarillo tiny-en | 19.8% | 0.215 | 0.978 | 0.027 | 0.999 | 1.000 / 0.998 | 0.904 / 0.70 | 0.972 / 0.84 |
| Tamarillo small-en | 18.8% | 0.208 | 0.969 | 0.034 | 0.999 | 1.000 / 0.998 | 0.863 / 0.52 | 0.971 / 0.87 |
| Tamarillo base-en | 9.6% | 0.121 | 0.987 | 0.029 | 1.000 | 1.000 / 1.000 | 0.900 / 0.76 | 0.977 / 0.90 |
desklib/ai-text-detector-v1.01* (MIT) |
49.5% | 0.513 | 0.975 | 0.037 | 0.999 | 1.000 / 1.000 | 0.541 / 0.12 | 0.934 / 0.71 |
fakespot-ai/roberta-base-ai-text-detection-v1β |
24.8% | 0.254 | 0.948 | 0.068 | 1.000 | 1.000 / 0.999 | 0.500 / 0.01 | 0.820 / 0.49 |
TrustSafeAI/RADAR-Vicuna-7B |
23.9% | 0.312 | 0.868 | 0.124 | 0.982 | 0.993 / 0.991 | 0.500 / 0.01 | 0.676 / 0.12 |
openai-community/roberta-base-openai-detector |
8.1% | 0.089 | 0.656 | 0.295 | 0.763 | 0.886 / 0.747 | 0.500 / 0.01 | 0.750 / 0.30 |
Candid summary of wins & losses:
- Where Tamarillo wins:
- 2025β2026 4B/8B Open-Weight LLMs:
base-enachieves #1 Macro-F1 (0.9866),0.9996ROC-AUC, and1.0000TPR@5%FPR; even 32Mtiny-en(0.9775F1,0.0273ECE) beats 434Mdesklib(0.9746F1,0.0374ECE) and 125Mfakespot(0.9477F1,0.0678ECE). - Non-Native English (ESL) Human Fairness:
base-en(9.58%FPR @ 0.50) reduces false accusations on IELTS ESL human essays by 5.17Γ vs.desklib(49.50%), 2.58Γ vs.fakespot(24.75%), and 2.50Γ vs.RADAR(23.92%). (Only 2019openai-roberta-detectorhas lower ESL FPR at8.08%, because it misses 58% of 2025β2026 AI text.) - Long-Context Documents (synthetic >900-token human prefix + human vs. 2025β26 AI tail stress test): All 3 Tamarillo tiers score
0.863β0.904AUC (0.515β0.760TPR@5%FPR), whereasdesklib(768-tok cap) collapses to0.541 / 0.115and 512-tok RoBERTa baselines collapse to random chance (0.500 / 0.005). - RAID Unseen Generators & Unseen Attacks:
tiny-en(0.997 / 0.99) leadsRAID Unseen Models;base-en(0.995 / 0.98) leadsRAID Unseen Attacks. - Speed, Compatibility & ONNX:
base-enis 1.48Γ faster thandesklibon A100 while reading 2.67Γ more tokens; standardAutoModelForSequenceClassificationwith zerotrust_remote_codeand1.0000-parity FP32 + FP16 ONNX.
- 2025β2026 4B/8B Open-Weight LLMs:
- Where baselines win (reported candidly):
- On
RAID Unseen Domains(recipes+poetry),desklib(0.980 / 0.93) andfakespot(0.993 / 0.95) substantially outperform Tamarillo (tiny-en0.848 / 0.39,small-en0.911 / 0.60,base-en0.908 / 0.44). Recipes and poetry were strictly excluded from Tamarillo's training data, and highly structured/short-line genres remain harder zero-shot domains for Tamarillo. - On
dmitvaessays,fakespot(1.000 / 1.00, training overlap) anddesklib(0.999 / 1.00) score higher than Tamarillo (tiny-en0.968 / 0.84,small-en0.964 / 0.83,base-en0.984 / 0.94). - On raw 512-token GPU speed, 125M RoBERTa models (
12 ms) are faster than 2,048-token ModernBERT (28β46 ms) when inputs are short and truncated at 512 tokens.
- On
Calibration & Operating Thresholds (calibration.json)
All thresholds and temperature parameters are fit strictly on the held-out 50/50 validation split (n=1,917, zero test-set leakage) and shipped in calibration.json:
| Metric | Raw Logits (T = 1.0, default) |
Temperature-Scaled (logits / 0.9446) |
|---|---|---|
Validation Temperature T |
1.0000 |
0.9446 |
| Validation ECE / Brier | 0.02403 / 0.04686 |
0.01997 / 0.04704 |
Validation 5% FPR Threshold |
0.56506 (thr_5fpr_val) |
0.56883 (calibrated_thr_5fpr) |
Validation 1% FPR Threshold (conservative) |
0.93046 (thr_1fpr_val) |
0.93968 (calibrated_thr_1fpr) |
ESL IELTS Human FPR @ 0.50 / @ thr_5fpr_val |
18.8% / 17.7% |
β (evaluate on target holdout before deploying) |
Note: Benchmark Tables 1β2 report raw-logit metrics (T = 1.0). ESL IELTS FPR at thr_1fpr_val was not separately logged in the unified run; because ESL writing exhibits elevated false positives relative to native validation text, users deploying in human-facing workflows should validate thresholds directly on a representative human holdout from their domain.
Parity-Verified ONNX Exports & Latency
Exported with onnx / onnxruntime and verified on both short documents and full 2,048-token documents. Dynamic INT8 quantization failed our strict probability-parity gate (max_abs_prob_diff > 0.05) and was intentionally excluded β only parity-verified FP32 and FP16 graphs are shipped:
| Artifact | File | Size | Short Parity (Agree / Max Ξp) | 2,048-Tok Parity (Agree / Max Ξp) | CPU 64 tok (p50) | CPU 512 tok (p50) | CPU 1,024 tok (p50) | CPU 2,048 tok (p50) |
|---|---|---|---|---|---|---|---|---|
| FP32 ONNX | onnx/model.onnx |
571.2 MB | 1.0000 / 0.00000 | 1.0000 / 0.00000 | 53.2 ms | 399.8 ms | 1083.2 ms | 3220.9 ms |
| FP16 ONNX | onnx/model_fp16.onnx |
285.8 MB | 1.0000 / 0.00131 | 1.0000 / 0.00005 | 60.1 ms | 439.2 ms | 1295.3 ms | 4161.8 ms |
Hardware disclosure: CPU latency measured with onnxruntime (4 intra-op threads, batch size 1) on GCP a2-highgpu-1g (Intel Xeon Cascade Lake @ 2.20 GHz, AVX-512). GPU latency measured on NVIDIA A100-SXM4-40GB (bf16, batch size 1): 31.0 ms @ 64 tok, 30.4 ms @ 512 tok, 34.7 ms @ 2,048 tok.
Training Summary & Data Provenance
- Canonical Backbone:
answerdotai/ModernBERT-base(149.6Mparameters,Apache-2.0). - Training Corpus (
60,768documents,51.8%AI /48.2%human, 100% commercially permissive licenses):liamdugan/raid(MIT, 6 seen domains only βrecipes&poetryheld out 100%;gpt4&mistral-chatheld out 100%;number&perplexity_misspellingattacks held out 100%; partitioned strictly bysource_idhash).yaful/MAGE(Apache-2.0, officialtrainsplit only; deduplicated against all test suites via MD5 + 12-word prefix).- Disjoint 2025β2026 open-weight synthetic slice generated with
mistralai/Mistral-7B-Instruct-v0.3(Apache-2.0) andmicrosoft/Phi-4-mini-instruct(MIT), length-matched and markdown-stripped, with strictly disjointsource_ids from theQwen3-4B/DeepSeek-R1-Distill-Llama-8Bevaluation set.
- Objective & Selection: Asymmetric human-FP BCE (
fp_weight=1.50, 0.03 label smoothing) + single-pass paired clean-vs-attacked symmetric KL consistency (lambda=0.25) + EMA (0.996), trained atmax_length=2048. Checkpoints selected strictly by validation composite (0.40 * ROC-AUC + 0.40 * TPR@5%FPR + 0.20 * Macro-F1).
Limitations & Responsible Use
- Not standalone proof for punitive decisions: AI text detection is probabilistic and inherently imperfect. Never use this model (or any AI detector) as the sole basis for academic discipline, employment action, account termination, or legal accusations. Use it as one triage/observability signal alongside human review, edit history, or provenance telemetry.
- Short text & human-AI co-editing: Accuracy degrades significantly on short snippets (
< 50words) and heavily human-edited AI drafts (or AI-grammar-checked human drafts). - Non-Native English (ESL) residual false positives: Although symmetric paragraph deconfounding reduces IELTS ESL human false positives by 2.63Γ vs.
desklib, residual FPR remains18.8%at the default0.50threshold (17.7%atthr_5fpr_val = 0.56506). For human-facing writing workflows, use a conservative threshold (such as validationthr_1fpr_val = 0.93046), validate on your target domain's human baseline, and require human review. - Unseen highly structured genres: Performance drops on out-of-distribution genres like recipes and poetry (
0.911AUC /0.60TPR@5%FPR) compared to prose, articles, essays, reviews, and technical text. - Scope of 2025β2026 evaluation: Our self-constructed
2025β26 Open-Weight 4B/8Bbenchmark evaluatesQwen3-4BandDeepSeek-R1-Distill-Llama-8Band does not directly measure closed frontier commercial API models (e.g., GPT-4o / Claude / Gemini). - English only: Trained and evaluated on English text; non-English performance is unverified.
- Downloads last month
- 13
Model tree for Tamarillo/ai-text-forensics-guard-small-en
Base model
answerdotai/ModernBERT-baseDatasets used to train Tamarillo/ai-text-forensics-guard-small-en
yaful/MAGE
Space using Tamarillo/ai-text-forensics-guard-small-en 1
Collection including Tamarillo/ai-text-forensics-guard-small-en
Evaluation results
- ROC-AUC on 2025-2026 Disjoint 4B/8B Open-Weight LLMs (Qwen3-4B + DeepSeek-R1-Distill-Llama-8B, OOD)self-reported0.999
- TPR@5%FPR on 2025-2026 Disjoint 4B/8B Open-Weight LLMs (Qwen3-4B + DeepSeek-R1-Distill-Llama-8B, OOD)self-reported0.993
- Macro-F1 on 2025-2026 Disjoint 4B/8B Open-Weight LLMs (Qwen3-4B + DeepSeek-R1-Distill-Llama-8B, OOD)self-reported0.969
- False Positive Rate @ 0.50 on chillies/ielts-writing-task2-essays (100% Human ESL Essays, OOD)self-reported0.188