Downloads · 30 days
6
24% of all-time downloads
enclavelabs/enclave-scribe-devanagari-iter4
enclave-scribe-devanagari-iter4 is a image-text-to-text model from enclavelabs. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as mit.
A LoRA adapter for allenai/olmOCR-2-7B-1025 that adds page-level Devanagari OCR capability. Iter-4 is fine-tuned on top of iter-3 with real Indic document page images plus word-level replay, and fixes iter-3's known d…
Downloads · 30 days
6
24% of all-time downloads
All-time downloads
25
Public
Repo size
381 MB
Likes
0
Public
Click a slice to open those files.
.safetensors381 MB · 100%
From the Hugging Face model README
A LoRA adapter for allenai/olmOCR-2-7B-1025 that adds page-level Devanagari OCR capability. Iter-4 is fine-tuned on top of iter-3 with real Indic document page images plus word-level replay, and fixes iter-3's known dead-loop failure mode on long dense Hindi/Marathi pages.
Built by Enclave Labs. MIT-licensed. Part of the EnclaveScribe project — a self-hostable, Indic-first document OCR system.
Given an image containing Devanagari text (Hindi, Marathi, Sanskrit, Nepali, Pali), returns the Unicode transcription. Unlike iter-3 which was trained on word crops only, iter-4 also handles full document pages without falling into generation loops.
For full-page PDFs, use it via the EnclaveScribe agent pipeline which handles page rasterization and generation-config.
Tested against a 6-page Gazette of India Extraordinary notification (dense Hindi + English) with the runtime bad_words_ids workaround disabled:
| Signal | iter-3 | iter-4 |
|---|---|---|
| Total chars extracted | 7,122 | 13,646 |
| Pages dead-looped | 2/6 | 0/6 |
| Max page chars (of 4,096 ceiling) | 2,430 | 4,077 |
| Wallclock (6 pages, g5.xlarge) | 20 min | 12 min |
Iter-3 pages 4 and 5 exhausted the full generation budget emitting <tool_call> blocks and produced empty output after the post-hoc regex strip. Iter-4 completes every page inside the budget with real document text.
Iter-4 is also more faithful to source script conventions — for example, it preserves Arabic numerals inside English sections (where iter-3 hallucinates Devanagari digits like २११३ instead of 2113).
See the full head-to-head in reports/iter4/GAZETTE_TEST.md.
import torch
from transformers import AutoProcessor, AutoModelForImageTextToText
from peft import PeftModel
from PIL import Image
BASE = "allenai/olmOCR-2-7B-1025"
ADAPTER = "enclavelabs/enclave-scribe-devanagari-iter4"
processor = AutoProcessor.from_pretrained(BASE)
model = AutoModelForImageTextToText.from_pretrained(
BASE, dtype=torch.bfloat16, device_map="auto"
)
model = PeftModel.from_pretrained(model, ADAPTER)
model.eval()
image = Image.open("hindi_page.png").convert("RGB")
messages = [{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "Extract this document page as clean markdown. "
"Preserve the original script exactly."},
],
}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=4096,
do_sample=False,
repetition_penalty=1.1, # belt-and-suspenders; iter-4 no longer strictly needs it
)
print(processor.batch_decode(
out[:, inputs.input_ids.shape[1]:], skip_special_tokens=True
)[0].strip())
Note: iter-4 no longer dead-loops on the pages that broke iter-3, but we recommend keeping repetition_penalty=1.1 in production. It costs nothing and stays as insurance.
allenai/olmOCR-2-7B-1025enclavelabs/enclave-scribe-devanagari), loaded via resume_adapter so training continues rather than starting freshallenai/olmOCR-2-32B-1025) with the same corpus for more LoRA capacitytests/fixtures/pdfs/gazette_moef_2024_06_07.pdf before shippingFollow github.com/Enclave-Labs-Inc/enclave-scribe for updates.
@software{enclavescribe_devanagari_iter4_2026,
title = {EnclaveScribe: Self-hostable Indic OCR — Devanagari adapter (iter-4)},
author = {Enclave Labs},
year = {2026},
url = {https://huggingface.co/enclavelabs/enclave-scribe-devanagari-iter4},
}
MIT — same as the base model and the EnclaveScribe repo.