Instructions to use tssandor/pdf-text-quality-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tssandor/pdf-text-quality-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="tssandor/pdf-text-quality-small")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("tssandor/pdf-text-quality-small") model = AutoModelForSequenceClassification.from_pretrained("tssandor/pdf-text-quality-small", device_map="auto") - Transformers.js
How to use tssandor/pdf-text-quality-small with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'tssandor/pdf-text-quality-small'); - Notebooks
- Google Colab
- Kaggle
MerahModels — PDF Text Quality Classifier (Small)
Does this PDF page need OCR, or is its extracted text already usable?
A fast, MIT-licensed, CPU-ready multilingual classifier by MerahModels.
What This Model Does
When you extract text from a PDF using pypdf, pymupdf, or another parser, pages often return non-empty text that is still unreadable — shifted font encodings (3URGXFW 6SHFLILFDWLRQ), raw glyph names (/C50/C72/C6f), replacement boxes (����), broken spacing, or heavily degraded scan OCR. Running OCR or a vision-language model on every page wastes time and money.
This model inspects a page's extracted text on CPU in milliseconds and returns:
CLEAN(0) — the text layer is usable; keep it as-is.GARBLED(1) — the text layer is corrupted; route this page to an OCR or VLM fallback.p_garbled— a calibrated probability (0.0to1.0) so you can tune the trade-off between catching borderline scans and minimizing OCR cost.
| What the extracted page looks like | Model output | Pipeline action |
|---|---|---|
| Normal prose, numeric tables, BOM lists, code, Arabic, vertical Japanese | CLEAN |
Keep extracted text |
Shifted font encoding (3URGXFW 6SHFLILFDWLRQ 6HFWLRQ 7KUHH...) |
GARBLED |
Route page to OCR / VLM |
Raw glyph IDs (/C50/C72/C6f/C64/C75...) or ���� replacement boxes |
GARBLED |
Route page to OCR / VLM |
| Garbled historical OCR, glued columns, exploded spaces, or overprinted letters | GARBLED |
Route page to OCR / VLM |
(Empty or image-only scanned pages have no text layer to classify — route pages with fewer than ~30 characters to OCR deterministically before calling the model.)
Why Use It
- Fast on plain CPU (no GPU needed): Ships as quantized int8 ONNX (
135.7 MiBweights +32.8 MiBtokenizer.json) plus fp32 ONNX and PyTorch weights, and runs in Python (onnxruntimeortransformers) and JavaScript/TypeScript (@huggingface/transformers). - Sees characters other encoders drop: Built on ModernBERT/mmBERT with a byte-fallback tokenizer across 26 languages and 10 scripts, preserving
�(U+FFFD), Private-Use-Area symbols, and spacing anomalies instead of silently discarding them. - Low false alarms on tricky clean pages: Tested against code snippets, financial tables, part-number lists, and vertical CJK text so clean technical PDFs do not get sent to OCR unnecessarily.
- MIT-licensed: Permissively licensed weights trained on open-licensed corpora for commercial and open-source document pipelines.
Which Tier Should I Pick?
- **
tssandor/pdf-text-quality-small(this model — recommended default):** Best accuracy and fewest false alarms (0.9888 F1 on held-outtest, ~33 ms/page CPU, 135.7 MiB int8 ONNX). tssandor/pdf-text-quality-mini(ultra-fast CPU tier):** Pruned 10-layer model that runs ~2.1× faster on CPU (~16 ms/page** / 66.6 pages/s batched; 0.9438 F1 at 256 tokens or 0.9888 F1 at 512 tokens, 113.2 MiB int8 ONNX).
(An internal mmBERT-base model was trained solely as the distillation teacher and is not published.)
Quickstart (Zero-PyTorch CPU — onnxruntime + tokenizers)
import json
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from tokenizers import Tokenizer
REPO = "tssandor/pdf-text-quality-small"
model_path = hf_hub_download(REPO, "onnx/model_quantized.onnx")
tok_path = hf_hub_download(REPO, "tokenizer.json")
cal_path = hf_hub_download(REPO, "calibration.json")
cal = json.loads(open(cal_path, encoding="utf-8").read())
temperature = cal["temperature"] # 1.5559
tok = Tokenizer.from_file(tok_path)
tok.no_padding()
tok.no_truncation()
sess = ort.InferenceSession(model_path, providers=["CPUExecutionProvider"])
def score_page(text: str, max_length: int = 256, threshold: float = 0.5) -> dict:
# Route empty / image-only pages to OCR deterministically before neural scoring
if len(text.strip()) < 30:
return {"label": "EMPTY", "p_garbled": 1.0}
ids = tok.encode(text, add_special_tokens=True).ids # [<bos>, ..., <eos>]
if len(ids) > max_length:
head = max(2, int(max_length * 0.75))
ids = ids[:head] + ids[-(max_length - head):]
logits = sess.run(
["logits"],
{"input_ids": np.array([ids], dtype=np.int64), "attention_mask": np.ones((1, len(ids)), dtype=np.int64)},
)[0][0]
scaled = logits / temperature
scaled -= scaled.max()
probs = np.exp(scaled) / np.exp(scaled).sum()
p_garbled = float(probs[1])
return {"label": "GARBLED" if p_garbled >= threshold else "CLEAN", "p_garbled": round(p_garbled, 4)}
print(score_page("The committee approved the annual financial report on May 14, 2025."))
print(score_page("3URGXFW 6SHFLILFDWLRQ 6HFWLRQ 7KUHH UHTXLUHPHQWV"))
print(score_page("/C50/C72/C6f/C64/C75/C63/C74 /C53/C70/C65/C63"))
Python — PyTorch (transformers 4.x & 5.x)
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
REPO = "tssandor/pdf-text-quality-small"
TEMPERATURE = 1.5559
tokenizer = AutoTokenizer.from_pretrained(REPO)
model = AutoModelForSequenceClassification.from_pretrained(REPO).eval()
def classify_page(text: str, max_length: int = 256, threshold: float = 0.5) -> dict:
if len(text.strip()) < 30:
return {"label": "EMPTY", "p_garbled": 1.0}
ids = tokenizer(text, add_special_tokens=True, truncation=False)["input_ids"]
if len(ids) > max_length:
head = max(2, int(max_length * 0.75))
ids = ids[:head] + ids[-(max_length - head):]
input_ids = torch.tensor([ids])
with torch.no_grad():
logits = model(input_ids=input_ids, attention_mask=torch.ones_like(input_ids)).logits[0]
p_garbled = float(torch.softmax(logits / TEMPERATURE, dim=-1)[1])
return {"label": "GARBLED" if p_garbled >= threshold else "CLEAN", "p_garbled": round(p_garbled, 4)}
JavaScript / TypeScript (@huggingface/transformers)
Use explicit AutoTokenizer + AutoModelForSequenceClassification (rather than pipeline) so long PDF pages apply the same 75%/25% head+tail truncation and temperature scaling used in Python ONNX:
import { AutoModelForSequenceClassification, AutoTokenizer, Tensor } from "@huggingface/transformers";
const REPO = "tssandor/pdf-text-quality-small";
const TEMPERATURE = 1.5559;
const MAX_LENGTH = 256;
const tokenizer = await AutoTokenizer.from_pretrained(REPO);
const model = await AutoModelForSequenceClassification.from_pretrained(REPO, { dtype: "q8" });
export async function scorePage(text: string, threshold = 0.5) {
if (text.trim().length < 30) return { label: "EMPTY", p_garbled: 1.0 };
const encoded = await tokenizer(text, { add_special_tokens: true, truncation: false });
let ids = Array.from(encoded.input_ids.data, (x) => BigInt(x));
if (ids.length > MAX_LENGTH) {
const head = Math.max(2, Math.floor(MAX_LENGTH * 0.75));
ids = [...ids.slice(0, head), ...ids.slice(ids.length - (MAX_LENGTH - head))];
}
const input_ids = new Tensor("int64", BigInt64Array.from(ids), [1, ids.length]);
const attention_mask = new Tensor("int64", new BigInt64Array(ids.length).fill(1n), [1, ids.length]);
const { logits } = await model({ input_ids, attention_mask });
const l0 = Number(logits.data[0]) / TEMPERATURE;
const l1 = Number(logits.data[1]) / TEMPERATURE;
const m = Math.max(l0, l1);
const p_garbled = Math.exp(l1 - m) / (Math.exp(l0 - m) + Math.exp(l1 - m));
return { label: p_garbled >= threshold ? "GARBLED" : "CLEAN", p_garbled: Number(p_garbled.toFixed(4)) };
}
Model Family & Baseline Overview
All CPU timings were measured live on Apple M3 Pro (onnxruntime 1.32.0, CPUExecutionProvider); datalab-to/ocr_error_detection has no upstream ONNX export and was timed live in PyTorch CPU on the same machine via eval_pytorch_and_datalab.py (258.1 MiB safetensors).
| Model | License | Weights (+ tokenizer.json) |
Single-Page CPU @256 (full 256 tok / mixed) |
Held-Out test F1 (n=91) |
Curated dev F1 (n=196) |
Dev Open-PDF F1 / FPR (n=60) |
26-Lang Synth F1 (n=5,160) |
|---|---|---|---|---|---|---|---|
tssandor/pdf-text-quality-small (int8@256, b=1) (default) |
MIT | 135.7 MiB (+ 32.8 MiB) | 32.8 ms / 26.6 ms | 0.9888 | 0.9735 | 0.9825 / 3.12% | 0.9947 (@512) |
tssandor/pdf-text-quality-mini (int8@256, b=1) |
MIT | 113.2 MiB (+ 32.8 MiB) | 16.2 ms / 12.4 ms | 0.9438 | 0.9399 | 0.9825 / 3.12% | 0.9944 (@512) |
datalab-to/ocr_error_detection (@0.5, PyTorch) |
CC-BY-NC-SA-4.0 | 258.1 MiB (fp16 PT, no ONNX) | 26.5 ms / 21.7 ms | 0.8500 | 0.8121 | 0.4615 / 6.25% | 0.4468 |
datalab-to/ocr_error_detection (@0.000398 val-tuned) |
CC-BY-NC-SA-4.0 | 258.1 MiB (fp16 PT, no ONNX) | 26.5 ms / 21.7 ms | 0.9474 | 0.9126 | 0.7879 / 37.50% | 0.7934 |
Char-TFIDF + LogReg (data_v5, @0.364172 val-tuned) |
MIT | Linear | 0.99 ms (incl. vec) | 0.9677 | 0.9261 | 0.8060 / 37.50% | 0.9393 |
Deterministic Heuristics (@0.001935 val-tuned) |
MIT | Rules | 0.22 ms | 0.1633 | 0.4320 | 0.9286 / 6.25% | 0.6801 |
Why byte-fallback tokenization matters: Both WordPiece (
distilbert-base-multilingual-cased, used bydatalab-to/ocr_error_detection) and SentencePiece (xlm-roberta) silently dropU+FFFDreplacement characters to[]and collapse multi-space column gaps. ModernBERT/mmBERT's 256k Gemma-2 byte-fallback tokenizer preservesU+FFFD, Private-Use-Area glyphs, control bytes, and spacing anomalies across scripts up to 8,192 tokens. Note thatdatalab-to/ocr_error_detectionranks historical OCR strongly (ROC-AUC1.0000 dev / 1.0000 test), but misses most native PDF text-layer corruptions at@0.5(0.4615 Open-PDF F1) and incurs 37.50% Open-PDF FPR when its threshold is lowered to0.000398.
Detailed Benchmarks for pdf-text-quality-small
1. Held-Out Evaluation Split (tssandor/pdf-text-quality-bench test, n = 91)
Disjoint by document, newspaper issue, and text from training, dev, and our earlier Round-1 benchmark (data_v4/bench_real.jsonl): 82 historical OCR passages (PleIAs/Post-OCR-Correction, CC0-1.0 across EN/FR/DE/IT, with German having fewer qualifying rows than EN/FR/IT; clean passages are LLM-corrected and the 0.10–0.18 CER band is excluded) + 9 unique-file open PDFs (5 clean CC-BY-SA-4.0, 4 broken Apache-2.0 test fixtures; small n=9 open-PDF slice, interpret with caution). (Benchmark filtering and deduplication were refined across pre-release review rounds without modifying model weights.)
| Runtime & Context | Overall F1 | P | R | ROC-AUC | ECE | Open PDFs F1 (9p) | Open PDFs FPR | Hist OCR F1 (82p) | Non-Latin PDF F1 |
|---|---|---|---|---|---|---|---|---|---|
ONNX int8 (max_len=256, batch=1) |
0.9888 | 1.0000 | 0.9778 | 1.0000 | 0.0137 | 1.0000 | 0.00% (0/5) | 0.9877 | — |
ONNX int8 (max_len=256, batch=16) |
0.9888 | 1.0000 | 0.9778 | 1.0000 | 0.0137 | 1.0000 | 0.00% (0/5) | 0.9877 | — |
ONNX fp32 (max_len=256, batch=16) |
1.0000 | 1.0000 | 1.0000 | 1.0000 | 0.0058 | 1.0000 | 0.00% (0/5) | 1.0000 | — |
ONNX int8 (max_len=512, batch=1) |
1.0000 | 1.0000 | 1.0000 | 1.0000 | 0.0084 | 1.0000 | 0.00% (0/5) | 1.0000 | — |
ONNX int8 (max_len=512, batch=16) |
0.9888 | 1.0000 | 0.9778 | 1.0000 | 0.0115 | 1.0000 | 0.00% (0/5) | 0.9877 | — |
ONNX fp32 (max_len=512, batch=16) |
1.0000 | 1.0000 | 1.0000 | 1.0000 | 0.0053 | 1.0000 | 0.00% (0/5) | 1.0000 | — |
PyTorch fp32 (max_len=1024, CPU) |
1.0000 | 1.0000 | 1.0000 | 1.0000 | 0.0049 | 1.0000 | 0.00% (0/5) | 1.0000 | — |
datalab-to/ocr_error_detection (@0.5) |
0.8500 | 0.9714 | 0.7556 | 0.9923 | 0.1092 | 0.5714 | 20.00% (1/5) | 0.8767 | — |
datalab-to/ocr_error_detection (@0.000398) |
0.9474 | 0.9000 | 1.0000 | 0.9923 | 0.1092 | 0.6667 | 80.00% (4/5) | 0.9880 | — |
Char-TFIDF + LogReg (@0.364172 val-tuned) |
0.9677 | 0.9375 | 1.0000 | 0.9961 | 0.1023 | 0.7273 | 60.00% (3/5) | 1.0000 | — |
Deterministic Heuristics (@0.001935 val-tuned) |
0.1633 | 1.0000 | 0.0889 | 0.5444 | 0.4646 | 1.0000 | 0.00% (0/5) | 0.0000 | — |
2. Curated Development Benchmark (tssandor/pdf-text-quality-bench dev, n = 196)
File-level rights-audited development set (60 open PDFs extracted with pypdf/pymupdf from U.S. Federal Public Domain, historical public domain, EU CC-BY-4.0, CC-BY-SA, and open-source test fixtures: 32 clean, 28 broken; 136 historical OCR passages across EN/FR/DE/IT from PleIAs/Post-OCR-Correction). Because dev informed corruptor coverage during iteration, treat test above as the cleaner generalization check.
| Runtime & Context | Overall F1 | P | R | ROC-AUC | ECE | Open PDFs F1 (60p) | Open PDFs FPR | Hist OCR F1 (136p) | Non-Latin PDF F1 (11p) |
|---|---|---|---|---|---|---|---|---|---|
ONNX int8 (max_len=256, batch=1) |
0.9735 | 0.9892 | 0.9583 | 0.9988 | 0.0235 | 0.9825 | 3.12% (1/32) | 0.9697 | 0.9231 |
ONNX int8 (max_len=256, batch=16) |
0.9735 | 0.9892 | 0.9583 | 0.9990 | 0.0214 | 0.9825 | 3.12% (1/32) | 0.9697 | 0.9231 |
ONNX fp32 (max_len=256, batch=16) |
0.9738 | 0.9789 | 0.9688 | 0.9984 | 0.0222 | 0.9655 | 6.25% (2/32) | 0.9774 | 0.9231 |
ONNX int8 (max_len=512, batch=1) |
0.9735 | 0.9892 | 0.9583 | 0.9993 | 0.0173 | 0.9643 | 3.12% (1/32) | 0.9774 | 0.9231 |
ONNX int8 (max_len=512, batch=16) |
0.9843 | 0.9895 | 0.9792 | 0.9994 | 0.0176 | 0.9825 | 3.12% (1/32) | 0.9851 | 0.9231 |
ONNX fp32 (max_len=512, batch=16) |
0.9792 | 0.9792 | 0.9792 | 0.9990 | 0.0226 | 0.9655 | 6.25% (2/32) | 0.9851 | 0.9231 |
PyTorch fp32 (max_len=1024, CPU) |
0.9792 | 0.9792 | 0.9792 | 0.9989 | 0.0231 | 0.9655 | 6.25% (2/32) | 0.9851 | 0.9231 |
datalab-to/ocr_error_detection (@0.5) |
0.8121 | 0.9710 | 0.6979 | 0.9821 | 0.1439 | 0.4615 | 6.25% (2/32) | 0.9206 | 0.4444 |
datalab-to/ocr_error_detection (@0.000398) |
0.9126 | 0.8545 | 0.9792 | 0.9821 | 0.1439 | 0.7879 | 37.50% (12/32) | 0.9714 | 0.7059 |
Char-TFIDF + LogReg (@0.364172 val-tuned) |
0.9261 | 0.8785 | 0.9792 | 0.9855 | 0.0667 | 0.8060 | 37.50% (12/32) | 0.9853 | 0.7500 |
Deterministic Heuristics (@0.001935 val-tuned) |
0.4320 | 0.9310 | 0.2812 | 0.6328 | 0.3856 | 0.9286 | 6.25% (2/32) | 0.0290 | 1.0000 |
3. 26-Language Synthetic Stress Test (test_synth, n = 5,160)
Caveat: test_synth is document-disjoint from training but generated by our own corruption suite (in-distribution for MerahModels, out-of-distribution for datalab-to/ocr_error_detection). Covers 26 languages across 10 scripts, 323 unseen hard clean benign twins (including 120 real code snippets, short numeric tables, and BOM part-number lists), and 1,068 partial-page corruptions.
| Runtime & Context | Overall F1 | Macro-26 F1 | Min-Lang F1 | Non-Latin Macro F1 | Benign Twin FPR (323p) | Total Clean FPs | Partial-Page Recall |
|---|---|---|---|---|---|---|---|
ONNX int8 (max_len=256, batch=16) |
0.9835 | 0.9802 | 0.9487 | 0.9804 | 0.00% (0/323) | 3/2580 | 0.9335 |
ONNX int8 (max_len=512, batch=16) |
0.9947 | 0.9956 | 0.9787 | 0.9934 | 0.00% (0/323) | 4/2580 | 0.9869 |
PyTorch bf16 (max_len=1024, CUDA) |
0.9969 | 0.9977 | 0.9818 | 0.9978 | 0.00% (0/323) | 5/2580 | 0.9972 |
datalab-to/ocr_error_detection (@0.5) |
0.4468 | 0.3235 | 0.0000 | 0.2124 | 0.62% (2/323) | 6/2580 | 0.2659 |
datalab-to/ocr_error_detection (@0.000398) |
0.7934 | 0.7791 | 0.2917 | 0.7238 | 90.40% (292/323) | 501/2580 | 0.7388 |
Char-TFIDF + LogReg (@0.364172 val-tuned) |
0.9393 | 0.9432 | 0.8941 | 0.9310 | 13.93% (45/323) | 112/2580 | 0.9036 |
Deterministic Heuristics (@0.001935 val-tuned) |
0.6801 | 0.7021 | 0.4444 | 0.6687 | 52.32% (169/323) | 364/2580 | 0.5805 |
4. Speed, Quantization Parity & Edge-Case Probes
- Architecture: ModernBERT 22L × 384H (~140M params, 8,192 native context, 256k Gemma-2 byte-fallback tokenizer)
- Training: Knowledge-distilled (
α=0.5, T=2.0, verified across 18,063 training micro-batches) from an internaljhu-clsp/mmBERT-baseteacher on 96,334 multilingual pages from open-licensed corpora (see Training Data below). - Artifact sizes:
onnx/model_quantized.onnx= 135.7 MiB (142.3 MB) (per_channeldynamic int8, classifier head kept fp32) |onnx/model.onnx= 537.1 MiB (563.2 MB) |model.safetensors= 536.5 MiB (562.6 MB) |tokenizer.json= 32.8 MiB (34.4 MB) (shared Gemma-2 256k byte-fallback vocabulary; include this in edge/browser download budgets). - Calibrated temperature:
T = 1.5559(stored incalibration.json; default operating threshold =0.50). - Cross-version
transformers4.x / 5.x parity: Both top-levelglobal_rope_theta: 160000.0/local_rope_theta: 160000.0and nestedrope_parametersare exported inconfig.json. Verified ontransformers==4.57.6vsonnx/model.onnxfp32 at@256: 0 decision flips across alldevandtestrows (max|Δp| = 0.000004dev /0.000002test). - fp32 vs int8 ONNX agreement (
batch=16):@256: 98.98% ondev(194/196, mean|Δp|=0.01543) and 98.90% ontest(90/91).@512: 98.47% ondev(193/196) and 98.90% ontest(90/91).
- Dynamic-int8 batch-size & runtime note: Dynamic activation quantization scales activations per batch tensor, so
batch=1vsbatch=16flips 0/196 borderline pages ondev(0/91ontest) at@256and 2/196 (1/91ontest) at@512. Different ONNX Runtime int8 builds (e.g., Python CPU vs@huggingface/transformersNode/WASM) can also shift borderline probabilities without flipping threshold-0.5 decisions; useonnx/model.onnx(fp32) when strict cross-runtime or batch-size invariance is required. - CPU Latency (Apple M3 Pro,
onnxruntime 1.32.0,CPUExecutionProvider):max_length=256: full ≥256-token pages (n=80): 32.8 ms mean (p50 32.1 ms, p95 39.8 ms) | mixed-length first 100devpages (30 shorter than 256 tok): 26.6 ms mean | batch-16: 30.0 pages/s (29.7 pages/s full-length).max_length=512: full ≥512-token pages (n=56): 81.1 ms mean (p50 78.8 ms, p95 95.1 ms) | mixed-length first 100devpages (68 shorter than 512 tok): 50.5 ms mean | batch-16: 11.7 pages/s (11.6 pages/s full-length).
Edge-case & short-table sanity probes (`int8@256`, `batch=1`: 13/13 passed)
| Probe | Expected | Predicted | p_garbled |
|---|---|---|---|
clean_en |
CLEAN |
CLEAN |
0.0145 |
clean_code |
CLEAN |
CLEAN |
0.0021 |
clean_vert_ja |
CLEAN |
CLEAN |
0.0000 |
clean_arabic |
CLEAN |
CLEAN |
0.0000 |
clean_numeric_table_4line |
CLEAN |
CLEAN |
0.0035 |
clean_part_number_list |
CLEAN |
CLEAN |
0.0113 |
bad_cmap_shift |
GARBLED |
GARBLED |
0.9999 |
bad_glyph_names |
GARBLED |
GARBLED |
0.9999 |
bad_fffd_wipeout |
GARBLED |
GARBLED |
0.9999 |
bad_hist_ocr |
GARBLED |
GARBLED |
1.0000 |
bad_overprint |
GARBLED |
GARBLED |
0.9999 |
bad_collapsed |
GARBLED |
GARBLED |
0.9998 |
bad_exploded |
GARBLED |
GARBLED |
0.9999 |
Choosing max_length & Threshold
max_length=256(default, 75% head + 25% tail): Best CPU throughput; catches whole-page CMap, encoding, spacing, and OCR corruptions.max_length=512: Raises partial-page corruption recall (25–40% of a long page corrupted) from 0.9335 to 0.9869.- Operating threshold (
p_garbledafter dividing logits byT=1.5559):0.50default; lower to0.25–0.35to route borderline scans to OCR, or raise to0.75–0.85to minimize OCR cost.
Known Limitations
- Empty or scanned image-only pages: This model evaluates extracted text layers only. Deterministically route pages with
len(text.strip()) < 30(or high image area + sparse text) to OCR before scoring. - Very mild OCR typos (1–3% CER): Readable pages with a handful of single-letter typos are intentionally scored
CLEANso pipelines do not pay for redundant OCR. - Raw hexadecimal / binary dumps: Dense hex dumps without surrounding prose can look like shifted-CMap noise (e.g.,
smallscored a standalone hex dump at0.63during pre-release probing). - Short clean all-caps or repetitive font specimens: Very short (<120 char) non-English banners or repeated pangram font test sheets can occasionally score near the decision boundary.
- Mid-page-only corruption at
max_length=256: Head+tail truncation at 256 tokens can miss a narrow corrupted band strictly in the middle of a >3,000-char page; usemax_length=512or1024if localized mid-page corruption is critical.
Training Data, License & Citation
- Maintainer: MerahModels
- Model weights & code: MIT License (base encoder
jhu-clsp/mmBERT-smallis MIT). - Training data (open-licensed corpora only; zero
finepdfs/Common Crawl, zerodatalaboutputs; screened viaRESTRICTED_LICENSE_REto exclude non-commercialCC-BY-NCand proprietary All-Rights-Reserved notices):wikimedia/wikipedia(CC-BY-SA-3.0, 26 languages)common-pile/comma_v0.1_training_dataset(regulations,doab,arxiv_papers,caselaw_access_project,libretexts,pubmed— Public Domain / CC-BY / CC-BY-SA)PleIAs/common_corpus(native-digital open collections:USPTO,StackExchange,OpenAlex,Court Listener,Eurlex,Caselaw Access Project,UK Hansard,SEC,Chinese-Court-Decisions,French Open Data)codeparrot/github-code-clean(filtered by upstream GitHub repository licenseMIT/Apache-2.0/BSD-*/ISC; provenance audit notes: (1) a normalized file-header audit found 18 of 2,160 code snippets —0.019%of the 96,334 training rows — carry vendored GPL/LGPL/FSF file headers inside MIT-labeled repos, andbuild_data.pynow excludes file-level GPL/LGPL headers for future runs; (2) one Apache Software Foundation permissive header intrain_046389retains the standard"All rights reserved"phrase followed by permissive redistribution terms)- Synthetic benign twins & PDF text-layer corruptors (
MIT, MerahModels)
- Benchmark: Published separately with per-row
document_licenseandsource_repo_licenseattssandor/pdf-text-quality-bench.
@misc{merahmodels2026pdftextquality,
title = {MerahModels — PDF Text Quality Classifier (Small)},
author = {MerahModels},
year = {2026},
url = {https://huggingface.co/tssandor/pdf-text-quality-small}
}
- Downloads last month
- -
Model tree for tssandor/pdf-text-quality-small
Base model
jhu-clsp/mmBERT-smallDatasets used to train tssandor/pdf-text-quality-small
PleIAs/common_corpus
codeparrot/github-code-clean
Evaluation results
- F1 (int8@256, batch=1) on tssandor/pdf-text-quality-benchtest set self-reported0.989
- ROC-AUC (int8@256, batch=1) on tssandor/pdf-text-quality-benchtest set self-reported1.000
- F1 (int8@256, batch=1) on tssandor/pdf-text-quality-benchself-reported0.974
- ROC-AUC (int8@256, batch=1) on tssandor/pdf-text-quality-benchself-reported0.999