Rewrite, Then Veto: How a Second Model Can Reduce LLM Over-Correction in OCR
By Gregory Hain
Based on: Rewrite, Then Veto: Rewriter-Agnostic Edit Gating for LLM-Based Post-OCR Correction — Jorge Ramón Fonseca Cacho
Consider a tiny snippet of noisy optical character recognition: he shew’d tbe Letter.
An instruction-tuned large language model might hand you back: he showed the letter.
This is a constructed example from the paper, not a recorded model response or an excerpt from the benchmark. But it captures the problem neatly.
At first glance, the model looks smart. It caught the obvious typo, swapping tbe for the. But in doing so, it made two unwanted changes. It modernized the historical spelling shew’d into showed, and it removed the capitalization from the noun Letter.
If your goal is faithful historical transcription, those changes matter. The benchmark used in this study, however, ignores case and punctuation during scoring; its results do not measure every aspect of that fidelity.
This behavior is called over-correction: changing text that was already correct. The HIPE-OCRepair competition organizers identify it as a recurring challenge, especially on low-noise inputs. For libraries and archives working with transcripts produced by OCR engines years or decades ago, re-digitizing the underlying collections is rarely feasible.
You want a system that fixes optical glitches without modernizing wording, paraphrasing historical text, or fabricating lost words.
A recent paper by Jorge Ramón Fonseca Cacho at the University of Nevada, Las Vegas—Rewrite, Then Veto: Rewriter-Agnostic Edit Gating for LLM-Based Post-OCR Correction—examines this failure mode. The paper shows how one targeted-correction approach failed and introduces a post-processing safeguard called EditVeto.
Here is how the method works, where the numbers landed on an international benchmark, and what the findings suggest for document engineering teams.

The Mostly Clean Reality: Why Historical OCR Invites Over-Correction
Noisy OCR does not necessarily mean a wall of unreadable static. In the benchmark studied here, most characters are already correct.
The ICDAR 2026 HIPE-OCRepair benchmark spans German, English, and French documents from the seventeenth through twentieth centuries. Its baseline error rates are revealing. On the deliberately degraded test track dta19-l2—nineteenth-century German Fraktur books whose page images were degraded before OCR—the normalized micro character match error rate is 0.0546, or 5.46%. On the lowest-noise track, dta19-l0, it is 0.0040, or 0.40%.
These are normalized alignment error rates, not raw percentages of incorrectly transcribed source characters. But they illustrate the central imbalance: there is far more correct text to preserve than erroneous text to repair.
LLMs do not reliably respect that boundary by default. A correction can restore a damaged word while also modernizing a neighboring spelling, changing punctuation, or completing text that should remain truncated.
The HIPE competition organizers evaluated models using two metrics:
- cMER (Character Match Error Rate): The ratio of substitutions, deletions, and insertions to hits plus substitutions, deletions, and insertions, computed on normalized text. Counts are summed across units within each test cell before taking the ratio. Lower is better.
- Preference Score (Pref): A metric bounded between -1.0 and +1.0. For each transcription unit, the scorer assigns +1 if correction reduced cMER, 0 if it stayed flat, and -1 if it made the unit worse, then averages those contributions.
Overall results use a weighted mean of the per-cell scores: each of the three dta19 noise levels receives weight 1/3, and every other cell receives weight 1.
A model can reduce aggregate character error while making many individual units worse. Preference exposes that trade-off: it counts whether each unit improved, rather than how many characters the improvement involved.
Controlling that collateral damage is the central challenge addressed by this study.
The Obvious Fix That Failed: The Span-Generation Trap
One natural response to over-correction is surgical isolation: do not let the model touch the whole document. Instead, locate the errors first, extract the broken spans, and ask the model to rewrite only those spans.
Before building EditVeto, Fonseca Cacho tested this hypothesis using an oracle experiment on the benchmark development split.
To give the surgical approach an unfair advantage, the author built an oracle span detector that read the ground-truth reference text. It aligned OCR with the reference, expanded mismatching operations to whitespace-delimited token boundaries, merged spans separated only by whitespace, and dropped spans whose reference replacement would not change the normalized text. The author then gave Qwen3-8B those spans, approximately 300 characters of surrounding context on each side, and instructions to generate a replacement for each one.
The result was a substantial regression.
Approach cMER (Dev) Preference Score
No correction (OCR Baseline) 0.0275 0.0000
Full-Context Zero-Shot Rewrite 0.0247 +0.4161
Oracle Per-Span Generation 0.0562 -0.6247
Even with reference-derived error locations, the per-span generator more than doubled weighted cMER, from 0.0275 to 0.0562, and turned the preference score deeply negative. It performed worse than no correction in every development cell.
Why did an 8-billion-parameter model fail when told where to edit?
Looking into the 13,167 oracle spans illustrates the failure:
- 5,229 proposals were rejected for being too long or missing the required tags.
- 4,677 proposals simply echoed the OCR span.
- Of the 3,261 proposals that changed the span, only 331 matched the reference replacement.
- 970 returned the OCR span followed by text copied from the right-hand context.
A different window interface rewrote the span with up to 40 characters of context on each side, then retained only edits inside the span. It removed that context leakage and performed much better than per-span generation, but still scored worse (0.0255 cMER / +0.2627 Pref) than the full-context rewrite (0.0247 cMER / +0.4161 Pref).
The takeaway is narrower than a universal rule against span correction: for this model and prompt, knowing where errors were did not make per-span generation effective. The experiment does not establish that context length alone caused the failure.
The more promising use of those error locations came after generation. Applying the oracle span gate to the full rewrite lowered cMER from 0.0247 to 0.0229 and raised preference from 0.4161 to 0.6501. That oracle reads the reference and cannot be deployed, but it motivated a learned veto gate.
The Mechanism: Align, Segment, and Veto
The full-context rewrite offered useful corrections alongside unwanted edits. Rather than asking the rewriter to generate replacements span by span, the author let it propose a complete transcription and filtered the changes afterward.
The resulting EditVeto pipeline has three stages:
- Full Rewrite: An upstream rewriter processes the entire transcription unit and generates a full proposed text.
- Optimal Character Alignment: The system aligns the OCR string against the rewrite using a minimum-cost Levenshtein edit script. Contiguous substitutions, insertions, or deletions uninterrupted by matching characters are grouped into edit blocks.
- Learned Veto Gating: A compact classifier scores each proposed block, keeping blocks it predicts to be helpful and restoring rejected blocks to the original OCR text.
[OCR Input] ──────> (LLM Rewriter) ──────> [Full Proposed Rewrite]
│ │
└────────────── Levenshtein Editops ───────────┘
│
[Discrete Character Edit Blocks]
│
(0.6B-Parameter Gate)
Keep (p >= τ) or Veto?
┌──────────┴──────────┐
Keep Veto
│ │
Apply Rewrite Revert to OCR
└──────────┬──────────┘
│
[Final Gated Output]
The Alignment Layer
Let the raw input be string $x$ and the full rewrite be string $z$. The pipeline computes a Levenshtein alignment between $x$ and $z$ at unit operation costs.
Contiguous non-matching operations merge into paired segments:
$$x = u_0 B_1 u_1 \dots B_n u_n$$
$$z = u_0 B_1' u_1 \dots B_n' u_n$$
Here, the $u$ segments represent unchanged text where the OCR and rewrite match. Each $B_i \to B_i'$ pair represents a proposed edit block.
A block can contain substitutions, insertions, deletions, or a combination of them. Either side of a block may be empty. When several minimum-cost alignments exist, the aligner's choice determines the block boundaries.
The 0.6B Gate Architecture
The gate is built on a Qwen3-0.6B backbone. Both the backbone and classification head are trained; the selected gate is then frozen for evaluation.
For every edit block, its text input contains:
- The dataset and language tag.
- A local OCR context window of $\pm 60$ characters surrounding the marked block.
- The proposed replacement string.
The combined text input is truncated to 256 tokens. The backbone encodes it using last-token pooling, and the resulting vector is concatenated with 15 standardized numerical features.
Those features split into two groups:
- 8 Text-Derived Features: Block lengths and their difference, log unit length, log block count, fraction changed, and insertion and deletion flags.
- 7 Log-Probability-Related Features: Six statistics from the rewriter's token log-probabilities—mean, minimum, sum, count, first-token log-probability, and unit mean—plus a failed-token-mapping flag.
The combined vector passes through an MLP head with one hidden layer of 256 units, GELU activation, and 10% dropout. It produces a score $p_i \in [0,1]$, interpreted as an estimated probability that the block is helpful, without post-hoc calibration.
If $p_i \ge \tau$, the block is accepted. If $p_i < \tau$, it is vetoed.
When a block is vetoed, the pipeline discards $B_i'$ and slots the original OCR string $B_i$ back into place.
The Damage Bound
With blocks taken from a minimum-cost alignment, the system has a mathematical property: the output $\hat{y}$ lies on a shortest edit path between the raw OCR text $x$ and the rewrite $z$.
The accepted and vetoed blocks partition the total Levenshtein distance:
$$d(x, \hat{y}) + d(\hat{y}, z) = d(x, z)$$
This equality concerns raw strings. It need not hold after the scorer's normalization, which can join hyphenated words across line breaks.
Writing $\nu$ for that normalization, the scored character error count is bounded by:
$$E(\hat{y}) \le \min\left( E(x) + d(\nu(\hat{y}), \nu(x)), ; E(z) + d(\nu(\hat{y}), \nu(z)) \right)$$
The bound follows from the triangle inequality. It concerns error counts, not a guarantee that cMER improves.
If the gate rejects every proposed edit, the output reverts entirely to the OCR text, and that unit's preference contribution is exactly zero. Every output character comes from either the OCR input or the rewrite. The gate generates no new replacement text, but it can retain harmful edits or reject helpful ones; this construction does not guarantee factual or transcription accuracy.
The Text-Only Variant: Gating Without Decoder Access
The full gate requires the rewriter's token log-probabilities. Those may be unavailable when processing a third-party system's saved output.
To remove that dependency, the author trained a text-only gate.
This variant uses the same Qwen3-0.6B architecture but zeros out the seven log-probability-related features during both training and inference. It retains the language and dataset tags, OCR context, proposed replacement, and eight text-derived numerical features.
The frozen gates were fitted on 130,165 helpful or harmful blocks extracted from Qwen3-8B and Qwen3-32B rewrites of the benchmark training split. Neutral blocks were excluded. Another 30,077 labeled blocks were held out for selection, with units sharing a reference grouped together.
The epoch and global threshold were chosen to maximize the summed labeled gain of accepted held-out blocks:
- Full Gate Threshold: $\tau = 0.5065$
- Text-Only Gate Threshold: $\tau = 0.4990$
Once selected, these gates were frozen. No development score entered gate or threshold selection, and there was no per-language, per-cell, or per-rewriter setting. The rewriter list and decision to freeze did follow the development experiments.
“Rewriter-agnostic” therefore has a specific meaning here: the text-only gate needs no internal information from the rewriter, and it was tested without retraining on outputs outside its training pair. It does not mean every rewriter benefits.
Test Results: What the Frozen Gate Accomplished
The author evaluated the frozen gates across 590 scored transcription units from the eight official HIPE-OCRepair test cells. Units can be paragraphs, articles, pages, or chunks; they are not necessarily whole documents.
The baseline OCR input across these sets had a weighted cMER of 0.0226.
Performance Across Five Different Rewriters
The author tested four zero-shot rewriters and a LoRA-adapted Qwen3-8B. The gate had never seen training outputs from Mistral-Small-24B or Qwen2.5-72B. Only Mistral was from a different model family.
Rewriter Ungated cMER Gated cMER (Full) Ungated Pref Gated Pref
Qwen3-8B 0.0184 0.0153 0.4946 0.7124
Qwen3-32B 0.0146 0.0119 0.6433 0.8228
Qwen3-8B + LoRA 0.0140 0.0114 0.7061 0.8541
Mistral-Small-24B 0.0158 0.0116 0.6002 0.8461
Qwen2.5-72B 0.0149 0.0106 0.6074 0.8446
Across all five rewriters, the full gate reduced weighted cMER by a reported 0.0026–0.0044. Preference scores rose from approximately 0.49–0.71 to 0.71–0.85. Both gates improved both metrics for every rewriter: all 20 paired-bootstrap comparisons reached $p \approx 0.0002$, the minimum attainable value under the study's 10,000-resample procedure. Bootstrap differences can differ slightly from subtraction of the rounded table values.
The text-only gate matched the full gate closely on cMER:
- Qwen3-8B text-only: 0.0153 cMER (Pref: 0.6950).
- Mistral-Small-24B text-only: 0.0116 cMER (Pref: 0.8289).
- Qwen2.5-72B text-only: 0.0106 cMER (Pref: 0.8281).
It equaled the full gate to four decimals for four rewriters and differed by 0.0001 for Qwen3-32B. Its preference scores were slightly lower for the zero-shot rewriters.
For these systems, decoder log-probabilities added little to aggregate cMER performance. That is evidence for a useful output-only interface, not proof that the gate captures all the information needed to judge an edit.
Gating the Competition Entries
Fonseca Cacho also applied the frozen text-only gate to published competition submissions.
The results split the field:
- BLOCR—prompted DeepSeek for English and Gemma 3 for French and German—improved from 0.0106 to 0.0096 cMER; preference rose from 0.7028 to 0.8596.
- L3i Run 1, using instruction-tuned Qwen3-14B, improved from 0.0176 to 0.0157 cMER. Run 2 also improved, over the three cells it covered.
- Zakaria-ENSIAS, using prompted Qwen3-8B with a length-ratio safeguard, improved from 0.0209 to 0.0121 cMER; preference rose from 0.4176 to 0.7631. It covered seven cells.
- BnF-Mistral, the winning team, went the other way on its two lowest-cMER runs. Run 1 rose from 0.0050 to 0.0065, and Run 3 rose from 0.0071 to 0.0077. Run 2 remained at 0.0090 to four decimals, with no significant cMER change.
Preference increased for every published run. The winning run therefore illustrates an important tension: the gate can improve the balance of units helped versus harmed while worsening aggregate character accuracy.

Why the Gate Hurt the Winning Model
The regression on BnF-Mistral Run 1 is one of the most instructive findings in the paper.
BnF-Mistral used Mistral Small 3 (24B), continued pre-training on roughly 80 billion tokens of pre-1900 BnF documents, LoRA fine-tuning on competition and synthetic data, a judge-and-retry loop, and routing of difficult documents to a larger model.
Its low cMER establishes strong benchmark performance. It does not establish that the system rarely hallucinates or that almost every individual edit is correct.
The paper's explanation is that the gate's global threshold was selected on less accurate rewriters. When a stronger system makes a higher proportion of useful edits, vetoes can remove more good work. On BnF-Mistral Run 1, gating raised cMER in seven of eight cells.
That interpretation does not require assuming the gate specifically mistrusted obscure historical words. The demonstrated failure is simpler: reverting selected edits degraded the winning output.
The lesson for pipeline designers is practical: a fixed veto gate can help some rewriters and hurt others. Low error on its training rewriters does not establish that its threshold will transfer safely to a stronger system.
Going Further: LoRA Tuning, Agreement Pools, and Ensembles
After the first test evaluation, the author explored whether gating could close the gap to BnF-Mistral when paired with stronger rewriters.
The author trained LoRA adapters on Mistral-Small-24B, Qwen3-32B, and Qwen2.5-72B, including a second 72B adapter trained with additional synthetic pairs. A retrained gate learned from a broader set of rewriter outputs, and Ensemble B pooled edits from the four LoRA rewriters.
Identical blocks were merged. Candidate blocks had to pass thresholds based on how many rewriters proposed them:
- A block proposed by 1 rewriter required $p \ge 0.779$.
- A block proposed by 2 rewriters required $p \ge 0.310$.
- A block proposed by 3 or 4 rewriters required $p \ge 0.012$.
Overlapping candidates were then resolved by the higher gate score. Because the ensemble combines edits from different rewrites, the single-rewrite shortest-path property no longer applies.
System Configuration Test cMER Test Preference
OCR Input Baseline 0.0226 0.0000
Competition Winner (BnF-Mistral Run 1) 0.0050 0.9000
Competition Runner-Up (BnF-Mistral Run 3) 0.0071 0.8737
------------------------------------------------------------------------
Zero-Shot Qwen2.5-72B + Frozen Gate 0.0106 0.8446
LoRA-adapted Qwen2.5-72B (Ungated) 0.0096 0.8409
LoRA-adapted Qwen2.5-72B + Retrained Gate 0.0085 0.8944
Four-Rewriter LoRA Ensemble B 0.0069 0.9282
Secondary Ensemble C (with Qwen3.8-27B) 0.0066 0.9296
The unsubmitted Ensemble B achieved cMER of 0.0069 and preference of 0.9282. It was statistically tied with the competition's second-ranked run (0.0071, $p=0.49$), behind the winner, and ahead of the remaining published runs on cMER. Its preference score was numerically above every published run, although the difference from the winner was not statistically significant ($p=0.08$).
The paper is careful about attribution: most of the step from 0.0106 to 0.0069 came from fine-tuning and pooling.
Fine-tuning lowered ungated Qwen2.5-72B cMER from 0.0148 to 0.0096 in the second evaluation. Pooling improved on gated LoRA-72B by another 0.0016. With individual fine-tuned rewriters held fixed, gating reduced cMER by 0.0011–0.0021. The gate's separate contribution inside the ensemble was not isolated.
A third, secondary evaluation applied the unchanged retrained gate to Qwen3.8-27B. It improved the zero-shot model from 0.0114 to 0.0108 cMER. For its LoRA-tuned version, the change from 0.0072 to 0.0071 was not significant; only preference improved significantly. Ensemble C reached 0.0066 but remained behind the winner, and B remained the primary system.
These later results require extra caution. Configurations were selected and frozen before each evaluation, but the direction of later work followed earlier test results. The paper explicitly acknowledges adaptive-overfitting risk from repeated test looks.
Why it matters: Practical Takeaways for Document Pipelines
For engineers building document-processing systems, this research offers useful architectural lessons within a specific text-only historical OCR setting.
1. Separate Correction Generation from Edit Validation
The study's rewriters were already prompted to preserve historical spelling, wording, punctuation, and line breaks. They still produced edits worth vetoing.
A separate block-level decision stage offers a way to retain useful corrections while reverting others to a known source string. The frozen evaluation shows that this separation can improve both aggregate cMER and preference across several rewriters.
2. Test Span Correction Rather Than Assuming It Is Safer
Knowing where an error occurs does not ensure an LLM can generate a good local replacement. Qwen3-8B's oracle per-span experiment failed despite substantial surrounding context, and the window alternative still trailed the full rewrite.
For a similar pipeline, full-context rewriting followed by edit filtering is worth comparing against targeted generation. The paper does not establish that all models, prompts, or span interfaces will behave the same way.
3. Account for the Whole Compute and Release Budget
The winning competition system combined large-scale historical pre-training with other adaptation and inference methods. This study did not isolate which component produced its advantage.
EditVeto's project used 33.83 GPU-hours after the oracle analysis, plus 1.08 GPU-hours for that analysis—approximately 35 GPU-hours in total—on two NVIDIA H200 GPUs. That is a reported experimental budget, not a deployment-cost or latency measurement.
The release also has practical limits. Code is Apache-2.0, but the released gates and adapters are under CC BY-NC-SA 4.0 for non-commercial research use, with base-model terms still applying. The synthetic-data 72B adapter used in Ensemble B and its synthetic training pairs are withheld; the paper reports a regeneration recipe.
4. Validate the Gate Against Each Rewriter
A threshold that helps one rewriter can discard useful corrections from another. Evaluate both cMER and preference: the BnF-Mistral results show that they can move in opposite directions.
The author proposes per-system or calibrated thresholds as future work. Dynamic calibration was not demonstrated as a solution, and alternative threshold schemes tested during development did not outperform one global threshold on the held-out data.
The Honest Limits of Edit Vetoing
EditVeto has clear boundaries:
- Bound to Rewriter Recall: A veto gate can only accept or reject proposed edits. If the rewriter leaves an error untouched, the gate cannot fix it.
- Uneven Results Across Test Cells: On
icdar2017-fr, the frozen gate raised cMER for four of five rewriters. This was the only official cell without development data, but French was present elsewhere in the benchmark; it was not an unseen language. Some regressions also occurred onimpresso-en. The paper does not establish that missing development data caused the French-cell failures. - Text-Only Evaluation: Neither the rewriter nor the gate receives page images. The study does not evaluate image-informed correction or establish performance across particular visual damage or layout conditions.
- Normalized Accuracy Is Not Full Transcription Fidelity: The scorer lowercases text, maps selected historical characters, handles certain line-break hyphenation markers, and replaces non-word characters with spaces. It therefore ignores case and punctuation distinctions that can matter to faithful transcription.
- Limited Generalization Evidence: Results cover one benchmark, three languages, and one rewriter run and gate seed per configuration and test look. Later evaluations reused the test set, and the retrained gate and log-probability-dependent ensembles do not establish the same rewriter-agnostic claim as the first frozen evaluation.
The Takeaway
Letting large language models rewrite historical text can resemble handing an over-eager copy editor a red pen: they may catch real typos while also changing wording that should remain intact.
EditVeto offers a tested way to filter that work. Let the model read the full transcription unit, propose its rewrite, calculate the character-level differences, and let a compact 0.6B gate decide which blocks survive.
On this benchmark, that workflow improved several rewriters and three competition teams, but it worsened the winning system's cMER. For document engineering teams, it is a promising architecture to evaluate against their own rewriters and data—not a guarantee of reliable correction.