Beyond Character Error Rate: Evaluating Diacritic Fidelity and Post-Processing Effects in Classical Arabic OCR

DOI 10.5281/zenodo.23683237

This dossier is hosted by Pandan Labs, which also publishes the evaluated model. Pandan Labs is not the author's academic or institutional affiliation. The preprint is archived on Zenodo (version 1.0); no arXiv identifier has been assigned.

Abstract

Abstract

Classical Arabic books print diacritics selectively, and the marks can change meaning. Faithful OCR of these books must copy the marks the page shows, adding none and dropping none. Arabic OCR is still commonly scored by character error rate (CER) computed after diacritics are removed. We fine-tune the vision-language OCR model dots.mocr with LoRA on synthetic and human-verified classical pages and evaluate it on 124 human-verified test pages, 38 human-verified unvowelled scans and further unverified scans.

We report three findings. First, letters-only CER misses most of what changes. On the test split, mean CER is unchanged (0.051 vs. 0.051), while the diacritic error rate (DER) falls from 0.204 to 0.177 and invented marks per 1,000 letters fall from 36.9 to 21.6. Second, gains are large on typeset print (DER 0.053 → 0.008) and on several scanned sets, but absent on the only human-verified low-resolution scan book. Third, replacing recognised Qur'anic quotations with canonical text, a common post-processing step, changes the conclusions: on the test split the DER improvement becomes non-significant, and on the low-resolution book a null result becomes a significant regression. We also disclose a release gate revised after a failed evaluation, bootstrap-seed sensitivity and run-to-run variance.

Key findings

Three findings, with their denominators.

Finding 1 · metrics

Letters-only CER masks the change in diacritic fidelity.

Base dots.mocr vs. fine-tuned v0.1 on the same human-verified test pages, raw output.

CER 0.051 vs. 0.051 · difference −0.000 [−0.026, +0.040] (124 pages) DER 0.204 → 0.177 · difference −0.027 [−0.041, −0.010] (122 paired pages)

Invented marks per 1,000 aligned letters: 36.9 → 21.6. Intervals: paired page bootstrap, 95%.

Finding 2 · conditions

Large DER gains on typeset pages; none on the verified low-resolution scan.

Raw output, human-verified test books.

Typeset (80 pages): DER 0.053 → 0.008 · difference −0.045 [−0.053, −0.037] Low-res scan (42 paired pages): 0.492 vs. 0.499 · +0.007 [−0.031, +0.050]

One typeset edition series and one low-resolution book. Not a claim about Arabic documents in general.

Finding 3 · post-processing

Canonical Qur'an quotation replacement changes the comparison.

Same outputs scored raw and after the quotation layer; the reference is unchanged.

Test split: −0.027 [−0.041, −0.010] raw → +0.016 [−0.002, +0.036] post-processed Low-res scan: +0.007 [−0.031, +0.050] raw → +0.090 [+0.045, +0.138] post-processed

DER difference, v0.1 minus base. A significant gain becomes non-significant, and a null result becomes a significant regression.

Results

Primary results.

Base dots.mocr against the fine-tuned v0.1 (training run lora-001). CER and DER are page means. CER is scored on every page; DER is defined only on pages where at least one aligned letter carries a mark in either output, so its paired page count can be smaller. Differences are v0.1 minus base, with paired page-bootstrap 95% intervals. Bold intervals exclude zero.

Raw transcription (Qur'an layer off) unless stated. Pages scored for CER and paired pages for DER are listed separately.
Evaluation set Print CER pages CER base → v0.1 DER pages (paired) DER base DER v0.1 DER difference, raw DER difference, post-processed
Human-verified test split
Kashf ash-ShubuhatTypeset800.019 → 0.005800.0530.008−0.045 [−0.053, −0.037]−0.023 [−0.028, −0.019]
Sharh Ma'na at-TaghutLow-res scan440.110 → 0.133420.4920.499+0.007 [−0.031, +0.050]+0.090 [+0.045, +0.138]
Test split, allMixed1240.051 → 0.0511220.2040.177−0.027 [−0.041, −0.010]+0.016 [−0.002, +0.036]
Additional human-verified scans
Unvowelled commentaries (verified subset)Scans380.139 → 0.251350.4550.297−0.158 [−0.222, −0.096]−0.101 [−0.175, −0.031]
Silver references (not checked by a person)
All 300 dpi pages (59)300 dpi scans590.078 → 0.054580.4530.324−0.129 [−0.172, −0.086]−0.105 [−0.149, −0.061]
Sharh al-Jami'Low-res scan480.140 → 0.246450.4930.367−0.126 [−0.193, −0.061]−0.054 [−0.129, +0.015]
Checkpoint-selection pages (not independent)
ValidationTypeset360.033 → 0.011360.0910.010−0.080 [−0.095, −0.066]−0.024 [−0.033, −0.017]

The CER rise on the unvowelled and al-Jami' scans comes from one page on which v0.1 repeats digits to the token limit (page CER 6.5). With one retry at repetition penalty 1.1, mean CER on the verified unvowelled set is 0.083. The "all 300 dpi pages" aggregate is a 10-page 300 dpi sample plus the 49 Inna Kunna pages, which overlap the unvowelled set. Full per-metric values, including invented and omitted marks, the retry variant and the second training run: evidence/primary-results.csv.

Dot plot of DER for base and v0.1 by evaluation set, with paired 95% intervals for the change and invented marks per 1,000 letters. Large improvements on typeset and synthetic pages; no change on the verified low-resolution scan.
Figure 3 (manuscript). Raw transcription by document condition. (a) DER level, (b) paired change with 95% intervals, (c) invented marks per 1,000 letters.
Paired DER change with the quotation layer off and on for each evaluation set, and DER levels for both models with the layer off and on.
Figure 4 (manuscript). The quotation layer lowers base DER far more than v0.1's, which narrows or reverses the measured difference. Data: evidence/postprocessing-results.csv.
Evaluation methodology

How the numbers are computed.

Each test page image goes to the model; the output is compared with a person's transcription of the printed source: every printed diacritic kept, none added. Two scoring conditions use the same reference. In the raw condition (primary), the model output is scored as it is. In the post-processed condition, a deterministic layer first replaces recognised Qur'anic quotations with canonical King Fahd Complex (QPC) Hafs text.

Letters-only CER
Levenshtein distance divided by reference length, over a text view with the diacritics, Qur'anic annotation marks and tatweel removed (Unicode NFC, no letter folding). It is unbounded above 1 when an output loops.
Conditional DER
The two texts are split into letters with their attached marks and aligned. Among aligned Arabic letters that carry a mark on at least one side, DER is the share whose marks differ. Letters the alignment does not match are excluded from both numerator and denominator, so DER measures marks conditional on correct letters.
Why DER can be undefined
If no aligned letter carries a mark on either side, as with an empty output or an unvowelled page read without vowels, the denominator is zero and DER is undefined. Such pages leave the DER mean and the paired DER comparison. That is why the DER page counts above can be smaller than the CER counts. On an unvowelled reference, page DER is 1.0 if any mark is invented, so pooled invented-mark rates are reported alongside.
Invented and omitted marks
An aligned letter that is bare in the reference but marked in the output is invented; one marked in the reference but bare in the output is omitted. Both are pooled per 1,000 aligned letters.
Alignment assumptions
An optimal Levenshtein alignment over base characters; mark order on a letter is ignored. Substituted, inserted or deleted letters carry no DER contribution, so text loss can lower DER's denominator without penalty. It is counted instead by CER and by omitted-word runs.
Quotation layer
Spans between ﴿…﴾ of at least eight letters are matched against the Qur'an after normalising letters. A window of one to four verses with a score of at least 90 replaces the span with the canonical wording. The layer rewrites only the model output.
Intervals
Paired bootstrap over pages: 4,000 resamples, seed 1, percentile 95% interval of the mean per-page difference, over pages where the metric is defined for both systems. No multiple-comparison correction. The intervals describe variation across the evaluated pages only; they do not estimate uncertainty about other books, editions, typefaces or publishers.

Why the marks matter

On one verified typeset test page, the base model drops a shadda that changes the meaning. Letters-only CER sees no difference between these two words; DER does.

Printedكَفَّرَهُمْ “declared them unbelievers” Base outputكَفَرَهُم “disbelieved in them”: shadda omitted
Diagram: page image to OCR model to raw transcription, scored either directly (faithful OCR) or after the Qur'an quotation layer (canonical text), against the same printed-source reference.
Figure 1 (manuscript). The two scoring paths share one reference; only the hypothesis changes.
Diagram of data sources, training sets and evaluation sets, with verified, silver and synthetic sets marked.
Figure 2 (manuscript). Data sources and splits. Books are separated by split; all verified partially and unvowelled pages come from one scanned test book.
Evidence ledger

Principal claims and what supports them.

Each claim names its dataset, page count, metric, result, manuscript section and public artifact. The aggregates are public; the page-level predictions and references behind them are not, so no claim here can be fully re-derived from public files alone.

C1 Letters-only CER does not register the change in diacritic fidelity on the test split.
Dataset
Gold test split (human-verified)
Pages scored
CER 124; DER 122 (paired)
Metric
letters-only CER; DER; invented marks per 1k
Result
CER 0.051 vs 0.051, diff −0.000 [−0.026, +0.040]; DER 0.204 → 0.177, diff −0.027 [−0.041, −0.010]; invented 36.9 → 21.6
Manuscript
Sections 5.1, 3
Artifact
evidence/primary-results.csv
Reproducibility
aggregate values public (evidence CSVs); page-level predictions and references private; not independently reproducible from public artefacts
Limitations
Page-bootstrap intervals cover the evaluated pages only; two books in the test split.
C2 Fine-tuning substantially reduces DER on the evaluated typeset pages.
Dataset
Kashf ash-Shubuhat, typeset (human-verified test)
Pages scored
80
Metric
DER; letters-only CER; invented marks per 1k
Result
DER 0.053 → 0.008, diff −0.045 [−0.053, −0.037]; CER 0.019 → 0.005; invented 30.3 → 3.0
Manuscript
Section 5.2; Table 3
Artifact
evidence/primary-results.csv
Reproducibility
aggregate values public (evidence CSVs); page-level predictions and references private; not independently reproducible from public artefacts
Limitations
One edition series; the same publisher's typesetting appears in training. Not a claim about Arabic documents in general.
C3 No DER improvement on the only human-verified low-resolution scanned book.
Dataset
Sharh Ma'na at-Taghut, low-resolution scan (human-verified test)
Pages scored
42 paired (44 scored)
Metric
DER
Result
DER 0.492 vs 0.499, diff +0.007 [−0.031, +0.050]
Manuscript
Section 5.2
Artifact
evidence/primary-results.csv
Reproducibility
aggregate values public (evidence CSVs); page-level predictions and references private; not independently reproducible from public artefacts
Limitations
Single book; holds all partially and unvowelled test pages; some references may disagree with the scan (direction of bias unknown).
C4 Fewer invented marks and lower DER on verified unvowelled commentary scans.
Dataset
Unvowelled scans, verified subset (38 pages, 2 books)
Pages scored
DER 35 (paired)
Metric
DER; invented marks per 1k
Result
DER 0.455 → 0.297, diff −0.158 [−0.222, −0.096]; invented 58.3 → 20.7
Manuscript
Section 5.2
Artifact
evidence/primary-results.csv
Reproducibility
aggregate values public (evidence CSVs); page-level predictions and references private; not independently reproducible from public artefacts
Limitations
21 of 38 pages were chosen for verification because the models disagreed on them; not a random sample.
C5 Canonical Qur'an quotation replacement changes the measured model comparison.
Dataset
Gold test split; Taghut (human-verified test)
Pages scored
122; 42 (paired)
Metric
DER, quote layer off vs on
Result
gold test: off −0.027 [−0.041, −0.010] vs on +0.016 [−0.002, +0.036]; Taghut: off +0.007 [−0.031, +0.050] vs on +0.090 [+0.045, +0.138]
Manuscript
Section 6; Table 4; Figure 4
Artifact
evidence/postprocessing-results.csv
Reproducibility
aggregate values public (evidence CSVs); page-level predictions and references private; not independently reproducible from public artefacts
Limitations
Mechanism partly hypothesised; layer-induced errors where the printed edition differs from QPC Hafs were not measured.
C6 The release gate was revised after v0.1 failed its first version.
Dataset
160 gold pages (test + validation)
Pages scored
160
Metric
gate verdict
Result
original gate FAIL (25 Oct 2026 18:39, UTC+3); tiered gate committed 22:30; same outputs PASS; weights published 23:13
Manuscript
Section 5.4; Appendix B
Artifact
evidence/release-gate-verdicts.csv
Reproducibility
chronology from private commit and log records; verdicts recomputable only with private page-level data
Limitations
Whether the rule was chosen after seeing the result is not recorded.
C7 The pass/fail distinction between v0.1 and lora-002 is within bootstrap-seed noise.
Dataset
Taghut, low-resolution rule of the tiered gate
Pages scored
42 / 41 (paired)
Metric
lower 95% bound of DER increase vs 0.05 tolerance
Result
v0.1 passes 200/200 seeds (bounds 0.0406-0.0463); lora-002 passes 125/200 (bounds 0.0472-0.0516)
Manuscript
Section 5.4; Appendix B
Artifact
evidence/experiment-manifest.json
Reproducibility
aggregate values public (evidence CSVs); page-level predictions and references private; not independently reproducible from public artefacts
Limitations
Seeds 1-200, 4,000 resamples each.
C8 Repeated inference of the same model changes outputs.
Dataset
Gold pages, base model run twice
Pages scored
113 typeset pages paired
Metric
DER difference between runs (quote layer on)
Result
typeset DER diff −0.0005 [−0.0009, −0.0001]; 28 of 157 answers differ between runs (manuscript Section 5.4)
Manuscript
Section 5.4; Appendix B
Artifact
evidence/experiment-manifest.json
Reproducibility
aggregate values public (evidence CSVs); page-level predictions and references private; not independently reproducible from public artefacts
Limitations
Cause not recorded (serving non-determinism or an unlogged setting).
C9 The second training run is a negative result and supports no causal claim about synthetic data.
Dataset
Gold test split
Pages scored
124
Metric
letters-only CER; broken pages
Result
test CER lora-002 0.160 vs v0.1 0.051
Manuscript
Section 5.3; Table 2
Artifact
evidence/primary-results.csv
Reproducibility
aggregate values public (evidence CSVs); page-level predictions and references private; not independently reproducible from public artefacts
Limitations
At least eight variables changed between the runs; one run each, seed not logged.

Downloadable evidence

All aggregate values were exported by script from the audit's recomputed results; no page text or page image is included.

Reproducibility and availability

What you can inspect, and what you cannot.

Status at publication of this dossier.
ArtifactStatusDetail
Fine-tuned model weights (v0.1)Publichuggingface.co/pandanlabs/dots-mocr-arabic-classical; evaluated revision 037b472 (identity with the evaluated checkpoint inferred, not hash-verified)
Base modelPublichuggingface.co/dots-studio/dots.mocr (third party; revision not pinned during the experiments)
Manuscript (published version)PublicZenodo, version 1.0, DOI 10.5281/zenodo.23683237, CC BY 4.0
Manuscript (web edition)Publicmanuscript.pdf: identical to the Zenodo version except that three scan excerpts in Figure 5 are omitted from this site
Aggregate evaluation dataPublicThe evidence CSV and JSON files above
Scoring and evaluation codePrivateHeld in a private repository; not released
Training code and configurationsPrivateConfiguration summarised in the manuscript (Table 2) and the manifest
Page-level predictions and audit recordsPrivatePreserved privately with SHA-256 manifests
Page images and reference transcriptionsNot releasableFrom editions whose rights have not been cleared, including modern commentaries by a living author
End-to-end reproductionNot possibleAlso missing: training seeds and command lines, a pinned base revision, and the raw synthetic renders (deleted; settings reconstructed by replay)
Limitations

Read the results with these in mind.

Research process and AI assistance

The role of generative AI.

Generative AI was used extensively. Anthropic's Claude, used through Claude Code, did the following under the author's direction:

  • Code. Wrote most of the data-generation, training, serving and evaluation code, and the scripts that produce this page's evidence files and figures.
  • Experiments. Launched and monitored the cloud training and evaluation runs.
  • Analysis and audit. Ran the reproducibility audit that recomputed every reported number from stored outputs, with several AI agents analysing datasets, metrics, results and failure cases.
  • Manuscript. Drafted the manuscript text, tables and figures, found the cited works and checked each reference against its publisher or archive record, and built this dossier.
  • Reference drafts. Proofread the unvowelled reference transcriptions against the page images and proposed corrections.

Separately, the draft transcriptions behind the reference sets were produced by an LLM-based OCR pipeline (Gemini), as described in the manuscript.

The author set the research questions and made the methodological decisions, including treating raw transcription as the primary condition. The author:

  • carried out the human verification of the reference transcriptions described in the manuscript;
  • reviewed the unvowelled reference pages and accepted or rejected each AI-proposed correction;
  • reviewed the manuscript.

The named author is responsible for every claim published in the manuscript and in this dossier.

Citation

How to cite.

Qudrath, M. F. (2026). Beyond Character Error Rate: Evaluating Diacritic Fidelity and Post-Processing Effects in Classical Arabic OCR (Version 1.0) [Preprint]. Zenodo. https://doi.org/10.5281/zenodo.23683237

@misc{qudrath2026beyond,
  author       = {Qudrath, Mohammed Fazalullah},
  title        = {Beyond Character Error Rate: Evaluating Diacritic Fidelity and Post-Processing Effects in Classical {A}rabic {OCR}},
  year         = {2026},
  publisher    = {Zenodo},
  version      = {1.0},
  doi          = {10.5281/zenodo.23683237},
  url          = {https://doi.org/10.5281/zenodo.23683237},
  note         = {Preprint. Research dossier: https://pandanlabs.com/research/arabic-ocr-diacritics/}
}

Download citation.bib. Cite the version DOI for this exact text; 10.5281/zenodo.23683236 always resolves to the latest version.