Tamarillo/ai-text-forensics-guard-tiny-en (v2)
v2 Ultra-Fast Edge & Browser Tier (32M) — Apache-2.0, zero-trust_remote_code, long-context (2,048 trained / 8,192 native RoPE) English AI-text provenance and adversarial-humanizer detector built on standard ModernBertForSequenceClassification (0=human, 1=ai_generated).
What's new in v2:
- Slashes Non-Native (ESL) Human False Positives (zero IELTS training leakage): Cuts IELTS ESL human FPR@0.50 from
19.8%(v1) to7.0%(v2) —7.07×lower thandesklib/ai-text-detector-v1.01(49.5%) — via pre-2022 human academic essays (ChristophSchuhmann/essays-with-instructions, Apache-2.0) and low-FPR asymmetric loss (fp_weight=1.65). - Defeats 2nd-Pass Adversarial LLM Humanizers: Lifts strictly unseen
microsoft/Phi-4-mini-instruct2nd-pass humanized AI detection from0.20->0.98TPR@5%FPR (0.914->0.997AUC) via paired clean-vs-humanized symmetric KL consistency on our open Apache-2.0 corpusTamarillo/ai-text-forensics-2026. - #1 Tier Class on Humanized-AI vs. IELTS ESL Cross-Stress: Achieves
0.990AUC /0.96TPR@5%FPR /0.914Macro-F1 (up from0.786v1; vs.desklib0.587F1,fakespot0.759F1,RADAR-Vicuna-7B0.682F1) while being 13.6× smaller thandesklib(32.0Mvs.434.0M). - Interactive Browser Demo: Try locally via WebAssembly ONNX in
Tamarillo/ai-text-forensics-guard-demo.
Quickstart (< 30 Seconds)
Requires pip install "transformers>=4.48" torch (standard AutoModelForSequenceClassification, zero trust_remote_code; attn_implementation="eager" ensures exact numerical parity with our ONNX exports, while default SDPA/FlashAttention can be enabled on GPUs for higher throughput):
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_id = "Tamarillo/ai-text-forensics-guard-tiny-en"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(
model_id, attn_implementation="eager"
).eval()
texts = [
"In modern society, many young people move from small towns to big cities for better job opportunities, although expensive rent and heavy traffic create real trade-offs for families.",
"Write-ahead logging, or WAL, is a way relational databases handle crash recovery. When you start a transaction, the database saves all changes to a log file first before updating data pages.",
]
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, natively calibrated; used in benchmark tables below)
probs = torch.softmax(logits, dim=-1)
# Optional validation temperature-scaled probabilities from calibration.json (T=1.0378)
probs_cal = torch.softmax(logits / 1.0378, 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)
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-tiny-en"
tokenizer = AutoTokenizer.from_pretrained(model_id)
onnx_path = hf_hub_download(model_id, "onnx/model_fp16.onnx") # or "onnx/model.onnx"
session = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])
enc = tokenizer(
"Write-ahead logging, or WAL, is a way relational databases handle crash recovery.",
truncation=True,
max_length=2048,
return_tensors="np",
)
logits = session.run(
["logits"],
{"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)
(For in-browser WebAssembly deployments, we recommend Tamarillo/ai-text-forensics-guard-tiny-en at 61.3 MB FP16 for fast downloads and low RAM; larger tiers are best suited for Node.js or server-side ONNX Runtime.)
import { AutoTokenizer, AutoModelForSequenceClassification } from "@huggingface/transformers";
const modelId = "Tamarillo/ai-text-forensics-guard-tiny-en";
const tokenizer = await AutoTokenizer.from_pretrained(modelId);
const model = await AutoModelForSequenceClassification.from_pretrained(modelId, { dtype: "fp16" });
const inputs = tokenizer("Write-ahead logging, or WAL, is a way relational databases handle crash recovery.", {
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 });
Family Ladder (v2)
| Model | Backbone | Params | Strictly OOD-6 Mean AUC | Humanized AI vs. ESL (AUC / F1) | ESL IELTS FPR@0.50 ↓ | CPU @ 64 tok (FP32) | FP16 ONNX | Gather-INT8 ONNX |
|---|---|---|---|---|---|---|---|---|
Tamarillo/ai-text-forensics-guard-tiny-en | jhu-clsp/ettin-encoder-32m | 32.0M | 0.947 | 0.990 / 0.914 | 7.0% | 9.5 ms | 61.3 MB | 67.2 MB |
Tamarillo/ai-text-forensics-guard-small-en | answerdotai/ModernBERT-base | 149.6M | 0.966 | 0.993 / 0.937 | 5.2% | 55.4 ms | 285.8 MB | withheld |
Tamarillo/ai-text-forensics-guard-base-en | answerdotai/ModernBERT-large | 395.8M | 0.971 | 0.995 / 0.947 | 4.3% | 164.6 ms | 755.6 MB | 1363.4 MB |
Strictly OOD Pareto Frontier
Head-to-Head Evaluation (10 Models, Same NVIDIA A100-SXM4-40GB)
All 10 models (Tamarillo v2, Tamarillo v1, and 4 public baselines) were evaluated head-to-head on the exact same GPU and exact same splits using raw softmax/sigmoid outputs (T = 1.0). ModernBERT models ran with attn_implementation="eager"; desklib/ai-text-detector-v1.01 ran with its official DesklibAIDetectionModel class and documented max_len=768.
Table 1: Strictly OOD 6-Suite Benchmarks (ROC-AUC / TPR@5%FPR)
| Model | Params | Context | Humanizer-2026 (Phi-4 Humanized, n=900) | Unseen DeepSeek-R1-Llama-8B (n=1,554) | RAID Unseen Models (n=970) | RAID Unseen Domains (n=1,200) | RAID Unseen Attacks (n=796) | External dmitva (n=1,600) | OOD-6 Mean AUC |
|---|---|---|---|---|---|---|---|---|---|
| Tamarillo tiny-en v2 | 32.0M | 2,048 (8K) | 0.997 / 0.98 | 0.998 / 0.99 | 0.994 / 0.97 | 0.742 / 0.05 | 0.990 / 0.96 | 0.959 / 0.81 | 0.947 |
| Tamarillo small-en v2 | 149.6M | 2,048 (8K) | 0.997 / 0.99 | 0.998 / 0.99 | 0.991 / 0.96 | 0.843 / 0.36 | 0.993 / 0.97 | 0.974 / 0.86 | 0.966 |
| Tamarillo base-en v2 | 395.8M | 2,048 (8K) | 0.998 / 0.99 | 0.998 / 1.00 | 0.988 / 0.96 | 0.863 / 0.19 | 0.992 / 0.96 | 0.987 / 0.94 | 0.971 |
| Tamarillo tiny-en v1 | 32.0M | 2,048 (8K) | 0.914 / 0.20 | 0.998 / 0.98 | 0.997 / 0.99 | 0.847 / 0.39 | 0.990 / 0.95 | 0.968 / 0.84 | 0.954 |
| Tamarillo small-en v1 | 149.6M | 2,048 (8K) | 0.919 / 0.64 | 0.997 / 0.99 | 0.992 / 0.97 | 0.911 / 0.61 | 0.989 / 0.96 | 0.964 / 0.83 | 0.964 |
| Tamarillo base-en v1 | 395.8M | 2,048 (8K) | 0.956 / 0.85 | 0.999 / 1.00 | 0.993 / 0.98 | 0.908 / 0.44 | 0.995 / 0.98 | 0.984 / 0.94 | 0.974 |
desklib/ai-text-detector-v1.01* (MIT) | 434.0M | 768 (DeBERTa) | 0.999 / 0.99 | 0.999 / 1.00 | 0.988 / 0.96 | 0.980 / 0.93 | 0.989 / 0.95 | 0.999 / 1.00 | 0.992 |
fakespot-ai/roberta-base-ai-text-detection-v1† | 124.7M | 512 | 0.991 / 0.96 | 0.999 / 0.99 | 0.987 / 0.91 | 0.993 / 0.95 | 0.988 / 0.95 | 1.000 / 1.00 | 0.993 |
TrustSafeAI/RADAR-Vicuna-7B | 355.4M | 512 | 0.895 / 0.32 | 0.985 / 0.91 | 0.964 / 0.88 | 0.883 / 0.52 | 0.907 / 0.64 | 0.962 / 0.76 | 0.933 |
openai-community/roberta-large-openai-detector | 355.4M | 512 | 0.338 / 0.03 | 0.599 / 0.21 | 0.782 / 0.46 | 0.767 / 0.51 | 0.816 / 0.54 | 0.650 / 0.14 | 0.660 |
Dataset-overlap & OOD integrity disclosures:
Humanizer-2026(ood_humanizer_2026,n=1,200total;n=900humanized slice shown): Pairs300clean +3002nd-pass casual-rewriter humanized passages from MITmicrosoft/Phi-4-mini-instruct(fromTamarillo/ai-text-forensics-2026) against600strictly disjoint pre-2022 human passages (200student essays,200held-out MAGE test human passages,100FiscalNote/billsum,100abisee/cnn_dailymail).Phi-4-mini-instructwas strictly excluded from all Tamarillo v2 training/validation data (whereas v1 training included cleanPhi-4-miniprompts).- Strictly unseen
DeepSeek-R1-Distill-Llama-8B:Qwen/Qwen3-8Bwas used to synthesize our v2 paired humanizer training split, makingQwen/Qwen3-4Ba same-family smaller sibling for v2. Therefore,Qwen/Qwen3-4Bis excluded from the OOD-6 Mean AUC above and reported separately in Table 2 (‡); only strictly unseendeepseek-ai/DeepSeek-R1-Distill-Llama-8Benters Table 1. - *
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.000AUC /1.00TPR@5%FPR ondmitva, indicating training-set overlap withdmitva/ Kaggle DAIGT essays (whereasdmitvais 100% OOD for Tamarillo).
Table 2: ESL Human Fairness, Humanized-AI vs. ESL Cross-Stress, Long-Context Tail & Auxiliary Suites
(Reported separately from the OOD-6 composite above; all scores use raw logits T = 1.0.)
| Model | ESL IELTS FPR@0.50 ↓ (n=1,200) | ESL Mean P(AI) ↓ | Humanized AI vs. IELTS ESL (AUC / TPR@5% / F1, n=1,500, 300:1,200) | Long-Context Tail Stress (AUC / TPR@5%, n=400) | Qwen3-4B‡ AUC (n=1,584) | Frontier Flat AUC (n=2,088, no \n) | MAGE Test AUC (ID, n=2,000) | A100 @ 2K (eager / native) |
|---|---|---|---|---|---|---|---|---|
| Tamarillo tiny-en v2 | 7.0% | 0.088 | 0.990 / 0.96 / 0.914 | 0.879 / 0.59 | 1.000 | 0.999 | 0.973 | 22.6 ms |
| Tamarillo small-en v2 | 5.2% | 0.066 | 0.993 / 0.99 / 0.937 | 0.886 / 0.49 | 1.000 | 0.999 | 0.976 | 55.0 ms |
| Tamarillo base-en v2 | 4.3% | 0.059 | 0.995 / 0.99 / 0.947 | 0.884 / 0.58 | 0.999 | 0.998 | 0.981 | 95.6 ms |
| Tamarillo tiny-en v1 | 19.8% | 0.215 | 0.924 / 0.28 / 0.786 | 0.908 / 0.68 | 1.000 | 0.999 | 0.971 | 22.6 ms |
| Tamarillo small-en v1 | 18.6% | 0.208 | 0.932 / 0.69 / 0.791 | 0.858 / 0.42 | 1.000 | 0.999 | 0.971 | 55.1 ms |
| Tamarillo base-en v1 | 9.5% | 0.121 | 0.978 / 0.93 / 0.890 | 0.895 / 0.71 | 1.000 | 1.000 | 0.977 | 90.6 ms |
desklib/ai-text-detector-v1.01* (MIT) | 49.5% | 0.513 | 0.963 / 0.86 / 0.587 | 0.552 / 0.07 | 0.999 | 0.999 | 0.934 | 66.6 ms |
fakespot-ai/roberta-base-ai-text-detection-v1† | 24.8% | 0.254 | 0.963 / 0.85 / 0.759 | 0.500 / 0.01 | 1.000 | 1.000 | 0.820 | 11.3 ms |
TrustSafeAI/RADAR-Vicuna-7B | 24.0% | 0.312 | 0.794 / 0.28 / 0.682 | 0.500 / 0.01 | 0.988 | 0.982 | 0.676 | 21.7 ms |
openai-community/roberta-large-openai-detector | 4.3% | 0.066 | 0.345 / 0.03 / 0.457 | 0.500 / 0.01 | 0.733 | 0.667 | 0.782 | 21.6 ms |
Note on ‡, class ratios, and latency: Qwen3-4B (‡) is a same-family smaller sibling of Tamarillo v2's Qwen/Qwen3-8B synthetic training split. Humanized AI vs. IELTS ESL (n=1,500) uses a 1:4 class ratio (300 humanized Phi-4-mini AI vs. 1,200 IELTS ESL human essays) and covers one LLM rewriter style rather than commercial paraphrasing suites. Long-Context Tail Stress (n=400) concatenates 3 disjoint human passages (~1,100 tokens) with either a human or 2025–26 AI tail from ood_frontier_2026. A100 @ 2K latencies reflect full 2,048-token inputs for Tamarillo (attn_implementation="eager") versus truncated 768-token (desklib) or 512-token (RoBERTa/RADAR) baselines. Reproducible training and evaluation scripts are published at github.com/duoi-bt/tamarillo-guardrails.
Candid summary of wins & losses:
- Where Tamarillo v2 wins decisively:
- 2nd-Pass Adversarial Humanizer Robustness + Non-Native ESL Fairness: Across all 3 tiers (
32M,150M,396M), Tamarillo v2 sweeps #1, #2, and #3 onHumanized AI vs. IELTS ESL(0.914 / 0.937 / 0.947Macro-F1;0.96–0.99TPR@5%FPR) — beating 13.6× largerdesklib(0.587F1),fakespot(0.759F1), andRADAR-Vicuna-7B(0.682F1) while cutting IELTS ESL false positives to4.3%–7.0%(vs.desklib49.5%,fakespot24.8%,RADAR24.0%, and Tamarillo v19.5%–19.8%). - Long-Context Documents (>900-token human prefix + human vs. 2025–26 AI tail): All 3 v2 tiers score
0.879–0.886AUC (0.49–0.59TPR@5%FPR), whereasdesklib(768-tok cap) drops to0.552 / 0.07and512-tok baselines collapse to random chance (0.500 / 0.01). - Zero-Drama Compatibility & Parity-Verified ONNX: Standard
AutoModelForSequenceClassification(zero custom subclasses, zerotrust_remote_code) with verified FP32/FP16 (and Gather-INT8 ontiny-en/base-en) ONNX exports.
- 2nd-Pass Adversarial Humanizer Robustness + Non-Native ESL Fairness: Across all 3 tiers (
- Where baselines or v1 win (reported candidly):
- Unseen highly structured genres (
RAID Unseen Domains:recipes+poetry): Adding pre-2022 student essays and low-FPR humanization regularization trades-4.5to-10.5AUC points vs. v1 (base-en0.908 -> 0.863,small-en0.911 -> 0.843,tiny-en0.847 -> 0.742), and bothdesklib(0.980, RAID-ID) andfakespot(0.993) substantially outperform Tamarillo on recipes and poetry. dmitvaessays:fakespot(1.000, overlap) anddesklib(0.999) score higher than Tamarillo v2 (0.959–0.987, thoughsmall-env2 gained+1.0andbase-env2 gained+0.3over v1).- Raw GPU throughput under eager attention: At
2,048tokens underattn_implementation="eager",base-en(95.6 ms) is slower than truncated768-tokdesklib(66.6 ms) and512-tok RoBERTa (11.3–21.7 ms). Usetiny-en(22.6 ms@ 2K GPU /9.5 ms@ 64 tok CPU) orsmall-en(55.0 ms@ 2K GPU) when latency dominates. openai-community/roberta-large-openai-detectormatchesbase-env2's4.3%ESL FPR only because it predicts human on almost all modern text (missing97%of 2026 humanized AI and79%ofDeepSeek-R1).
- Unseen highly structured genres (
Calibration & Operating Thresholds (calibration.json)
Fit strictly on the held-out validation split (n=2,316, zero test leakage) and shipped in calibration.json:
| Metric | Raw Logits (T = 1.0, default) | Temperature-Scaled (logits / 1.0378) |
|---|---|---|
Validation Temperature T | 1.0000 | 1.0378 |
| Validation ECE / Brier | 0.02465 / 0.03857 | 0.02318 / 0.03841 |
Validation 5% FPR Threshold | 0.24908 (thr_5fpr_val) | 0.25668 (calibrated_thr_5fpr) |
Validation 1% FPR Threshold (conservative) | 0.86339 (thr_1fpr_val) | 0.85527 (calibrated_thr_1fpr) |
ESL IELTS Human FPR @ 0.50 / @ thr_5fpr_val | 7.0% / 8.5% | — (validate on target human holdout before deploying) |
Parity-Verified ONNX Exports & Latency
Exported with onnx / onnxruntime and verified on both short (n=16) and 2,048-token (n=8) probes against PyTorch eager FP32. FP32, FP16, and Gather-only QUInt8 all passed our strict >=0.995 agreement and <=0.05 max probability-delta gate. Note: Gather-only QUInt8 quantizes only the embedding table while keeping transformer projection weights in FP32 for exact ModernBERT logit parity, which is why FP16 is smaller on disk while Gather-INT8 can be slightly faster on CPU.
| 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 | 122.4 MB | 1.0000 / 0.00000 (n=16) | 1.0000 / 0.00000 (n=8) | 9.5 ms | 73.3 ms | 216.9 ms | 719.7 ms |
| FP16 ONNX | onnx/model_fp16.onnx | 61.3 MB | 1.0000 / 0.00076 (n=16) | 1.0000 / 0.00002 (n=8) | 10.9 ms | 83.7 ms | 265.6 ms | 921.5 ms |
| Gather-INT8 ONNX | onnx/model_quantized.onnx | 67.2 MB | 1.0000 / 0.03673 (n=16) | 1.0000 / 0.00021 (n=8) | 8.6 ms | 72.6 ms | 216.4 ms | 730.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). GPU latency measured on NVIDIA A100-SXM4-40GB (bf16, attn_implementation="eager", batch size 1): 13.9 ms @ 64 tok, 14.3 ms @ 512 tok, 22.6 ms @ 2,048 tok.
Training Summary & Data Provenance
- Canonical Backbone:
jhu-clsp/ettin-encoder-32m(32.0Mparameters,MIT). - Training Corpus (
60,671documents,49.0%AI /51.0%human, 100% commercially permissive & pre-2022 human provenance):Tamarillo/ai-text-forensics-2026(Apache-2.0,qwen3_trainsplit generated withQwen/Qwen3-8B— paired clean + 2nd-pass adversarial humanized AI drafts sharinggroup_id;howto_guideexcluded to avoid recipe shortcuts;phi4_humanizer_ood_test100% held out).liamdugan/raid(MIT, 6 seen domains only —recipes&poetry,gpt4&mistral-chat, andnumber&perplexity_misspellingattacks 100% held out; partitioned strictly bysource_idhash).yaful/MAGE(Apache-2.0, officialtrainsplit only; deduplicated against all evaluation suites via MD5 + 12-word prefix).ChristophSchuhmann/essays-with-instructions(Apache-2.0, pre-2022 IvyPanda human academic essays with TOC/References stripped; zerochillies/ielts-writing-task2-essaysrows in train/val).- Disjoint
mistralai/Mistral-7B-Instruct-v0.3(Apache-2.0) clean + adversarial passages + matched human (microsoft/Phi-4-mini-instructstrictly excluded from v2 training).
- Formatting Deconfounding: Symmetric paragraph-break normalization (
I(\n\n; y) = 0) eliminates the RAID\n\n -> AIshortcut (0.9986raw vs.0.9988newline-stripped). - Objective & Selection: Distilled from
Tamarillo/ai-text-forensics-guard-base-env2 (answerdotai/ModernBERT-large) via OOM-safe soft-probability KD + Z-score standardized margin MSE (kd_weight=0.45) combined with asymmetric human-FP BCE (fp_weight=1.65) and paired clean-vs-attacked/humanized symmetric KL consistency (lam_kl=0.30). Checkpoints selected strictly by validation composite (0.35 * ROC-AUC + 0.35 * TPR@5%FPR + 0.15 * Macro-F1 + 0.15 * (1 - FPR@0.50)).
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: Even at
7.0%FPR@0.50 on IELTS ESL essays (8.5%atthr_5fpr_val = 0.24908), non-native writers still face non-zero false flags. In human-facing writing workflows, raise the operating threshold (e.g.,thr_1fpr_val = 0.86339), validate directly on your domain's human baseline, and require human review. - Unseen highly structured genres: Performance drops on out-of-distribution genres like recipes and poetry (
0.742AUC /0.05TPR@5%FPR) relative to essays, articles, reviews, and technical prose. - Scope of 2025–2026 evaluation: Our open-weight benchmarks cover
Phi-4-mini-instruct(clean & 2nd-pass humanized),DeepSeek-R1-Distill-Llama-8B, andQwen3-4B, and do not directly benchmark closed commercial API models (e.g., GPT-4o / Claude / Gemini). - English only: Trained and evaluated on English prose (
max_length=2048, native8,192RoPE); non-English accuracy is unverified.