Instructions to use SJF7/ocr-edit-gate-mistral-small-24b-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use SJF7/ocr-edit-gate-mistral-small-24b-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-Small-24B-Instruct-2501") model = PeftModel.from_pretrained(base_model, "SJF7/ocr-edit-gate-mistral-small-24b-lora") - Notebooks
- Google Colab
- Kaggle
LoRA-24B OCR rewriter - SJF7/ocr-edit-gate-mistral-small-24b-lora
LICENSE: CC BY-NC-SA 4.0 (NON-COMMERCIAL TRAINING DATA). These weights were fine-tuned on HIPE-OCRepair-2026 train data, several parts of which are licensed for non-commercial use only (CC BY-NC / CC BY-NC-SA 4.0, overproof: research use only). impresso-nzz was excluded from adapter training, but the other non-commercial sets were used. Whether trained weights are an adaptation of their training data is legally unsettled. The authors release these weights under CC BY-NC-SA 4.0 (non-commercial, share-alike) because of these training-data licenses.
What it is
A LoRA adapter (PEFT) that turns mistralai/Mistral-Small-24B-Instruct-2501 into a full-unit OCR rewriter for HIPE-OCRepair-2026: it reads one transcription unit of OCR text and
writes a corrected version (Phase 0 zero-shot prompt of the code repo, greedy decoding, thinking off). In the paper its output is not used directly:
the rewrite is split into edit blocks and only blocks accepted by the edit gate (SJF7/ocr-edit-gate-qwen3-0.6b-gate) are applied to the OCR.
This is the exact frozen adapter of the paper (epoch 2; sha256 in the code repo's frozen/ hash tables).
Recipe (ocrgate/lora_train.py): r = 16, alpha = 32, dropout 0.05, all attention + MLP projections, lr 1e-4, grad-accum 16, 2 epochs, seed 1234, bf16;
epoch chosen on the held-out part of train (never on dev/test).
Serving (vLLM 0.32.0): --enable-lora --max-lora-rank 16 --tokenizer-mode mistral, TP = 2 on 2x H200 in the paper.
Training data and licenses
Exactly the units of role fit in configs/p2_split.json from the HIPE-OCRepair-2026 train files below (data repo
hipe-eval/HIPE-OCRepair-2026-data, tag v0.9.5 = commit bd463f7; 1 unit skipped as too long, so 1,572 training examples).
No dev, test, held-out or synthetic data. Licenses were checked in the data repo at that commit: the participation guidelines
table (README-Participation-Guidelines.md) and the per-dataset cards (documentation/README-*.md).
| train subset (cell) | fit units used | license (guidelines table) | license (dataset card: benchmark version / original source) |
|---|---|---|---|
| icdar2017_v1.1_train_en | 319 | CC BY-NC-SA 4.0 | CC BY-NC-SA 4.0 / CC BY-NC-SA 4.0 |
| icdar2017_v1.1_train_fr | 274 | CC BY-NC-SA 4.0 | CC BY-NC-SA 4.0 / CC BY-NC-SA 4.0 |
| impresso-snippets_v1.0_train_en / fr / de | 35 / 35 / 35 | CC BY-NC-SA 4.0 | CC BY-NC-SA 4.0 |
| overproof-combined_v1.0_train_en | 101 | Research use only | CC BY-NC-SA 4.0 (structured format and annotations) / not stated, likely public domain |
| dta19-l0 / l1 / l2 _v0.1_train_de | 132 / 132 / 132 | CC BY-NC 4.0 | CC BY-SA 4.0 / CC BY 4.0 |
| dta19-l0 / l1 / l2 _v0.1_train-unmatched_de | 126 / 126 / 126 | CC BY-NC 4.0 | CC BY-SA 4.0 / CC BY 4.0 |
| impresso-nzz_v1.1_train_de | 0 (excluded) | CC BY-NC 4.0 | CC BY-NC 4.0 |
Non-commercial and share-alike subsets. icdar2017 and impresso-snippets are CC BY-NC-SA 4.0, overproof is "research use only", and dta19 is CC BY-NC 4.0 per the guidelines (CC BY-SA 4.0 per its card). Whether fine-tuned weights are an adaptation of their training data is legally unsettled. If they are, NC would restrict commercial use and SA would require the same license for the weights. This artifact is therefore released under CC BY-NC-SA 4.0.
No synthetic data. The paper's separate LoRA-72B-syn adapter was trained with synthetic pairs and is not released. Its data
can be regenerated with scripts/p3_fetch_clean.py, ocrgate/p3_noise.py and scripts/p3_lora_synth_train.sh in the code repo
(see the paper).
Results (official HIPE-OCRepair-2026 scorer; weighted cMER, lower is better / pref)
| system | dev | test | source |
|---|---|---|---|
| LoRA-24B, no gate | 0.0139 / 0.856 | 0.0107 / 0.7980 | FINAL_REPORT_P2.md, FINAL_REPORT_TEST_P3.md |
| LoRA-24B + full gate | 0.0112 / 0.930 | 0.0086 / 0.9169 | FINAL_REPORT_P2.md, FINAL_REPORT_TEST_P3.md |
| P3 primary ensemble (member) | 0.0084 / 0.971 | 0.0069 / 0.9282 | FINAL_REPORT_P3.md, FINAL_REPORT_TEST_P3.md |
Dev covers 7 of the 8 official cells; test is on the 8 official cells. The project scored the test split three times (all disclosed); nothing was tuned on test.
Intended use
Research on post-OCR correction of historical documents (HIPE-OCRepair-2026 benchmark). It is not meant for production or commercial use (see the license notice above), and not for languages or domains far from the training data (19th-20th c. newspapers and books in en/fr/de). Outputs can still introduce errors; the method only edits spans the gate accepts, and every other character is copied from the OCR input.
License
These weights are released under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license (CC BY-NC-SA 4.0, https://creativecommons.org/licenses/by-nc-sa/4.0/), because they were trained on HIPE-OCRepair-2026 training data distributed under non-commercial and share-alike terms.
Training data (HIPE-OCRepair-Bench v0.9, train split; https://github.com/hipe-eval/HIPE-OCRepair-2026-data): icdar2017 (CC BY-NC-SA 4.0), impresso-snippets (CC BY-NC-SA 4.0), overproof (CC BY-NC-SA 4.0 per its data card; listed as "research use only" in the HIPE guidelines), dta19 (listed as CC BY-NC 4.0 in the HIPE guidelines and CC BY-SA 4.0 in its data card; derived from GT4HistOCR / Deutsches Textarchiv). No development or test data was used for training.
Please use these weights for non-commercial research only, as the overproof terms ask. This is a request that reflects the data provider's terms, not an additional license condition.
Base model: mistralai/Mistral-Small-24B-Instruct-2501 (Apache-2.0). This repository contains a LoRA adapter for the base model; obtain and use the base model under its own license.
Citation
@misc{ocreditgate2026,
title = {Rewrite, Then Veto: Rewriter-Agnostic Edit Gating for LLM-Based Post-OCR Correction},
author = {Fonseca Cacho, Jorge Ram{\'o}n},
year = {2026}
}
Paper: Rewrite, Then Veto: Rewriter-Agnostic Edit Gating for LLM-Based Post-OCR Correction, by Jorge Ramón Fonseca Cacho, Department of Computer Science, University of Nevada, Las Vegas. arXiv: Code: https://github.com/SniperJF/ocr-edit-gate-release.
- Downloads last month
- 4
Model tree for SJF7/ocr-edit-gate-mistral-small-24b-lora
Base model
mistralai/Mistral-Small-24B-Base-2501