Instructions to use kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora
- SGLang
How to use kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora 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 "kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora with Docker Model Runner:
docker model run hf.co/kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora
DeepSeek-OCR-2 Urdu OCR 1M LoRA
LoRA adapter fine-tuned from deepseek-ai/DeepSeek-OCR-2 for Urdu OCR on a small subset of PuristanLabs1/urdu-ocr-1M.
Summary
- Base model:
deepseek-ai/DeepSeek-OCR-2 - Task: Urdu OCR
- Dataset config:
nastaliq - Train samples:
800 - Validation samples:
80 - Metric: CER
This is a small adapter-focused experiment meant to improve Urdu transcription quality without uploading a full model checkpoint.
Usage
This repo is an adapter repo. You can load it directly and PEFT will attach the base model automatically from the adapter config.
import torch
from peft import AutoPeftModelForCausalLM
from transformers import AutoTokenizer
MODEL_ID = "kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
model = AutoPeftModelForCausalLM.from_pretrained(
MODEL_ID,
trust_remote_code=True,
torch_dtype=torch.bfloat16,
use_safetensors=True,
_attn_implementation="flash_attention_2",
)
model = model.eval().cuda()
model.config.use_cache = True
prompt = "<image>\nFree OCR. "
result = model.infer(
tokenizer,
prompt=prompt,
image_file="sample.png",
output_path="ocr-output",
base_size=1024,
image_size=768,
crop_mode=True,
save_results=False,
eval_mode=True,
)
print(result)
Training
- Precision: bf16
- Epochs: 1
- Train batch size: 1
- Eval batch size: 1
- Gradient accumulation: 8
- Learning rate:
1e-4 - Warmup steps:
10 - Weight decay:
0.01 - Scheduler: cosine
LoRA target modules:
q_projkv_a_proj_with_mqakv_b_projo_projgate_projup_projdown_proj
Results
Two example comparisons from the validation subset:
| Sample | Base CER | Finetuned CER |
|---|---|---|
| 21 | 0.6290 | 0.0806 |
| 53 | 1.5385 | 0.3846 |
Detailed examples:
sample_index: 21
reference : آنے والے شخص نے اپنا تعارف کرواتے ہوئے کہا:”میرا نام شہزاد ہے۔
before : ۱- وله شخص از پشت رفت و آمد و به "میرادام" بشارد.
after : آئے والے شخص نے اپنا تعارف کرواتے ہوئے کہا: ”میں ہام شہزاد ہے۔
sample_index: 53
reference : آپﷺ نے فرمایا کہ اے انجشہ!
before : 1 - في كتابة النص، هل تسبيماً ماكسراً؟ اكتب ثابتاً!
after : آپ ﷺ نے فسر ملیا کرا اے اچھٹ !
These examples improved clearly, but this is still a small-sample run and should not be treated as a full benchmark.
Limitations
- trained on only
800/80samples - evaluated on a very small subset
- may not generalize well to real scanned Urdu documents without further validation
Citation
Please cite the base model and dataset.
@article{wei2026deepseek,
title={DeepSeek-OCR 2: Visual Causal Flow},
author={Wei, Haoran and Sun, Yaofeng and Li, Yukun},
journal={arXiv preprint arXiv:2601.20552},
year={2026}
}
Model tree for kingabzpro/deepseek-ocr-2-urdu-ocr-1m-lora
Base model
deepseek-ai/DeepSeek-OCR-2