Image-Text-to-Text
Transformers
Safetensors
Turkish
English
qwen3_vl
ocr
multimodal
lamapi
next3
conversational
Instructions to use thelamapi/next3-ocr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thelamapi/next3-ocr with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="thelamapi/next3-ocr") 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("thelamapi/next3-ocr") model = AutoModelForMultimodalLM.from_pretrained("thelamapi/next3-ocr", 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 thelamapi/next3-ocr with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thelamapi/next3-ocr" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thelamapi/next3-ocr", "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/thelamapi/next3-ocr
- SGLang
How to use thelamapi/next3-ocr 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 "thelamapi/next3-ocr" \ --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": "thelamapi/next3-ocr", "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 "thelamapi/next3-ocr" \ --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": "thelamapi/next3-ocr", "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 thelamapi/next3-ocr with Docker Model Runner:
docker model run hf.co/thelamapi/next3-ocr
Next3-OCR
Next3-OCR is the first OCR vision-language model in Lamapi's Next 3 series, built for accurate verbatim document transcription across Turkish and English documents, receipts, and handwriting.
Model Lineage & Identity
| Field | Details |
|---|---|
| Product Name | Next3-OCR |
| Series | Next 3 |
| Developer & Training Organization | Lamapi (thelamapi) |
| Founder | Ersin Sarp Yiฤit |
| Owner | Ersin Sarp Yiฤit |
| Starting Checkpoint | thelamapi/next-ocr (pinned revision: 5790b6dd78f415cd7e7e73f6a5101fc07507e7f0) |
| Architecture | Qwen3VLForConditionalGeneration (Qwen3VLProcessor, ~8.77B BF16 parameters) |
| Artifact Format | Full sharded safetensors Transformers checkpoint (merge_and_unload(safe_merge=True) from LoRA adapter) |
Benchmark Comparison (Measured Head-to-Head)
All models below were evaluated under identical conditions on the exact same locked held-out test set (24 real images: 10 Turkish documents from moganai/TurkishOCR-Bench, 7 real receipts from naver-clova-ix/cord-v2, and 7 handwritten lines from Teklia/IAM-line), plus 10 unseen neutral-prompt identity probes.
| Model | Char Accuracy (โ) | Strict CER (โ) | Strict WER (โ) | Turkish Char Accuracy (โ) | Identity Accuracy (โ) |
|---|---|---|---|---|---|
| Next3-OCR (Lamapi, Next 3) | 80.04% | 0.1996 | 0.3368 | 36.73% | 100.0% |
Next-OCR (thelamapi/next-ocr, baseline) |
75.81% | 0.2419 | 0.4229 | 26.82% | 0.0% |
EasyOCR (tr+en) |
50.65% | 0.4935 | 0.7805 | 27.51% | N/A |
Tesseract OCR (tur+eng) |
53.24% | 0.4676 | 0.662 | 33.29% | N/A |
Training Method
- Backbone & Adapter: Vision encoder frozen; 4-bit QLoRA (NF4 + BF16 compute) applied to language-model attention and MLP projections (
q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj). - Stage 1 (Identity & Task Separation): Trained with neutral system prompts, disjoint train/val/test identity templates, false-premise & roleplay resistance, and OCR-vs-identity counterexamples to prevent brand leakage into OCR outputs.
- Stage 2 (Real OCR Fine-Tuning): Trained on verified Turkish documents (
moganai/TurkishOCR-Bench), real receipts (naver-clova-ix/cord-v2), and real handwriting (Teklia/IAM-line) with validation-CER checkpoint selection and identity replay. - Merged Export: Starting checkpoint reloaded at the exact pinned revision in full BF16 (non-quantized) and merged via
merge_and_unload(safe_merge=True).
Quick Start
import torch
from PIL import Image
from transformers import AutoProcessor, Qwen3VLForConditionalGeneration
model_id = "thelamapi/next3-ocr"
processor = AutoProcessor.from_pretrained(model_id)
model = Qwen3VLForConditionalGeneration.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
image = Image.open("document.png").convert("RGB")
messages = [{"role": "user", "content": [{"type": "image", "image": image}, {"type": "text", "text": "Extract all text from this image verbatim in reading order."}]}]
prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[prompt], images=[image], return_tensors="pt").to(model.device)
with torch.inference_mode():
out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(processor.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
License & Source Metadata Notes
- The starting checkpoint
thelamapi/next-ocrlistsapache-2.0in its repository YAML metadata while its README body displays an MIT badge, and its README refers to8Bwhilesafetensorsmetadata reports8,767,123,696(~8.77B) parameters. - Limitations: Very dense, low-DPI, or severely degraded scans may still produce character errors. Always verify critical numeric/legal fields in production workflows.
- Downloads last month
- 44