Instructions to use moganai/MoganOCR-TR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moganai/MoganOCR-TR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="moganai/MoganOCR-TR") 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") model = AutoModelForMultimodalLM.from_pretrained("moganai/MoganOCR-TR", 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 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moganai/MoganOCR-TR" # 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", "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
- SGLang
How to use moganai/MoganOCR-TR 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" \ --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", "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" \ --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", "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 with Docker Model Runner:
docker model run hf.co/moganai/MoganOCR-TR
MoganOCR-TR
MoganOCR-TR is a 2B-parameter OCR model for Turkish documents. It takes one page image and writes the whole page in reading order as Markdown, with tables as HTML and formulas as LaTeX. It is a full fine-tune of Qwen3.5-2B, vision encoder included, on 357,763 pages of which 77% are Turkish.
On TurkishOCR-Bench it scores 89.9, fourth of 18 models and first among OCR-specific models, ahead of general models hundreds of times its size. On Turkish text alone it is second, behind only GPT-6.1 Sol.
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> |
Everything visible on the page is transcribed as it appears, including page numbers, footnotes and watermarks. Handwriting is transcribed as written; the writer's spelling mistakes are not corrected.
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.
vLLM
vllm serve moganai/MoganOCR-TR --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",
"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"])
Transformers
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "moganai/MoganOCR-TR"
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))
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).
Examples
Model outputs on TurkishOCR-Bench pages, rendered. The model has not seen these pages in training.
Results
TurkishOCR-Bench has 488 hard pages from 368 documents in 10 categories (academic, table, formula, scanned, old and new Official Gazette, book, receipt/invoice/form, slide, handwriting), with human-verified ground truth and 115,116 unit tests. The main score is TOB = (Text_TR + Table + Formula) / 3: tables by TEDS, block formulas by CDM, and Text_TR as the geometric mean of unit-test accuracy and page usability on Turkish text.
The pages were chosen because models struggle on them, so these scores compare models; they are not the accuracy to expect on an average document. MoganOCR-TR was built by the team that built the benchmark. The training set was checked for overlap with it, every model is scored by the same deterministic rules, and the raw outputs of all 18 models are released with the benchmark.
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 (Türkçe)
MoganOCR-TR, Türkçe belgeler için 2B parametreli bir OCR modelidir. Tek bir sayfa görüntüsü alır ve bütün sayfayı okuma sırasıyla Markdown olarak yazar; tablolar HTML, formüller LaTeX olur. Qwen3.5-2B üzerine, görsel kodlayıcı dahil tam ince ayardır; %77'si Türkçe olan 357.763 sayfayla eğitildi.
TurkishOCR-Bench'te 89,9 alır: 18 model içinde dördüncü, OCR'a özel modeller içinde birinci; kendisinden yüzlerce kat büyük genel modellerin önündedir. Yalnız Türkçe metinde, GPT-6.1 Sol'un ardından ikincidir.
Çıktı biçimi
| İçerik | Biçim |
|---|---|
| Metin, başlık, liste | Markdown. Her paragraf tek satırdır; satır sonunda bölünen kelimeler birleştirilir. |
| Tablo | HTML <table>, birleşik hücreler rowspan / colspan ile |
| Formül | LaTeX, satır içi $...$ ve blok $$...$$ |
| Sayfa üst / alt bilgisi | <header>...</header> ve <footer>...</footer> |
Sayfada görünen her şey göründüğü gibi yazılır: sayfa numarası, dipnot ve filigran dahil. El yazısı yazıldığı gibi aktarılır; yazarın yazım hataları düzeltilmez.
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
vllm serve moganai/MoganOCR-TR --max-model-len 32768 --limit-mm-per-prompt '{"image": 1, "video": 0}'
import base64, requests
img = base64.b64encode(open("sayfa.png", "rb").read()).decode()
r = requests.post("http://localhost:8000/v1/chat/completions", json={
"model": "moganai/MoganOCR-TR",
"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"])
Transformers
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "moganai/MoganOCR-TR"
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("sayfa.png")},
{"type": "text", "text": "Sayfayı markdown olarak yaz."},
]}]
girdi = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True,
return_dict=True, return_tensors="pt").to(model.device)
cikti = model.generate(**girdi, max_new_tokens=8000, do_sample=False)
print(processor.decode(cikti[0, girdi["input_ids"].shape[1]:], skip_special_tokens=True))
İş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).
Örnekler
TurkishOCR-Bench sayfalarında model çıktıları, işlenmiş hâlde. Model bu sayfaları eğitimde görmedi.
Sonuçlar
TurkishOCR-Bench, 10 kategorideki (akademik, tablo, formül, taranmış, eski ve yeni Resmî Gazete, kitap, fiş/fatura/form, slayt, el yazısı) 368 belgeden 488 zor sayfa, insan onaylı doğru metin ve 115.116 birim testten oluşur. Ana skor TOB = (Metin_TR + Tablo + Formül) / 3'tür: tablolar TEDS, blok formüller CDM ile ölçülür; Metin_TR ise Türkçe metinde birim test doğruluğu ile sayfa kullanılabilirliğinin geometrik ortalamasıdır.
Sayfalar modellerin zorlandığı sayfalardan seçildi; bu skorlar modelleri karşılaştırır, ortalama bir belgede beklenecek doğruluğu göstermez. MoganOCR-TR, benchmarkı hazırlayan ekip tarafından geliştirildi. Eğitim kümesi benchmarkla örtüşme açısından denetlendi, bütün modeller aynı deterministik kurallarla puanlandı ve 18 modelin ham çıktıları benchmarkla birlikte yayımlandı.
Lisans
Apache 2.0
Atıf
@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}
}
- Downloads last month
- 73