Image-Text-to-Text
Transformers
Safetensors
Sanskrit
qwen3_5
ocr
sanskrit
devanagari
document-ocr
sansar
conversational
Eval Results (legacy)
Instructions to use MuseMesh/sansar-ocr-2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MuseMesh/sansar-ocr-2b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="MuseMesh/sansar-ocr-2b") 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("MuseMesh/sansar-ocr-2b") model = AutoModelForMultimodalLM.from_pretrained("MuseMesh/sansar-ocr-2b", 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 MuseMesh/sansar-ocr-2b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MuseMesh/sansar-ocr-2b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MuseMesh/sansar-ocr-2b", "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/MuseMesh/sansar-ocr-2b
- SGLang
How to use MuseMesh/sansar-ocr-2b 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 "MuseMesh/sansar-ocr-2b" \ --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": "MuseMesh/sansar-ocr-2b", "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 "MuseMesh/sansar-ocr-2b" \ --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": "MuseMesh/sansar-ocr-2b", "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 MuseMesh/sansar-ocr-2b with Docker Model Runner:
docker model run hf.co/MuseMesh/sansar-ocr-2b
Download training/summary.json from MuseMesh/sansar-ocr-2b: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/MuseMesh/sansar-ocr-2b/resolve/main/training/summary.json
- Command line
-
hf download hf://MuseMesh/sansar-ocr-2b/training/summary.json
-
curl -L -o summary.json https://huggingface.co/MuseMesh/sansar-ocr-2b/resolve/main/training/summary.json
1.46 kB
| { | |
| "run": "ocrvlm_v12_clean_q35", | |
| "model": "Qwen/Qwen3.5-2B", | |
| "steps": 2000, | |
| "max_steps": 2000, | |
| "samples": 32000, | |
| "best_checkpoint": "/opt/sansar/runs/ocrvlm_v12_clean_q35/checkpoint-2000", | |
| "best_val_loss": 0.06209864094853401, | |
| "evals": [ | |
| [ | |
| 200, | |
| 0.15769308805465698 | |
| ], | |
| [ | |
| 400, | |
| 0.1268068104982376 | |
| ], | |
| [ | |
| 600, | |
| 0.10351545363664627 | |
| ], | |
| [ | |
| 800, | |
| 0.09406991302967072 | |
| ], | |
| [ | |
| 1000, | |
| 0.08291669189929962 | |
| ], | |
| [ | |
| 1200, | |
| 0.07203876972198486 | |
| ], | |
| [ | |
| 1400, | |
| 0.06750340759754181 | |
| ], | |
| [ | |
| 1600, | |
| 0.06383494287729263 | |
| ], | |
| [ | |
| 1800, | |
| 0.062389373779296875 | |
| ], | |
| [ | |
| 2000, | |
| 0.06209864094853401 | |
| ] | |
| ], | |
| "train_loss": 0.053184996942679086, | |
| "wall_seconds": 7254.4, | |
| "tokens_seen": 80725777, | |
| "peak_mem_gb": 34.63, | |
| "gpu": "NVIDIA A100-SXM4-40GB", | |
| "args": { | |
| "model": "Qwen/Qwen3.5-2B", | |
| "data_root": "/opt/sansar/ocrdata", | |
| "out_dir": "/opt/sansar/runs/ocrvlm_v12_clean_q35", | |
| "max_pixels": 1800000, | |
| "max_len": 6144, | |
| "samples": 30000, | |
| "max_steps": 2000, | |
| "grad_accum": 16, | |
| "lr": 1.5e-05, | |
| "vision_lr": 5e-06, | |
| "warmup_ratio": 0.03, | |
| "final_gold_frac": 0.15, | |
| "eval_steps": 200, | |
| "val_max": 300, | |
| "val_per_source": 120, | |
| "save_total_limit": 2, | |
| "workers": 8, | |
| "seed": 0, | |
| "freeze_vision": false, | |
| "optim": "adamw8bit", | |
| "no_grad_ckpt": false, | |
| "smoke": 0, | |
| "device_map": null, | |
| "pilot": false, | |
| "weights": "gold_twin=1.5,textbooks=0.5,air=0.2,synthetic=0.3" | |
| }, | |
| "batch_size": 16 | |
| } |