Instructions to use sarvamai/sarvam-m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sarvamai/sarvam-m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sarvamai/sarvam-m") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sarvamai/sarvam-m") model = AutoModelForCausalLM.from_pretrained("sarvamai/sarvam-m", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sarvamai/sarvam-m with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sarvamai/sarvam-m" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sarvamai/sarvam-m", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sarvamai/sarvam-m
- SGLang
How to use sarvamai/sarvam-m 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 "sarvamai/sarvam-m" \ --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": "sarvamai/sarvam-m", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "sarvamai/sarvam-m" \ --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": "sarvamai/sarvam-m", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sarvamai/sarvam-m with Docker Model Runner:
docker model run hf.co/sarvamai/sarvam-m
vLLM launch params? Tool calling?
Hi everyone,
I’m trying to serve sarvamai/sarvam-m with the latest dev build of vLLM (0.9.1, CUDA back-end).
Launch command:
python -m vllm.entrypoints.openai.api_server \
--model sarvamai/sarvam-m \
--tokenizer_mode mistral \
--load_format mistral \
--tensor_parallel_size 4 \
--enable_auto_tool_choice \
--tool_call_parser mistral \
--enable_prefix_caching \
--port 8080 \
--trust_remote_code
Log tail:
Traceback (most recent call last):
...
OSError: Found 0 files matching the pattern: ^tokenizer\.model\.v.*$|^tekken\.json$|^tokenizer\.mm\.model\.v.*$
Make sure that a Mistral tokenizer is present in
['tokenizer.json', 'tokenizer_config.json', ...]
What I think is happening
MistralTokenizer inside vLLM only recognises the official Mistral files (tekken.json, tokenizer.model.v*, etc.).
The Sarvam repo ships just the generic Hugging-Face tokenizer.json, so the scan returns nothing and the loader raises the OSError.
Questions
1. Is the quick fix simply
--tokenizer mistralai/Mistral-Small-24B-Instruct-2501
so vLLM grabs the tokenizer from the original base model while still loading Sarvam’s weights?
2. Switching to auto makes vLLM fall back to the Hugging Face fast tokenizer. Generation works, but you lose Mistral-3–specific extras (notably the function-calling / tool-calling special-token prefixes), so tool calls are no longer parsed.
3. Any other launch parameters I should tweak for a 4-GPU (H100 80 GB each) setup?
Thanks for any pointers!
— Aditya