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
- -