Downloads · 30 days
21
37% of all-time downloads
samaritan-ai/dots-ocr-samaritan-hebrew
dots-ocr-samaritan-hebrew is a image-text-to-text model from samaritan-ai. 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 transformers. The card lists the license as mit.
Fine-tuned dots.ocr for Samaritan manuscript OCR, emitting modern Hebrew transcriptions (RTL).
Downloads · 30 days
21
37% of all-time downloads
All-time downloads
57
Public
Parameters
3B
6.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors6.1 GB · 100%
From the Hugging Face model README
Fine-tuned dots.ocr for Samaritan manuscript OCR, emitting modern Hebrew transcriptions (RTL).
This repository contains a merged full checkpoint (base + LoRA) selected by a full validation sweep (ocr_cer on 494 OCR/grounding samples). Adapter step: 350.
| Item | Value |
|---|---|
| Base | rednote-hilab/dots.ocr (~3.04B) |
| Method | LoRA r=32, α=64, RSLoRA; vision + language targets; vision merger trained densely |
| Train recipe | max_pixels=3_500_000, max_seq_length=6144, bf16, grad accum 16 |
| Selected checkpoint | checkpoint-350 (merged) |
| Val OCR CER (micro) | 0.0463 |
| Val OCR exact match | 0.470 |
| Val OCR CER median / p90 | 0.0025 / 0.161 |
| Layout F1 (14 layout pages) | 0.857 |
| JSON valid rate (layout) | 1.0 |
Plain
cerin multi-task dumps is dominated by the small layout subset. Preferocr_cerfor this model.
Not a general multilingual OCR replacement for the base model. Outside Samaritan→Hebrew, prefer the upstream checkpoint.
import torch
from transformers import AutoModelForCausalLM, AutoProcessor
from qwen_vl_utils import process_vision_info
from PIL import Image
model_id = "samaritan-ai/dots-ocr-samaritan-hebrew" # update if you rename the repo
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
attn_implementation="sdpa", # or flash_attention_2
torch_dtype=torch.bfloat16,
device_map="auto",
)
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
# Match the fine-tune pixel budget (also set in preprocessor_config.json here)
ip = processor.image_processor
ip.min_pixels, ip.max_pixels = 3136, 3_500_000
ip.size = {**getattr(ip, "size", {}), "shortest_edge": 3136, "longest_edge": 3_500_000}
image = Image.open("page.jpg").convert("RGB")
prompt = "Extract the text content from this image."
messages = [{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": prompt},
],
}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text], images=image_inputs, videos=video_inputs,
padding=True, return_tensors="pt",
).to(model.device)
with torch.inference_mode():
out = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
print(processor.tokenizer.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
Extract the text content from this image.dotsocr-ft (local fine-tune stack for dots.ocr / PAGEXML)--grounding-per-page 2)data/val.packed.jsonl sweep over checkpoint-{150,200,250,300,350,400} ranked by ocr_cerComparative full-val OCR CER (494 samples):
| Adapter | ocr_cer | exact | median | p90 |
|---|---|---|---|---|
| checkpoint-300 | 0.0412 | 0.445 | 0.0038 | 0.760 |
| checkpoint-350 | 0.0463 | 0.470 | 0.0025 | 0.161 |
| checkpoint-250 | 0.0500 | 0.421 | 0.0098 | 0.176 |
| checkpoint-200 | 0.0653 | 0.362 | 0.0179 | 0.176 |
| checkpoint-400 | 0.0702 | 0.486 | 0.0013 | 0.096 |
| checkpoint-150 | 0.1675 | 0.221 | 0.0402 | 0.786 |
checkpoint-350 was chosen as the balanced production checkpoint (strong micro CER and healthy tail vs checkpoint-300’s high p90).
transformers==4.51.x (dots.ocr remote code target)huggingface-hub>=0.30,<1.0qwen-vl-utils, torch with bf16 GPU recommendedtrust_remote_code=True (ships modeling_*.py / configuration_dots.py)If you use this model, please cite the upstream dots.ocr work and note this Samaritan→Hebrew fine-tune (checkpoint-350).