Instructions to use moganai/MoganOCR-TR-1.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moganai/MoganOCR-TR-1.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="moganai/MoganOCR-TR-1.5") 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("moganai/MoganOCR-TR-1.5") model = AutoModelForMultimodalLM.from_pretrained("moganai/MoganOCR-TR-1.5", 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 moganai/MoganOCR-TR-1.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moganai/MoganOCR-TR-1.5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moganai/MoganOCR-TR-1.5", "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/moganai/MoganOCR-TR-1.5
- SGLang
How to use moganai/MoganOCR-TR-1.5 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 "moganai/MoganOCR-TR-1.5" \ --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": "moganai/MoganOCR-TR-1.5", "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 "moganai/MoganOCR-TR-1.5" \ --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": "moganai/MoganOCR-TR-1.5", "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 moganai/MoganOCR-TR-1.5 with Docker Model Runner:
docker model run hf.co/moganai/MoganOCR-TR-1.5
MoganOCR-TR-1.5
MoganOCR-TR-1.5 is the next version of MoganOCR-TR, a 2B-parameter OCR model for Turkish documents. It reads one page image and writes the whole page in reading order as Markdown, with tables as HTML and formulas as LaTeX. Same size, same prompt, same output format: it is a drop-in replacement.
On TurkishOCR-Bench it scores 91.9 (MoganOCR-TR: 89.9).
What's new
- No more memorized text on blank pages. On empty scanned pages MoganOCR-TR often wrote a memorized passage ("1. BΓLΓM / KALP VE DAMAR HASTALIKLARIβ¦") or looped until the token limit. 1.5 returns an empty output, or only what is really on the page (page number,
<figure/>, form boxes). - Better tables. Table TEDS rises from 82.5 to 86.9.
- No repetition loops. On TurkishOCR-Bench, pages that loop until the token limit went from 2 to 0; on text pages of the held-out set, from 8 to 0.
- Better on scanned pages. Text usability on scanned pages rises from 71.0 to 78.4.
Results
TurkishOCR-Bench: 488 hard pages, 10 categories, scored with the published pipeline (oku_puanla.py + tob_v3.py, CDM included). Images up to 4,194,304 pixels (the processor default, which gave the best results), up to 8,000 new tokens.
| MoganOCR-TR | MoganOCR-TR-1.5 | |
|---|---|---|
| TOB score | 89.9 | 91.9 |
| Text_TR | 89.4 | 91.0 |
| Table (TEDS) | 82.5 | 86.9 |
| Formula (CDM) | 97.8 | 97.8 |
| Clean pages | 65.8% | 68.3% |
| Unreliable pages | 26.8% | 24.7% |
| Turkish-character tests | 97.6 | 99.2 |
| Pages looping to the token limit | 2 | 0 |
Demo
Real MoganOCR-TR-1.5 outputs on three TurkishOCR-Bench pages (from the benchmark run; the model has not seen these pages in training): the raw Markdown as it is generated and the rendered result. All three pages score full marks.
Pages: Bayram, Sevilgen, Δ°biΕ, GU J Sci Part C 10(1), 2022 (CC BY-SA 4.0); AΕΔ±cΔ±oΔlu et al., Acta Odontologica Turcica, 2026 (CC BY 4.0); BektaΕi Εairleri ve Nefesleri, p. 160 (public domain, Wikimedia Commons).
How it was trained
Starting from MoganOCR-TR, with the vision encoder frozen:
- GRPO (DAPO loss, TRL + vLLM): 125 steps, 8 pages Γ 8 samples per step. Pages were chosen where the model's own samples disagreed. Reward: text similarity, table row and number F1, empty output on blank pages, zero for loops and truncated outputs.
- Short SFT (1 epoch, 1,086 pages): blank pages that RL could not fix, plus the model's own high-scoring outputs on text pages to prevent forgetting.
- Weight averaging: 50% RL model + 50% SFT model. The SFT model alone fixed blank pages but skipped about 5% of text pages; the average keeps both.
Usage
The prompt is always SayfayΔ± markdown olarak yaz. ("Write the page as markdown."). Keep thinking off (the chat template default), decode greedily and allow up to 8,000 new tokens. Keep the processor's default image limit of 4,194,304 pixels; the results above were measured with it.
vLLM
vllm serve moganai/MoganOCR-TR-1.5 --max-model-len 32768 --limit-mm-per-prompt '{"image": 1, "video": 0}'
import base64, requests
img = base64.b64encode(open("page.png", "rb").read()).decode()
r = requests.post("http://localhost:8000/v1/chat/completions", json={
"model": "moganai/MoganOCR-TR-1.5",
"temperature": 0,
"max_tokens": 8000,
"chat_template_kwargs": {"enable_thinking": False},
"messages": [{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img}"}},
{"type": "text", "text": "SayfayΔ± markdown olarak yaz."},
]}],
})
print(r.json()["choices"][0]["message"]["content"])
MTP: mtp.safetensors is the MTP head of MoganOCR-TR, not retrained for 1.5. Enable it with --speculative-config '{"method": "mtp", "num_speculative_tokens": 3}'. The speed-up was not re-measured for 1.5.
Transformers
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "moganai/MoganOCR-TR-1.5"
model = AutoModelForImageTextToText.from_pretrained(model_id, dtype="bfloat16", device_map="auto")
processor = AutoProcessor.from_pretrained(model_id)
messages = [{"role": "user", "content": [
{"type": "image", "image": Image.open("page.png")},
{"type": "text", "text": "SayfayΔ± markdown olarak yaz."},
]}]
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=8000, do_sample=False)
print(processor.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Resolution: the processor accepts images up to 4,194,304 pixels by default, so an A4 page at 200 dpi goes in unscaled (about 3,800 visual tokens). All benchmark numbers above use this setting, which gave the best results; avoid lowering max_pixels.
Output format
| Content | Format |
|---|---|
| Text, headings, lists | Markdown. One paragraph per line; words hyphenated at line ends are joined. |
| Tables | HTML <table>, merged cells as rowspan / colspan |
| Formulas | LaTeX, inline $...$ and block $$...$$ |
| Running header / footer | <header>...</header> and <footer>...</footer> |
| Figures | <figure/> |
License
Apache 2.0
Citation
@article{tasdemir2026moganocr,
title = {MoganOCR-TR and TurkishOCR-Bench: A Vision-Language OCR Model and Page-Level Evaluation Set for Turkish Document Parsing},
author = {Aleyna Tasdemir and Furkan Yilmaz and Muhammed Faruk Gozay},
year = {2026}
}
MoganOCR-TR-1.5 (TΓΌrkΓ§e)
MoganOCR-TR-1.5, TΓΌrkΓ§e belgeler iΓ§in 2B parametreli OCR modeli MoganOCR-TR'nin yeni sΓΌrΓΌmΓΌdΓΌr. Tek bir sayfa gΓΆrΓΌntΓΌsΓΌnΓΌ okuyup bΓΌtΓΌn sayfayΔ± okuma sΔ±rasΔ±yla Markdown olarak yazar; tablolar HTML, formΓΌller LaTeX olur. Boyut, istem ve Γ§Δ±ktΔ± biΓ§imi aynΔ±dΔ±r: doΔrudan yerine geΓ§er.
TurkishOCR-Bench'te 91,9 alΔ±r (MoganOCR-TR: 89,9).
Neler deΔiΕti
- BoΕ sayfada ezber metin yok. MoganOCR-TR boΕ taranmΔ±Ε sayfalarda sΔ±k sΔ±k ezberlenmiΕ bir metin ("1. BΓLΓM / KALP VE DAMAR HASTALIKLARIβ¦") yazΔ±yor ya da token sΔ±nΔ±rΔ±na kadar dΓΆngΓΌye giriyordu. 1.5 boΕ Γ§Δ±ktΔ± verir ya da yalnΔ±z sayfada gerΓ§ekten olanΔ± yazar (sayfa numarasΔ±,
<figure/>, form kutularΔ±). - Daha iyi tablolar. Tablo TEDS 82,5'ten 86,9'a Γ§Δ±ktΔ±.
- Tekrar dΓΆngΓΌsΓΌ yok. TurkishOCR-Bench'te token sΔ±nΔ±rΔ±na kadar dΓΆngΓΌye giren sayfa 2'den 0'a, ayrΔ±lmΔ±Ε deΔerlendirme kΓΌmesinin metin sayfalarΔ±nda 8'den 0'a indi.
- TaranmΔ±Ε sayfalarda daha iyi. TaranmΔ±Ε sayfalarda metin kullanΔ±labilirliΔi 71,0'dan 78,4'e Γ§Δ±ktΔ±.
SonuΓ§lar
TurkishOCR-Bench: 10 kategoride 488 zor sayfa, yayΔ±mlanan hatla (oku_puanla.py + tob_v3.py, CDM dahil) puanlandΔ±. GΓΆrΓΌntΓΌ ΓΌst sΔ±nΔ±rΔ± 4.194.304 piksel (iΕlemcinin varsayΔ±lanΔ±; en iyi sonucu bu ayar verdi), en Γ§ok 8.000 yeni token.
| MoganOCR-TR | MoganOCR-TR-1.5 | |
|---|---|---|
| TOB-Skor | 89,9 | 91,9 |
| Metin_TR | 89,4 | 91,0 |
| Tablo (TEDS) | 82,5 | 86,9 |
| FormΓΌl (CDM) | 97,8 | 97,8 |
| Temiz sayfa | %65,8 | %68,3 |
| GΓΌvenilmez sayfa | %26,8 | %24,7 |
| TΓΌrkΓ§e karakter testleri | 97,6 | 99,2 |
| Token sΔ±nΔ±rΔ±na kadar dΓΆngΓΌye giren sayfa | 2 | 0 |
Demo
MoganOCR-TR-1.5'in TurkishOCR-Bench'teki ΓΌΓ§ sayfada gerΓ§ek Γ§Δ±ktΔ±sΔ± (benchmark koΕusundan; model bu sayfalarΔ± eΔitimde gΓΆrmedi): ΓΌretilirken akan ham Markdown ve iΕlenmiΕ hΓ’li. ΓΓ§ sayfa da tam puan alΔ±r.
Sayfalar: Bayram, Sevilgen, Δ°biΕ, GU J Sci Part C 10(1), 2022 (CC BY-SA 4.0); AΕΔ±cΔ±oΔlu ve ark., Acta Odontologica Turcica, 2026 (CC BY 4.0); BektaΕi Εairleri ve Nefesleri, s. 160 (kamu malΔ±, Wikimedia Commons).
NasΔ±l eΔitildi
MoganOCR-TR'den baΕlanarak, gΓΆrsel kodlayΔ±cΔ± dondurulmuΕ hΓ’lde:
- GRPO (DAPO kaybΔ±, TRL + vLLM): 125 adΔ±m, adΔ±m baΕΔ±na 8 sayfa Γ 8 ΓΆrnek. Sayfalar, modelin kendi ΓΆrneklerinin birbirinden ayrΔ±ΕtΔ±ΔΔ± sayfalardan seΓ§ildi. ΓdΓΌl: metin benzerliΔi, tablo satΔ±r ve sayΔ± F1'i, boΕ sayfada boΕ Γ§Δ±ktΔ±; dΓΆngΓΌ ve kesik Γ§Δ±ktΔ± sΔ±fΔ±r alΔ±r.
- KΔ±sa SFT (1 epoch, 1.086 sayfa): RL'in dΓΌzeltemediΔi boΕ sayfalar ve unutmayΔ± ΓΆnlemek iΓ§in modelin metin sayfalarΔ±ndaki kendi yΓΌksek puanlΔ± Γ§Δ±ktΔ±larΔ±.
- AΔΔ±rlΔ±k ortalamasΔ±: %50 RL modeli + %50 SFT modeli. YalnΔ±z SFT modeli boΕ sayfalarΔ± Γ§ΓΆzΓΌyor ama metin sayfalarΔ±nΔ±n yaklaΕΔ±k %5'ini atlΔ±yordu; ortalama ikisinin iyisini korur.
KullanΔ±m
Δ°stem her zaman SayfayΔ± markdown olarak yaz. olmalΔ±dΔ±r. DΓΌΕΓΌnme kapalΔ± kalΔ±r (sohbet Εablonunun varsayΔ±lanΔ±), Γ§ΓΆzme aΓ§gΓΆzlΓΌdΓΌr ve en Γ§ok 8.000 yeni token ΓΌretilir. vLLM ve Transformers ΓΆrnekleri yukarΔ±daki Δ°ngilizce bΓΆlΓΌmle aynΔ±dΔ±r.
ΓΓΆzΓΌnΓΌrlΓΌk: Δ°Εlemci varsayΔ±lan olarak 4.194.304 piksele kadar gΓΆrΓΌntΓΌ kabul eder; 200 dpi'lik bir A4 sayfa kΓΌΓ§ΓΌltΓΌlmeden girer (yaklaΕΔ±k 3.800 gΓΆrsel token). YukarΔ±daki bΓΌtΓΌn benchmark sonuΓ§larΔ± bu ayarla ΓΆlΓ§ΓΌldΓΌ ve en iyi sonucu bu ayar verdi; max_pixels deΔerini dΓΌΕΓΌrmeyin.
MTP: mtp.safetensors, MoganOCR-TR'nin MTP kafasΔ±dΔ±r; 1.5 iΓ§in yeniden eΔitilmedi. --speculative-config '{"method": "mtp", "num_speculative_tokens": 3}' ile aΓ§Δ±lΔ±r; hΔ±zlanma 1.5 iΓ§in yeniden ΓΆlΓ§ΓΌlmedi.
Lisans
Apache 2.0
- Downloads last month
- 73