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/label_stats.json from MuseMesh/sansar-ocr-2b: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/MuseMesh/sansar-ocr-2b/resolve/main/training/label_stats.json
- Command line
-
hf download hf://MuseMesh/sansar-ocr-2b/training/label_stats.json
-
curl -L -o label_stats.json https://huggingface.co/MuseMesh/sansar-ocr-2b/resolve/main/training/label_stats.json
2.17 kB
| { | |
| "version": "v1.2-clean", | |
| "built_from": "/run/media/kushal/Kush/sansar/data/ocr_labels/v1", | |
| "rules": "(every train / val row of v1.1 is decided by them; test = the 54 bench_v1 pages, unchanged):\n 1. tiers silver_vision, llm_claude, llm_codex and sources textbooks_vision, air_vision, llm_claude, llm_codex: dropped.\n 2. any remaining row that carries an ocr_engine, a cer_vs_vision value or an id prefix of those tiers\n (tbv_, airv_, llmc_, llmx_): dropped (none expected; a guard).\n 3. synthetic pages that typeset a paragraph whose corpus record lists `vagartha` (Sarvam's Vagartha dataset) among\n its source_corpora: dropped. The paragraph ids come from --vagartha_ids (id<TAB>source_corpora, made by a\n grep of train_slice_plus_all_v2 for the synthetic text cache's ids); a page is dropped when it shares one\n 16-letter window (hnorm, stride 1 on the page) with any of those paragraphs.\n 4. kept tiers must be gold_twin, gold_digital (textbooks: text layer, AIR: OCR-free decode) and synthetic (curated\n e-text typeset): asserted.", | |
| "splits": { | |
| "train": { | |
| "pages": 19377, | |
| "books": 1057, | |
| "chars": 27080866, | |
| "by_tier": { | |
| "gold_twin": 11074, | |
| "gold_digital": 7206, | |
| "synthetic": 1097 | |
| }, | |
| "by_source": { | |
| "twin": 11074, | |
| "textbooks": 3367, | |
| "air": 3839, | |
| "synthetic": 1097 | |
| } | |
| }, | |
| "val": { | |
| "pages": 711, | |
| "books": 31, | |
| "chars": 1045871, | |
| "by_tier": { | |
| "gold_twin": 209, | |
| "gold_digital": 478, | |
| "synthetic": 24 | |
| }, | |
| "by_source": { | |
| "twin": 209, | |
| "textbooks": 36, | |
| "air": 442, | |
| "synthetic": 24 | |
| } | |
| }, | |
| "test": { | |
| "pages": 54, | |
| "books": 53, | |
| "chars": 86038, | |
| "by_tier": { | |
| "gold_bench": 54 | |
| }, | |
| "by_source": { | |
| "bench": 54 | |
| } | |
| } | |
| }, | |
| "dropped": { | |
| "train: synthetic page typesets a Vagartha (Sarvam) paragraph": 847, | |
| "train: tier llm_claude (llm_claude)": 420, | |
| "train: tier llm_codex (llm_codex)": 219, | |
| "train: tier silver_vision (air_vision)": 908, | |
| "train: tier silver_vision (textbooks_vision)": 2881, | |
| "val: synthetic page typesets a Vagartha (Sarvam) paragraph": 26, | |
| "val: tier silver_vision (air_vision)": 125 | |
| } | |
| } |