Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ocr-bench ships with 16 registered OCR models. Five form the default set:
| `deepseek-ocr` | 4B | Diverse documents | Most consistent across types |
| `dots-ocr` | 1.7B | General | Struggles on historical text |

The opt-in registry also includes compact models at different quality/cost points, including `falcon-ocr` (0.3B) and `ovis-ocr2` (0.9B). List every available model with:
The opt-in registry also includes compact models at different quality/cost points, including `falcon-ocr` (0.3B, v1 weights), `falcon-ocr-1.5` (0.3B, the v1.5 weights TII pushed to the same repo on 2026-09-11; both slugs pin a commit) and `ovis-ocr2` (0.9B). List every available model with:

```bash
ocr-bench run --list-models
Expand Down
26 changes: 25 additions & 1 deletion src/ocr_bench/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,36 @@ class ModelConfig:
_VLLM_OPENAI_ENV = {"PYTHONPATH": "/usr/local/lib/python3.12/dist-packages"}


# tiiuae/Falcon-OCR ships v1 and v1.5 in the SAME repo: TII overwrote `main`
# with the v1.5 weights on 2026-09-11 (no tag, no branch). uv-scripts split the
# recipe by version identity (falcon-ocr.py pins v1, falcon-ocr-1.5.py pins the
# v1.5 release head) and both scripts default to their pin; the explicit
# `--revision` here is belt-and-braces so the bench never depends on a script
# default. The script resolves the commit and records it in inference_info.
_FALCON_OCR_SCRIPT = "https://huggingface.co/datasets/uv-scripts/ocr/raw/main/falcon-ocr.py"
_FALCON_OCR_15_SCRIPT = "https://huggingface.co/datasets/uv-scripts/ocr/raw/main/falcon-ocr-1.5.py"
FALCON_OCR_V1_REVISION = "42ec56b72a23984ac059e7c8a6d397a8529423fe" # last v1, 2026-07-03
FALCON_OCR_V15_REVISION = "fe757d59ecd79d4d68760162306a70a015761ad9" # v1.5 head, 2026-09-11


MODEL_REGISTRY: dict[str, ModelConfig] = {
"falcon-ocr": ModelConfig(
script="https://huggingface.co/datasets/uv-scripts/ocr/raw/main/falcon-ocr.py",
script=_FALCON_OCR_SCRIPT,
model_id="tiiuae/Falcon-OCR",
size="0.3B",
default_flavor="l4x1",
# v1 weights. Without the pin this slug silently became v1.5 on 2026-09-11.
default_args=["--revision", FALCON_OCR_V1_REVISION],
),
"falcon-ocr-1.5": ModelConfig(
script=_FALCON_OCR_15_SCRIPT,
model_id="tiiuae/Falcon-OCR",
size="0.3B",
default_flavor="l4x1",
# v1.5 weights (same repo, same 0.3B arch). Shares model_id with
# `falcon-ocr`; the loader labels colliding configs by slug so both rows
# stay distinct on the leaderboard.
default_args=["--revision", FALCON_OCR_V15_REVISION],
),
"glm-ocr": ModelConfig(
script="https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py",
Expand Down
18 changes: 16 additions & 2 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_image_mode_fields_default_none(self):

class TestModelRegistry:
def test_has_core_models(self):
assert len(MODEL_REGISTRY) == 16
assert len(MODEL_REGISTRY) == 17

def test_default_models_exist_in_registry(self):
for slug in DEFAULT_MODELS:
Expand All @@ -70,6 +70,7 @@ def test_deepseek_has_prompt_mode_free(self):
def test_compact_models_use_standard_l4_launch(self):
expected = {
"falcon-ocr": ("tiiuae/Falcon-OCR", "0.3B", "falcon-ocr.py"),
"falcon-ocr-1.5": ("tiiuae/Falcon-OCR", "0.3B", "falcon-ocr-1.5.py"),
"ovis-ocr2": ("ATH-MaaS/OvisOCR2", "0.9B", "ovis-ocr2.py"),
}
for slug, (model_id, size, script_name) in expected.items():
Expand All @@ -78,13 +79,26 @@ def test_compact_models_use_standard_l4_launch(self):
assert cfg.size == size
assert cfg.script.endswith(f"/{script_name}")
assert cfg.default_flavor == "l4x1"
assert cfg.default_args == []
assert cfg.image is None
assert cfg.python is None
assert cfg.env is None
assert MODEL_REGISTRY["ovis-ocr2"].default_args == []

def test_falcon_ocr_versions_pin_distinct_commits(self):
# Same Hub repo holds v1 and v1.5 (main was overwritten 2026-09-11), so
# each slug must pin its own full commit sha or runs stop reproducing.
pins = {}
for slug in ("falcon-ocr", "falcon-ocr-1.5"):
args = MODEL_REGISTRY[slug].default_args
assert args[0] == "--revision", slug
sha = args[1]
assert len(sha) == 40 and all(c in "0123456789abcdef" for c in sha), slug
pins[slug] = sha
assert pins["falcon-ocr"] != pins["falcon-ocr-1.5"]

def test_compact_models_are_opt_in(self):
assert "falcon-ocr" not in DEFAULT_MODELS
assert "falcon-ocr-1.5" not in DEFAULT_MODELS
assert "ovis-ocr2" not in DEFAULT_MODELS

def test_image_mode_models_configured(self):
Expand Down
Loading