ModernBERT LLM Authorship Attribution
Fine-tuned ModernBERT-base that classifies the author of a short English Q&A answer into five classes: human, Claude (Haiku 4.5), GPT (GPT-5 mini), Gemini (2.5 Flash), Kimi (K2).
Try it in your browser: Authorship Attribution - inference runs fully client-side via Transformers.js.
Files
The model is supplied in three formats:
| File | Size | Format | Used by |
|---|---|---|---|
model.safetensors | 598 MB | PyTorch weights, 32-bit float | Python transformers |
onnx/model.onnx | 599 MB | ONNX, 32-bit float | Transformers.js with dtype: "fp32" |
onnx/model_quantized.onnx | 151 MB | ONNX, 8-bit quantized | Transformers.js with dtype: "q8", and the browser demo |
The quantized file was made with ONNX Runtime dynamic quantization. The token embedding table and every linear layer (99.98% of the 149.6M parameters) are stored as 8-bit integers instead of 32-bit floats, with a separate scale per output channel in the linear layers. That makes the file about 4x smaller. Activations are converted to 8-bit on the fly inside those layers. LayerNorm, GELU, attention scores and softmax still run in 32-bit float.
Both ONNX files also run in ONNX Runtime directly (inputs input_ids and attention_mask, output logits).
Training data
Derived from the HC3 corpus (CC-BY-SA-4.0), extended with answers generated by the four LLMs above across 5,306 questions on finance, medicine, and general knowledge. Split at the question level to prevent leakage.
Evaluation
- PyTorch weights: 98.0% accuracy on a held-out test sample (n=150, chance = 20%). Per-class F1 0.98-0.99.
- Quantized ONNX (
onnx/model_quantized.onnx, 8-bit per-channel, 151 MB): 98.7% on the same sample, 98.7% agreement with fp32.
Usage
Python, PyTorch weights:
from transformers import pipeline
clf = pipeline("text-classification", model="tildahh/modernbert-base-llm-author-attribution")
clf("your text here", top_k=None)
JavaScript, quantized ONNX (the same call the demo makes):
import { pipeline } from "@huggingface/transformers";
const classify = await pipeline(
"text-classification",
"tildahh/modernbert-base-llm-author-attribution",
{ dtype: "q8" } // "q8" loads onnx/model_quantized.onnx, "fp32" loads onnx/model.onnx
);
const scores = await classify("your text here", { top_k: null });
Limitations
Research artifact, not a general-purpose AI detector. Trained on short Q&A answers and four specific 2025-era models. Performance beyond the evaluated domains and model versions has not been established. Confidence scores saturate near 100% and are not calibrated probabilities. A prediction does not establish who wrote a passage. Provided as-is, no warranties.
Model created by Terra Jiang, Matilda Orona & Rahil Sharma for Natural Language Processing with Deep Learning, UC Berkeley MIDS, 2026.