Spaces:
Sleeping
Sleeping
Sync README.md to 86e2b67
Browse files
README.md
CHANGED
|
@@ -1,22 +1,111 @@
|
|
| 1 |
-
-
|
| 2 |
-
title: OCR Bench Viewer
|
| 3 |
-
emoji: "π"
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: gray
|
| 6 |
-
sdk: docker
|
| 7 |
-
app_port: 7860
|
| 8 |
-
tags:
|
| 9 |
-
- ocr
|
| 10 |
-
- leaderboard
|
| 11 |
-
- vlm-judge
|
| 12 |
-
---
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ocr-bench
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
**There is currently no single best OCR model.** Rankings change depending on your documents. Manuscript cards, printed books, historical texts all produce different winners.
|
| 4 |
|
| 5 |
+
`ocr-bench` allows you to create **per-collection leaderboards** using a VLM-as-judge approach, so you can find what works best for _your_ documents rather than relying on generic benchmarks. You can validate the VLM's judgement with human votes, and share results via the Hugging Face Hub.
|
| 6 |
|
| 7 |
+
The underlying OCR model inference uv scripts are available at [uv-scripts/ocr](https://huggingface.co/datasets/uv-scripts/ocr). The majority of these use vLLM for efficient GPU inference, and are designed to run on a single consumer GPU (e.g. 24GB 3090/4090). The `ocr-bench` package orchestrates running these models at scale on the Hub, and judging outputs with a VLM. If you just want to run some OCR models on your data without the judging/leaderboard aspect, you can run the scripts directly.
|
| 8 |
|
| 9 |
+
## Why?
|
| 10 |
|
| 11 |
+
Generic OCR benchmarks tell you which model wins _on average_. But if you're digitising 18th-century encyclopaedias, that average doesn't help β the best model for your documents might be the worst on someone else's. Inspired by [Datalab's Benchmarks + Evals](https://www.datalab.to/blog/datalab-benchmarks-evals) approach β pairwise VLM-as-judge with Bradley-Terry scoring on your own documents β ocr-bench brings this idea to the Hugging Face Hub as an open-source, self-serve tool.
|
| 12 |
+
|
| 13 |
+
ocr-bench lets you run the same set of OCR models on a sample of _your_ collection, then uses a vision-language model to judge which produces the best transcription for each document. The result is a leaderboard specific to your data.
|
| 14 |
+
|
| 15 |
+
| Model | BPL card catalog | Britannica 1771 |
|
| 16 |
+
| ------------------ | :--------------: | :-------------: |
|
| 17 |
+
| GLM-OCR (0.9B) | #2 (1535) | **#1** (1787) |
|
| 18 |
+
| LightOnOCR-2 (1B) | **#1** (1559) | #2 (1780) |
|
| 19 |
+
| FireRed-OCR (2.1B) | β | #3 (1551) |
|
| 20 |
+
| DeepSeek-OCR (4B) | #4 (1452) | #4 (1437) |
|
| 21 |
+
| dots.ocr (1.7B) | #3 (1453) | #5 (945) |
|
| 22 |
+
|
| 23 |
+
Rankings can flip completely between collections.
|
| 24 |
+
|
| 25 |
+

|
| 26 |
+
|
| 27 |
+
**[Try the live viewer](https://huggingface.co/spaces/davanstrien/ocr-bench-britannica-results-qwen35-viewer)** β browse the Britannica 1771 leaderboard, compare OCR outputs side-by-side, and vote on quality yourself.
|
| 28 |
+
|
| 29 |
+
## Hub-native by design
|
| 30 |
+
|
| 31 |
+
The entire evaluation loop lives on the Hugging Face Hub:
|
| 32 |
+
|
| 33 |
+
1. **Your dataset** on the Hub (images + optional ground truth)
|
| 34 |
+
2. **OCR models** run via [HF Jobs](https://huggingface.co/docs/hub/jobs-overview) β outputs written as PRs on a Hub dataset
|
| 35 |
+
3. **VLM judge** via [HF Inference Providers](https://huggingface.co/docs/inference-providers/index) β only needs an HF token
|
| 36 |
+
4. **Results** published to a Hub dataset (leaderboard + pairwise comparisons)
|
| 37 |
+
5. **Viewer** as a [HF Space](https://huggingface.co/spaces) for browsing and human validation
|
| 38 |
+
|
| 39 |
+
No local GPU required. Everything is shareable via Hub URLs.
|
| 40 |
+
|
| 41 |
+
## Quickstart
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
uv pip install ocr-bench[viewer]
|
| 45 |
+
|
| 46 |
+
# 1. Run OCR models on your dataset
|
| 47 |
+
ocr-bench run <input-dataset> <output-repo> --max-samples 50
|
| 48 |
+
|
| 49 |
+
# 2. Judge outputs pairwise with a VLM
|
| 50 |
+
ocr-bench judge <output-repo>
|
| 51 |
+
|
| 52 |
+
# 3. Browse results + validate
|
| 53 |
+
ocr-bench view <output-repo>-results
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## How it works
|
| 57 |
+
|
| 58 |
+
**`ocr-bench run`** launches OCR models on your dataset via [HF Jobs](https://huggingface.co/docs/hub/jobs-overview). Each model writes its output as a PR on the same Hub dataset, keeping everything together without merge conflicts.
|
| 59 |
+
|
| 60 |
+
**`ocr-bench judge`** runs pairwise comparisons using a VLM judge (default: [Qwen3.5-35B-A3B](https://huggingface.co/Qwen/Qwen3.5-35B-A3B) via HF Inference Providers). For each document, the judge sees the original image and two OCR outputs (anonymised as A/B) and picks the better transcription. Results are fit to a [Bradley-Terry model](https://en.wikipedia.org/wiki/Bradley%E2%80%93Terry_model) to produce ELO ratings with bootstrap 95% confidence intervals. Adaptive stopping halts early when rankings are statistically resolved.
|
| 61 |
+
|
| 62 |
+
**`ocr-bench view`** serves a local web viewer with a leaderboard, comparison browser, and human validation. Vote on comparisons to cross-check the automated judge with human judgement.
|
| 63 |
+
|
| 64 |
+
## Available models
|
| 65 |
+
|
| 66 |
+
ocr-bench ships with 5 OCR models ready to run:
|
| 67 |
+
|
| 68 |
+
| Model | Size | Best for | Notes |
|
| 69 |
+
| --------------- | ---- | -------------------------- | ---------------------------- |
|
| 70 |
+
| `glm-ocr` | 0.9B | Historical printed text | Top performer on Britannica |
|
| 71 |
+
| `lighton-ocr-2` | 1B | Card catalogs, manuscripts | Top performer on BPL |
|
| 72 |
+
| `firered-ocr` | 2.1B | Clean printed text | Mid-pack on degraded docs |
|
| 73 |
+
| `deepseek-ocr` | 4B | Diverse documents | Most consistent across types |
|
| 74 |
+
| `dots-ocr` | 1.7B | General | Struggles on historical text |
|
| 75 |
+
|
| 76 |
+
All model scripts are available at [uv-scripts/ocr](https://huggingface.co/datasets/uv-scripts/ocr) on the Hub.
|
| 77 |
+
|
| 78 |
+
By default all 5 run. To pick specific models:
|
| 79 |
+
|
| 80 |
+
```bash
|
| 81 |
+
ocr-bench run <dataset> <output> --models glm-ocr lighton-ocr-2
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## Example results
|
| 85 |
+
|
| 86 |
+

|
| 87 |
+
|
| 88 |
+
Browse these on the Hub:
|
| 89 |
+
|
| 90 |
+
- [davanstrien/ocr-bench-britannica-results-qwen35](https://huggingface.co/datasets/davanstrien/ocr-bench-britannica-results-qwen35) β Encyclopaedia Britannica 1771, 5 models, 50 samples
|
| 91 |
+
- [davanstrien/bpl-ocr-bench-results](https://huggingface.co/datasets/davanstrien/bpl-ocr-bench-results) β Boston Public Library card catalog, 4 models, 150 samples
|
| 92 |
+
- [Live viewer](https://huggingface.co/spaces/davanstrien/ocr-bench-britannica-results-qwen35-viewer) β Britannica leaderboard with ELO chart and comparison browser
|
| 93 |
+
|
| 94 |
+
## Install
|
| 95 |
+
|
| 96 |
+
```bash
|
| 97 |
+
uv pip install ocr-bench # Core (run + judge)
|
| 98 |
+
uv pip install ocr-bench[viewer] # With web UI
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
Or with [uv](https://docs.astral.sh/uv/):
|
| 102 |
+
|
| 103 |
+
```bash
|
| 104 |
+
uv pip install ocr-bench[viewer]
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
Requires Python >= 3.11 and an [HF token](https://huggingface.co/settings/tokens).
|
| 108 |
+
|
| 109 |
+
## Status
|
| 110 |
+
|
| 111 |
+
Working proof of concept. The core pipeline (run β judge β view) is functional. Not polished production software β expect rough edges. This is an early-stage project to explore the idea of VLM-judged OCR leaderboards, and gather feedback on the concept and implementation!
|