Downloads · 30 days
0
ejaz111/bart-synthetic-data-vampyre-ocr-correction
bart-synthetic-data-vampyre-ocr-correction is a machine learning model from ejaz111. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This model is a fine-tuned version of facebook/bart-base for correcting OCR errors in historical texts, specifically trained on "The Vampyre" dataset.
Downloads · 30 days
0
Access
Public
Updated Nov 7, 2025
Repo size
1.8 MB
Likes
0
Public
Click a slice to open those files.
.json2.9 MB · 56%
From the Hugging Face model README
This model is a fine-tuned version of facebook/bart-base for correcting OCR errors in historical texts, specifically trained on "The Vampyre" dataset.
Evaluated on real historical OCR text from "The Vampyre":
| Metric | Score |
|---|---|
| Character Error Rate (CER) | 14.49% |
| Word Error Rate (WER) | 37.99% |
| Exact Match | 0.0% |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("ejaz111/bart-synthetic-data-vampyre-ocr-correction")
model = AutoModelForSeq2SeqLM.from_pretrained("ejaz111/bart-synthetic-data-vampyre-ocr-correction")
# Correct OCR errors
ocr_text = "Th1s 1s an 0CR err0r w1th m1stakes in the anc1ent text."
input_ids = tokenizer(ocr_text, return_tensors="pt", max_length=512, truncation=True).input_ids
outputs = model.generate(input_ids, max_length=512)
corrected_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(f"Original: {ocr_text}")
print(f"Corrected: {corrected_text}")
from transformers import pipeline
corrector = pipeline("text2text-generation", model="ejaz111/bart-synthetic-data-vampyre-ocr-correction")
result = corrector("The breeze wh15pered so7tly through the anci3nt tre55")[0]['generated_text']
print(result)
# Output: "The breeze whispered softly through the ancient trees"
The synthetic training data included these OCR error types:
The model showed rapid improvement in early epochs:
The best checkpoint from epoch 2 was saved and is the one available in this repository.
This model is particularly effective for:
| Model | CER | WER | Parameters |
|---|---|---|---|
| BART-base | 14.49% | 37.99% | 139M |
| T5-base | 13.93% | 22.52% | 220M |
BART achieves slightly better character-level accuracy but struggles more with word-level corrections.
| Original OCR | Corrected Output |
|---|---|
| "Th1s 1s an 0CR err0r" | "This is an OCR error" |
| "The anci3nt tre55" | "The ancient trees" |
| "bl0omiNg floweRs" | "blooming flowers" |
If you use this model in your research, please cite:
@misc{bart-vampyre-ocr,
author = {Ejaz},
title = {BART Base OCR Error Correction for Historical Texts},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/ejaz111/bart-synthetic-data-vampyre-ocr-correction}}
}
Ejaz - Master's Student in AI and Robotics
Apache 2.0