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:

  1. Broken or non-standard transformers loading: desklib/ai-text-detector-v1.01 requires pasting a custom DesklibAIDetectionModel subclass and ships no id2label mapping or ONNX weights.
  2. 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.54 AUC on our long-context tail stress test).
  3. High Non-Native English (ESL) false positives & formatting shortcuts: In liamdugan/raid, 0.0% of human texts contain \n\n paragraph breaks while 58–78% of AI texts do. Naively trained RAID detectors memorize \n\n -> AI and falsely flag 49.5% of real human IELTS ESL essays (desklib).
  4. No parity-verified ONNX / browser artifacts: None of desklib, fakespot, RADAR, or openai-roberta-detector ship 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.01 while reading 2.67Γ— longer context (2,048 vs. 768 tok), 53.2 ms CPU @ 64 tok, 0.911 unseen-domain AUC (+6.3pp over tiny-en), 0.0200 calibrated validation ECE, and 2.63Γ— lower ESL human FPR than desklib (18.8% vs. 49.5%).
  • Symmetric Paragraph Deconfounding: Trained on a near-balanced corpus (60,768 docs: 51.8% AI / 48.2% human) where \n\n and \n paragraph breaks are symmetrically normalized and re-injected identically across human and AI texts (I(\n\n; y) = 0), yielding formatting-invariant detection (0.9986 raw vs. 0.9988 with all newlines stripped) and reducing IELTS ESL human false positives by 2.63Γ— on small-en (up to 5.17Γ— on base-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

Strictly OOD 5-Suite 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 (768 for desklib, 512 for 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 by source_id to be 100% disjoint from our Mistral-7B-Instruct-v0.3 / Phi-4-mini-instruct training 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.01 lists liamdugan/raid in its training metadata, so RAID Unseen Domains (recipes + poetry) and RAID splits are in-distribution for desklib while strictly held out (zero rows in train/val) for Tamarillo.
  • †fakespot-ai/roberta-base-ai-text-detection-v1 scores 1.0000 AUC / 0.9994 F1 / 0.0006 ECE on dmitva, indicating direct training-set overlap with dmitva / Kaggle DAIGT essays (whereas dmitva is 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-en achieves #1 Macro-F1 (0.9866), 0.9996 ROC-AUC, and 1.0000 TPR@5%FPR; even 32M tiny-en (0.9775 F1, 0.0273 ECE) beats 434M desklib (0.9746 F1, 0.0374 ECE) and 125M fakespot (0.9477 F1, 0.0678 ECE).
    • 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 2019 openai-roberta-detector has lower ESL FPR at 8.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.904 AUC (0.515–0.760 TPR@5%FPR), whereas desklib (768-tok cap) collapses to 0.541 / 0.115 and 512-tok RoBERTa baselines collapse to random chance (0.500 / 0.005).
    • RAID Unseen Generators & Unseen Attacks: tiny-en (0.997 / 0.99) leads RAID Unseen Models; base-en (0.995 / 0.98) leads RAID Unseen Attacks.
    • Speed, Compatibility & ONNX: base-en is 1.48Γ— faster than desklib on A100 while reading 2.67Γ— more tokens; standard AutoModelForSequenceClassification with zero trust_remote_code and 1.0000-parity FP32 + FP16 ONNX.
  • Where baselines win (reported candidly):
    • On RAID Unseen Domains (recipes + poetry), desklib (0.980 / 0.93) and fakespot (0.993 / 0.95) substantially outperform Tamarillo (tiny-en 0.848 / 0.39, small-en 0.911 / 0.60, base-en 0.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 dmitva essays, fakespot (1.000 / 1.00, training overlap) and desklib (0.999 / 1.00) score higher than Tamarillo (tiny-en 0.968 / 0.84, small-en 0.964 / 0.83, base-en 0.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.

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.6M parameters, Apache-2.0).
  • Training Corpus (60,768 documents, 51.8% AI / 48.2% human, 100% commercially permissive licenses):
    • liamdugan/raid (MIT, 6 seen domains only β€” recipes & poetry held out 100%; gpt4 & mistral-chat held out 100%; number & perplexity_misspelling attacks held out 100%; partitioned strictly by source_id hash).
    • yaful/MAGE (Apache-2.0, official train split 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) and microsoft/Phi-4-mini-instruct (MIT), length-matched and markdown-stripped, with strictly disjoint source_ids from the Qwen3-4B / DeepSeek-R1-Distill-Llama-8B evaluation 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 at max_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 (< 50 words) 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 remains 18.8% at the default 0.50 threshold (17.7% at thr_5fpr_val = 0.56506). For human-facing writing workflows, use a conservative threshold (such as validation thr_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.911 AUC / 0.60 TPR@5%FPR) compared to prose, articles, essays, reviews, and technical text.
  • Scope of 2025–2026 evaluation: Our self-constructed 2025–26 Open-Weight 4B/8B benchmark evaluates Qwen3-4B and DeepSeek-R1-Distill-Llama-8B and 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
Safetensors
Model size
0.1B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Tamarillo/ai-text-forensics-guard-small-en

Quantized
(96)
this model

Datasets used to train Tamarillo/ai-text-forensics-guard-small-en

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-reported
    0.999
  • TPR@5%FPR on 2025-2026 Disjoint 4B/8B Open-Weight LLMs (Qwen3-4B + DeepSeek-R1-Distill-Llama-8B, OOD)
    self-reported
    0.993
  • Macro-F1 on 2025-2026 Disjoint 4B/8B Open-Weight LLMs (Qwen3-4B + DeepSeek-R1-Distill-Llama-8B, OOD)
    self-reported
    0.969
  • False Positive Rate @ 0.50 on chillies/ielts-writing-task2-essays (100% Human ESL Essays, OOD)
    self-reported
    0.188