Instructions to use altslate/indic-ocr-0.9b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use altslate/indic-ocr-0.9b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="altslate/indic-ocr-0.9b", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("altslate/indic-ocr-0.9b", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("altslate/indic-ocr-0.9b", trust_remote_code=True, device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use altslate/indic-ocr-0.9b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "altslate/indic-ocr-0.9b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "altslate/indic-ocr-0.9b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/altslate/indic-ocr-0.9b
- SGLang
How to use altslate/indic-ocr-0.9b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "altslate/indic-ocr-0.9b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "altslate/indic-ocr-0.9b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "altslate/indic-ocr-0.9b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "altslate/indic-ocr-0.9b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use altslate/indic-ocr-0.9b with Docker Model Runner:
docker model run hf.co/altslate/indic-ocr-0.9b
indic-ocr-0.9b
An OCR model for printed text in Indian languages: give it an image of a text block (a paragraph, a few lines, a heading) and it returns the text. 0.9B parameters, fine-tuned from PaddleOCR-VL-1.6, and licensed Apache-2.0 with no use or revenue restrictions.
On the Sarvam Indic OCR Bench (23 languages, 22 Indian + English):
- it is ahead of Patram 1.5 (7B), a model about eight times its size, on both the representative split (57.5 vs 46.0 word accuracy) and the full 6,908-block test (59.2 vs 47.0), and on 18 of 23 languages in each;
- it reads Manipuri in Meetei Mayek (59.7 word accuracy) and Santhali in Ol Chiki (28.5) on this bench, where both Patram 1.5 and Surya OCR 2.5 score 0โ17;
- it is behind Surya OCR 2.5 (689M; weights under a modified OpenRAIL-M licence with a revenue cap) overall: 59.2 vs 67.1 on the full test. The gap is mostly Odia, Malayalam, Kannada, Urdu, Punjabi and Gujarati (see the tables). Use Surya if those scripts matter most to you and its licence fits.
It reads one block at a time. It does not do layout analysis: crop the page into blocks first (any layout model, or a simple line/paragraph splitter), then send each block.
Usage
vLLM (recommended)
Tested with vllm/vllm-openai:v0.32.0:
vllm serve altslate/indic-ocr-0.9b --served-model-name ocr --trust-remote-code --max-model-len 8192 \
--limit-mm-per-prompt '{"image": 1}'
import base64, requests
img = base64.b64encode(open("block.png", "rb").read()).decode()
r = requests.post("http://localhost:8000/v1/chat/completions", json={
"model": "ocr", "temperature": 0, "max_tokens": 2048,
"messages": [{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img}"}},
{"type": "text", "text": "OCR:"}]}]})
print(r.json()["choices"][0]["message"]["content"])
transformers (โฅ 5.0)
Tested with transformers 5.23.0 and torch 2.14:
import torch
from PIL import Image
from transformers import AutoProcessor, AutoModelForImageTextToText
model = AutoModelForImageTextToText.from_pretrained("altslate/indic-ocr-0.9b", dtype=torch.bfloat16).to("cuda").eval()
processor = AutoProcessor.from_pretrained("altslate/indic-ocr-0.9b")
image = Image.open("block.png").convert("RGB")
messages = [{"role": "user", "content": [{"type": "image", "image": image}, {"type": "text", "text": "OCR:"}]}]
inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_dict=True,
return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=1024, do_sample=False, repetition_penalty=1.05)
print(processor.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
The prompt is always OCR:. The model was trained only on that task; the other PaddleOCR-VL prompts (tables, formulas, charts)
were not trained further and may have degraded.
Results
Sarvam Indic OCR Bench, scored with the benchmark's own metrics.py --normalize. Word accuracy = 100 ร (1 โ WER), averaged
over blocks. All models were run by us, in the same harness, greedy decoding:
- this model: vLLM v0.32.0, prompt
OCR:; - Patram 1.5 7B: vLLM v0.30.0 with BharatGen's own vLLM patch and chat template, a plain "transcribe exactly" prompt;
- Surya OCR 2.5: vLLM v0.30.0, Surya's own block prompt, image resizing and sampling settings from the
surya-ocrpackage (0.24.0), its HTML output converted to plain text. (On vLLM v0.32.0 Surya returned empty output for 59% of blocks, so we used v0.30.0; its valid-block word accuracy there, 70.0, matches the number Sarvam publishes for it.)
The benchmark's word_accuracy leaves out blocks with an empty prediction. This model and Patram had none on either split; Surya had 6
(representative split) and 46 (full test), so its numbers are very slightly flattered.
Overall
| Split | Model | Params | Licence | Word acc | Valid-block word acc | Valid-block CER | Loops |
|---|---|---|---|---|---|---|---|
| representative (1,173 blocks) | indic-ocr-0.9b | 0.9B | Apache-2.0 | 57.5 | 60.5 | 0.194 | 63 |
| representative | Patram 1.5 | 7B | Apache-2.0 | 46.0 | 50.2 | 0.279 | 102 |
| representative | Surya OCR 2.5 | 0.7B | OpenRAIL-M (modified) | 63.9 | 66.9 | 55 | |
| full test (6,908 blocks) | indic-ocr-0.9b | 0.9B | Apache-2.0 | 59.2 | 62.7 | 0.179 | 406 |
| full test | Patram 1.5 | 7B | Apache-2.0 | 47.0 | 50.7 | 0.271 | 534 |
| full test | Surya OCR 2.5 | 0.7B | OpenRAIL-M (modified) | 67.1 | 70.0 | 291 |
"Loops" = blocks the benchmark flags as repetition loops or catastrophic output; "valid-block" columns leave those out.
Per language, representative split (word accuracy)
| Language | indic-ocr-0.9b | Patram 1.5 7B | Surya OCR 2.5 |
|---|---|---|---|
| Assamese | 66.6 | 40.4 | 76.5 |
| Bengali | 72.4 | 56.8 | 76.2 |
| Bodo | 63.2 | 44.4 | 52.5 |
| Dogri | 58.6 | 44.5 | 57.0 |
| English | 96.8 | 97.5 | 95.3 |
| Gujarati | 48.2 | 50.3 | 60.5 |
| Hindi | 80.2 | 77.9 | 85.2 |
| Kannada | 44.2 | 36.5 | 74.7 |
| Kashmiri | 20.9 | 7.8 | 28.3 |
| Konkani | 81.1 | 71.6 | 77.6 |
| Maithili | 77.6 | 59.1 | 77.7 |
| Malayalam | 29.4 | 48.3 | 73.4 |
| Manipuri (Meetei Mayek) | 59.7 | 0.0 | 0.0 |
| Marathi | 79.4 | 75.4 | 85.1 |
| Nepali | 76.8 | 77.3 | 77.4 |
| Odia | 14.4 | 18.1 | 60.9 |
| Punjabi | 60.3 | 51.7 | 84.7 |
| Sanskrit | 46.8 | 37.6 | 46.9 |
| Santhali (Ol Chiki) | 28.5 | 17.2 | 5.1 |
| Sindhi | 73.2 | 64.0 | 77.9 |
| Tamil | 76.8 | 53.0 | 79.0 |
| Telugu | 60.7 | 41.1 | 69.3 |
| Urdu | 50.8 | 28.8 | 77.3 |
Per language, full test (word accuracy)
| Language | indic-ocr-0.9b | Patram 1.5 7B | Surya OCR 2.5 |
|---|---|---|---|
| Assamese | 76.6 | 45.1 | 83.7 |
| Bengali | 73.9 | 54.4 | 78.4 |
| Bodo | 70.6 | 48.2 | 57.7 |
| Dogri | 64.1 | 47.8 | 64.8 |
| English | 97.2 | 97.3 | 94.6 |
| Gujarati | 41.8 | 43.9 | 60.8 |
| Hindi | 78.7 | 77.5 | 83.0 |
| Kannada | 43.5 | 39.4 | 73.4 |
| Kashmiri | 20.3 | 6.8 | 26.3 |
| Konkani | 88.2 | 75.6 | 78.5 |
| Maithili | 80.1 | 62.4 | 71.1 |
| Malayalam | 28.3 | 48.6 | 73.7 |
| Manipuri (Meetei Mayek) | 60.0 | 0.0 | 0.0 |
| Marathi | 80.3 | 76.4 | 83.9 |
| Nepali | 81.4 | 83.0 | 78.2 |
| Odia | 15.9 | 16.9 | 65.3 |
| Punjabi | 57.5 | 47.9 | 79.2 |
| Sanskrit | 47.0 | 32.7 | 57.0 |
| Santhali (Ol Chiki) | 34.2 | 14.3 | 9.8 |
| Sindhi | 79.5 | 65.4 | 83.3 |
| Tamil | 77.6 | 57.7 | 77.1 |
| Telugu | 60.7 | 39.9 | 66.0 |
| Urdu | 55.0 | 27.9 | 82.2 |
Limitations
- Weak on Odia, Malayalam and Kannada (16โ44 word accuracy on the full test), and well behind Surya on Urdu, Punjabi and Gujarati. The training data for these scripts is synthetic text in a limited set of fonts; old letterpress pages (common in the benchmark) are read poorly. A version trained on real proofread print is in progress.
- Script confusion: on some Telugu pages it writes Kannada script (about 70 of 300 full-test Telugu blocks), and on some Santhali pages it confuses Ol Chiki with Meetei Mayek. Check the output script if this matters.
- Repetition loops on about 6% of full-test blocks (406 of 6,908), mostly long or very dense blocks. Use
repetition_penaltyaround 1.05 and amax_tokenslimit; split very long blocks. - Printed text only. Not trained on handwriting, tables, formulas or scene text.
- Blocks, not pages. Full pages exceed what it was trained on; crop first.
- Kashmiri (20 word accuracy) is not usable yet.
Training
Four rounds of full fine-tuning from PaddleOCR-VL-1.6 (8k + 6k + 3k + 2k steps, batch 8, lr 1e-5, cosine schedule, loss on the answer only), about 150k block images seen. Checkpoints were chosen only on our own synthetic dev set (held-out fonts and sentences); the Sarvam benchmark was used for evaluation only, never for training or checkpoint selection.
Data: all synthetic, rendered with Pillow + raqm (HarfBuzz shaping) with scan-like degradations (noise, blur, rotation, low-resolution rescans, an "old print" profile with faded ink, bleed-through and speckle):
- text: Dakshina native-script Wikipedia sentences (train split; CC BY-SA 4.0), the Indic side of allenai/nllb (ODC-BY 1.0), Wikipedia 20231101 dumps for Assamese, Odia, Nepali, Maithili, Sanskrit, Konkani, Santhali, Manipuri and Kashmiri (CC BY-SA 4.0), English sentences from allenai/nllb;
- fonts: open fonts from Google Fonts (OFL) and Indic print fonts from the Ubuntu archive (Lohit, SMC, Samyak, Gubbi, Kalapi, Uniol and others; OFL or GPL with the font exception). Fonts were used to render training images and are not redistributed;
- mixed-script blocks: English words and lines inside Indic text, each word drawn in a font of its own script, and bilingual blocks that alternate lines of two languages (Santhali and Manipuri with Bengali, the others with English);
- test-leak guard: every sentence that appears in the benchmark's ground truth for its language was removed before rendering.
No closed or proprietary models were used to make the data.
Licence
Apache-2.0, the same as the base model. The training text came from CC BY-SA 4.0 and ODC-BY 1.0 sources; no text is distributed with the model.
Citation
If you use it, please cite this repository and the base model, PaddleOCR-VL (PaddlePaddle). Benchmark: Sarvam AI, Indic OCR Bench.
- Downloads last month
- -