ai4bharat/samanantar
Viewer • Updated • 49.8M • 2.54k • 38
How to use PredictiveManish/Trimurti-LM with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="PredictiveManish/Trimurti-LM") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("PredictiveManish/Trimurti-LM", dtype="auto")How to use PredictiveManish/Trimurti-LM with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "PredictiveManish/Trimurti-LM"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "PredictiveManish/Trimurti-LM",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/PredictiveManish/Trimurti-LM
How to use PredictiveManish/Trimurti-LM with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "PredictiveManish/Trimurti-LM" \
--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": "PredictiveManish/Trimurti-LM",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "PredictiveManish/Trimurti-LM" \
--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": "PredictiveManish/Trimurti-LM",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use PredictiveManish/Trimurti-LM with Docker Model Runner:
docker model run hf.co/PredictiveManish/Trimurti-LM
Trimurti-LM is a small, efficient multilingual language model trained from scratch on English, Hindi, and Punjabi text. Named after the Hindu trinity (Brahma-Vishnu-Shiva), it represents the three-fold capability of creating text, preserving meaning, and transforming across scripts.
Key Features:
| Aspect | Details |
|---|---|
| Architecture | GPT-2 style decoder-only Transformer |
| Parameters | 4,672,000 (4.2M) |
| Hidden Size | 256 |
| Layers | 4 |
| Attention Heads | 8 |
| Context Length | 128 tokens |
| Vocabulary | 8000 tokens (SentencePiece) |
| Training Steps | 5000 |
| Training Time | 2.38 hours |
| Hardware | NVIDIA GTX 1650 (4GB VRAM) |
The model was trained on a balanced multilingual corpus:
Sources:
Data Processing:
[EN], [HI], [PA] prefixes| Metric | Value | Notes |
|---|---|---|
| Final Loss | 1.206 | Cross-entropy loss |
| Perplexity | 3.32 | e^1.206 = 3.32 |
| Top-1 Accuracy | ~25% | Next token prediction |
| Top-5 Accuracy | ~60% | Next token prediction |
| Language ID Accuracy | 95% | With explicit tags |
from transformers import GPT2LMHeadModel
import sentencepiece as spm
import torch
# Load model and tokenizer
tokenizer = spm.SentencePieceProcessor()
tokenizer.load("multilingual_spm.model")
model = GPT2LMHeadModel.from_pretrained("PredictiveManish/Trimurti-LM")
# Generate text
prompt = "[EN] The weather is"
input_ids = tokenizer.encode(prompt)
input_tensor = torch.tensor([input_ids])
with torch.no_grad():
output = model.generate(
input_ids=input_tensor,
max_length=50,
temperature=0.7,
do_sample=True,
pad_token_id=0
)
generated = tokenizer.decode(output[0].tolist())
print(generated)
If you use Trimurti-LM in your work, please cite:
@software{trimurti_lm_2026,
title = {Trimurti-LM: A 4.2M Parameter Multilingual Language Model},
author = {Manish Tiwari},
year = {2026},
url = {https://huggingface.co/PredictiveManish/Trimurti-LM},
note = {Trained from scratch on English, Hindi, and Punjabi with consumer hardware}
}
@inproceedings{samanantar_2021,
title = {Samanantar: The Largest Publicly Available Parallel Corpora Collection for 11 Indic Languages},
author = {Gowtham Ramesh and Sumanth Doddapaneni and Aravinth Bheemaraj and Mayank Jobanputra and Raghavan AK and Ajitesh Sharma and Sujit Sahoo and Harshita Diddee and Mahalakshmi J and Divyanshu Kakwani and Navneet Kumar and Aswin Pradeep and Srihari Nagaraj and Kumar Deepak and Vivek Raghavan and Anoop Kunchukuttan and Pratyush Kumar and Mitesh Shantadevi Khapra},
booktitle = {Proceedings of the Neural Information Processing Systems (NeurIPS) Track on Datasets and Benchmarks},
year = {2021},
url = {https://arxiv.org/abs/2104.05596}
}