syauqiezjut/MultimodalPegon

Python

0

5 commits

updated Apr 16, 2026

See the code

README

PegonKitab — Dataset and Code for Multimodal Post-OCR Correction of Pegon Manuscripts

Paper License Dataset

This repository contains the dataset, code, and evaluation scripts for the paper:

When Arabic OCR Fails: Benchmarking and Multimodal Post-OCR Correction for Pegon Manuscripts
Syauqie Muhammad Marier, Bayu Nadya Kusuma, Md Mehedi Hassan Dorjoy, Linan Zhu, Xiangjie Kong


Overview

Pegon is a modified Arabic script used in Javanese and Sundanese Islamic manuscripts. Several Pegon-specific characters differ from standard Arabic by only one or two dots, causing systematic OCR failures when using Arabic-trained models.

This work introduces:

  • PegonKitab — 2,801 annotated handwritten line images from 5 manuscripts
  • A 16-model OCR benchmark spanning traditional OCR, transformer HTR, vision-language models, and Arabic-specialized systems
  • CASTLE-Pegon — a multimodal post-OCR correction model (ByT5 + ViT) achieving 18.6% CER reduction over GPT-4o

Dataset

PegonKitab Statistics

KitabLanguageScript styleTrainValTestTotal
Kitab01Javanese—2083839285
Kitab02Javanese—4628484630
Kitab03Sundanese—1973636269
Kitab04Sundanese—650118118886
Kitab05Javanese—41976229724
Total1,9363525062,794

Download

ResourceLinkSize
Cropped line images (CroppedLines/)Google Drive~XX MB
Annotation splits (JSON)This repository (data/splits/)~XX MB

Data Format

Each JSON file in data/splits/ contains a list of records:

{
  "record_id": "Kitab01_001",
  "kitab_id": "Kitab01",
  "language": "javanese",
  "image_filename": "Kitab01-001.png",
  "ground_truth": "...",
  "ocr_gpt4o": "..."
}
FieldDescription
record_idUnique identifier
kitab_idSource manuscript (Kitab01–05)
languagejavanese or sundanese
image_filenameFilename in CroppedLines/
ground_truthHuman-annotated transcription
ocr_gpt4oGPT-4o zero-shot OCR output (used as correction input)

OCR Benchmark Results

Full results on PegonKitab test set (506 lines). CER and WER are macro-averaged. RC = recognition coverage (% of inputs producing non-empty output).

TierModelRC (%)CERWER
1Tesseract 565.20.70671.0348
1EasyOCR100.00.61941.1256
2TrOCR-small100.01.16491.4599
2TrOCR-base100.01.01961.2140
2TrOCR-large100.00.97121.0654
2Arabic-Nougat0.01.00001.0000
2GOT-OCR20.01.00001.0000
3GPT-4o100.00.42430.9986
3GPT-4o-mini100.00.66281.1001
3Qwen2.5-VL-3B100.00.52991.1211
3Qwen2.5-VL-7B100.00.52401.0585
3InternVL2.5-4B100.01.24311.7034
4QARI-OCR v0.298.61.03641.7120
4Arabic-HTR-v2100.027.56111.193
5ByT5 (random aug.)100.00.41340.9834
5ByT5 (glyph aug.)100.00.48160.9869

CASTLE-Pegon Model

Architecture

CASTLE-Pegon fuses visual and textual modalities for post-OCR correction:

  • Text branch: ByT5 encoder (byte-level, no tokenization needed for Arabic script)
  • Visual branch: ViT encoder (patch-level image features from line image)
  • Fusion: Learned gating — α·text_features + (1−α)·visual_features
  • Decoder: ByT5 decoder with auto-regressive correction

Results

ModelCERWERΔ vs GPT-4o
GPT-4o (best zero-shot)0.42430.9986—
ByT5 text-only0.41340.9834−2.6%
Multimodal v1 (ByT5-base + ViT)0.3635—−14.3%
Multimodal-Pegon v2 (ByT5-ft + ViT)0.3456—−18.6%

syauqiezjut/MultimodalPegon

Python

0

5 commits

updated Apr 16, 2026

See the code

README

PegonKitab — Dataset and Code for Multimodal Post-OCR Correction of Pegon Manuscripts

Paper License Dataset

This repository contains the dataset, code, and evaluation scripts for the paper:

When Arabic OCR Fails: Benchmarking and Multimodal Post-OCR Correction for Pegon Manuscripts
Syauqie Muhammad Marier, Bayu Nadya Kusuma, Md Mehedi Hassan Dorjoy, Linan Zhu, Xiangjie Kong


Overview

Pegon is a modified Arabic script used in Javanese and Sundanese Islamic manuscripts. Several Pegon-specific characters differ from standard Arabic by only one or two dots, causing systematic OCR failures when using Arabic-trained models.

This work introduces:

  • PegonKitab — 2,801 annotated handwritten line images from 5 manuscripts
  • A 16-model OCR benchmark spanning traditional OCR, transformer HTR, vision-language models, and Arabic-specialized systems
  • CASTLE-Pegon — a multimodal post-OCR correction model (ByT5 + ViT) achieving 18.6% CER reduction over GPT-4o

Dataset

PegonKitab Statistics

KitabLanguageScript styleTrainValTestTotal
Kitab01Javanese—2083839285
Kitab02Javanese—4628484630
Kitab03Sundanese—1973636269
Kitab04Sundanese—650118118886
Kitab05Javanese—41976229724
Total1,9363525062,794

Download

ResourceLinkSize
Cropped line images (CroppedLines/)Google Drive~XX MB
Annotation splits (JSON)This repository (data/splits/)~XX MB

Data Format

Each JSON file in data/splits/ contains a list of records:

{
  "record_id": "Kitab01_001",
  "kitab_id": "Kitab01",
  "language": "javanese",
  "image_filename": "Kitab01-001.png",
  "ground_truth": "...",
  "ocr_gpt4o": "..."
}
FieldDescription
record_idUnique identifier
kitab_idSource manuscript (Kitab01–05)
languagejavanese or sundanese
image_filenameFilename in CroppedLines/
ground_truthHuman-annotated transcription
ocr_gpt4oGPT-4o zero-shot OCR output (used as correction input)

OCR Benchmark Results

Full results on PegonKitab test set (506 lines). CER and WER are macro-averaged. RC = recognition coverage (% of inputs producing non-empty output).

TierModelRC (%)CERWER
1Tesseract 565.20.70671.0348
1EasyOCR100.00.61941.1256
2TrOCR-small100.01.16491.4599
2TrOCR-base100.01.01961.2140
2TrOCR-large100.00.97121.0654
2Arabic-Nougat0.01.00001.0000
2GOT-OCR20.01.00001.0000
3GPT-4o100.00.42430.9986
3GPT-4o-mini100.00.66281.1001
3Qwen2.5-VL-3B100.00.52991.1211
3Qwen2.5-VL-7B100.00.52401.0585
3InternVL2.5-4B100.01.24311.7034
4QARI-OCR v0.298.61.03641.7120
4Arabic-HTR-v2100.027.56111.193
5ByT5 (random aug.)100.00.41340.9834
5ByT5 (glyph aug.)100.00.48160.9869

CASTLE-Pegon Model

Architecture

CASTLE-Pegon fuses visual and textual modalities for post-OCR correction:

  • Text branch: ByT5 encoder (byte-level, no tokenization needed for Arabic script)
  • Visual branch: ViT encoder (patch-level image features from line image)
  • Fusion: Learned gating — α·text_features + (1−α)·visual_features
  • Decoder: ByT5 decoder with auto-regressive correction

Results

ModelCERWERΔ vs GPT-4o
GPT-4o (best zero-shot)0.42430.9986—
ByT5 text-only0.41340.9834−2.6%
Multimodal v1 (ByT5-base + ViT)0.3635—−14.3%
Multimodal-Pegon v2 (ByT5-ft + ViT)0.3456—−18.6%