Instructions to use kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16") 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("kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16") model = AutoModelForMultimodalLM.from_pretrained("kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16", 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 kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16", "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/kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16
- SGLang
How to use kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16 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 "kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16" \ --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": "kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16", "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 "kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16" \ --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": "kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16", "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 kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16 with Docker Model Runner:
docker model run hf.co/kailasa-ngpt/gemma-4-31b-tamil-devanagari-ocr-bf16
Gemma 4 31B Tamil + Devanagari OCR — BF16
This is the primary-quality merged checkpoint produced by the workspace's
Tamil and Devanagari OCR fine-tune. It starts from google/gemma-4-31B-it and
merges the selected rank-32 language-layer LoRA into Google's original BF16
weights. The vision tower stayed frozen. Sanskrit is covered where it is
written in Devanagari; this model has not been validated for other Sanskrit
scripts such as Grantha.
Training
- Distillation dataset:
kailasa-ngpt/gemini-3.7-flash-ocr-26-aug-2026 - Target rows: 8,374 Devanagari and 4,066 Tamil; 68 Telugu rows excluded
- Balanced training stream: 16,748 examples through deterministic Tamil oversampling
- Optimized examples: 4,000 (1,000 steps, physical batch 4)
- QLoRA: NF4 load, rank/alpha 32/32, 410 language-layer targets
- Learning rate: 1e-4 cosine; best checkpoint at step 950
- Best clean-book validation loss: 0.407109946
- Sequence/image budgets: 8,192 total tokens and 1,120 vision tokens
- Training peak: 31.13 GiB allocated on one RTX PRO 6000 96GB
Evaluation
All text metrics preserve raw model Unicode and line boundaries. The primary metric is extended-grapheme-cluster CER (gCER).
| Gate | gCER mean | gCER median | gCER clipped at 100% | Catastrophic | 4,096-token caps |
|---|---|---|---|---|---|
| Independent 80-page gate | 25.68% | 11.12% | 17.42% | 7/80 | 4/80 |
| Untouched base, same pages | 374.74% | 17.56% | 25.99% | 11/80 | 6/80 |
The fine-tune beat the base on 66/80 paired pages. A 20,000-replicate, script-stratified bootstrap estimated 99.505% probability that its raw mean gCER is lower; the very wide interval is caused by unbounded CER on base-model repetition loops.
On the untouched public benchmark's 350 natural-text cases, this BF16 artifact scored 3.238% gCER (Tamil 5.512%, Devanagari 0.965%) and 53.14% exact match. Its aggregate gCER difference from the base was not statistically resolved on that short-text benchmark.
vLLM
From the workspace root:
scripts/serve_vllm.sh artifacts/gemma4-31b-tamil-devanagari-ocr-bf16
.venv-serve/bin/python scripts/ocr_vllm_client.py page.png --output page.txt
The client uses the exact training prompt, temperature-zero decoding, preserves output verbatim, and cancels long exact grapheme repetition cycles. Exit code 2 means the token limit was reached; exit code 3 means the repetition guard fired. The artifact pins the 1,120-token image budget in both model and processor configuration, so ordinary vLLM loading matches the fine-tuning input budget.
Limitations and terms
The source dataset card declares license other, and its labels are Gemini
teacher outputs rather than human ground truth. It also documents teacher-side
normalization. Review the source-corpus rights, dataset terms, Gemini terms, and
the base model's Apache 2.0 license before redistribution or commercial deployment. OCR errors,
including occasional autoregressive loops, remain; do not treat the output as a
faithful scholarly edition without review.
- Downloads last month
- 9