You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+247-9Lines changed: 247 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,22 +5,255 @@
5
5
<h1>Karanta OCR</h1>
6
6
</div>
7
7
8
-
# Karanta OCR
8
+
# KarantaOCR: Efficient Document Processing for African Languages
9
9
Karanta means "read" in Hausa, a language spoken in Nigeria and other West African countries. This project is a OCR toolkit for processing scanned documents containing content in african languages and extracting the text in them at scale.
10
10
11
11
We would like to give huge credits to the [OlmoOCR](https://github.com/allenai/olmocr) project and team for providing the blueprint that we've adapted for Karanta.
12
12
13
-
## OCR Pipeline
13
+
## Table of Contents
14
14
15
-
### Document Type Classification
16
-
...
15
+
-[Model Description](#model-description)
16
+
-[Training Data](#training-data)
17
+
-[Stage 1: General OCR Training](#stage-1-general-ocr-training)
18
+
-[Stage 2: African Language Fine-Tuning](#stage-2-african-language-fine-tuning)
-[Load the Model and Processor](#load-the-model-and-processor)
26
+
-[Prepare a PDF Page for Inference](#prepare-a-pdf-page-for-inference)
27
+
-[Run OCR Inference](#run-ocr-inference)
28
+
-[End-to-End Example](#end-to-end-example)
29
+
-[Citation Information](#citation-information)
17
30
18
-
### Document Article Segmentation
19
-
...
31
+
---
20
32
21
-
### OCR
22
-
...
33
+
## Model Description
34
+
35
+
#### [Paper](....)
36
+
37
+
**KarantaOCR** is an open-source document OCR and processing model designed for **high-accuracy text extraction in African languages**.
38
+
The model focuses on preserving language-specific characters and diacritics that are often lost, normalized, or mis-transcribed by existing OCR systems.
39
+
40
+
KarantaOCR is fine-tuned from [Qwen/Qwen2.5-VL-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-3B-Instruct), a vision-language model that combines a strong vision encoder with a large language model.
41
+
Through targeted curriculum fine-tuning, KarantaOCR extends these capabilities to robust document understanding across diverse PDF formats and multilingual settings.
42
+
43
+
## Training Data
44
+
45
+
KarantaOCR was trained using a **two-stage curriculum fine-tuning strategy**.
46
+
47
+
### Stage 1: General OCR Training
48
+
49
+
***100,000 documents** sampled from [Allenai OCRMix](allenai/olmOCR-mix-0225)
50
+
* Purpose: learn general OCR skills across layouts, fonts, tables, and document structures
51
+
52
+
### Stage 2: African Language Fine-Tuning
53
+
54
+
***50,000 PDFs** containing text in **10 African languages**, crawled from the web
55
+
* Domains include:
56
+
57
+
* Religious texts
58
+
* Legal documents
59
+
* Dictionaries
60
+
* Novels
61
+
* Other long-form and structured documents
62
+
63
+
This stage emphasizes accurate transcription of **diacritics, special characters, and region-specific typography**.
***Table extraction** and structured document understanding
88
+
* Robust handling of:
89
+
90
+
* Multi-column layouts
91
+
* Headers and footers
92
+
* Mixed scanned and digital PDFs
93
+
94
+
While improved performance on African languages was our priority, KarantaOCR **maintains strong performance on English and other high-resource languages**, making it suitable for mixed-language document collections.
95
+
96
+
## Evaluation
97
+
98
+
KarantaOCR is evaluated on the OLMOocr benchmark using pass-rate accuracy. Scores are reported as averages across JSONL files with 95% confidence intervals.
99
+
In addition to OLMOocr benchmark, we also create a KarantaOCR-Bench, which focuses specifically on testing OCR extraction on special characters and diacritics.
out_ids[len(in_ids):] for in_ids, out_ids inzip(inputs.input_ids, generated_ids)
222
+
]
223
+
224
+
outputs = processor.batch_decode(
225
+
trimmed_ids,
226
+
skip_special_tokens=True,
227
+
clean_up_tokenization_spaces=False,
228
+
)
229
+
return outputs[0]
230
+
```
231
+
232
+
### End-to-End Example
233
+
234
+
```python
235
+
model = load_model("taresco/KarantaOCR")
236
+
processor = load_processor("taresco/KarantaOCR")
237
+
238
+
prompt ="""Below is the image of one page of a PDF document.
239
+
Just return the plain text representation of this document as if you were reading it naturally.
240
+
Turn equations into a LaTeX representation, and tables into markdown format. Remove the headers and footers, but keep references and footnotes.
241
+
Read any natural handwriting.
242
+
This is likely one page out of several in the document, so be sure to preserve any sentences that come from the previous page, or continue onto the next page, exactly as they are.
243
+
If there is no text at all that you think you should read, you can output null.
244
+
if the document contains diacritics, please include them in the output.
0 commit comments