Instructions to use eulogik/Bharat-Tiny-LLM-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use eulogik/Bharat-Tiny-LLM-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="eulogik/Bharat-Tiny-LLM-v2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("eulogik/Bharat-Tiny-LLM-v2") model = AutoModelForCausalLM.from_pretrained("eulogik/Bharat-Tiny-LLM-v2", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use eulogik/Bharat-Tiny-LLM-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "eulogik/Bharat-Tiny-LLM-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "eulogik/Bharat-Tiny-LLM-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/eulogik/Bharat-Tiny-LLM-v2
- SGLang
How to use eulogik/Bharat-Tiny-LLM-v2 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 "eulogik/Bharat-Tiny-LLM-v2" \ --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": "eulogik/Bharat-Tiny-LLM-v2", "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 "eulogik/Bharat-Tiny-LLM-v2" \ --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": "eulogik/Bharat-Tiny-LLM-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use eulogik/Bharat-Tiny-LLM-v2 with Docker Model Runner:
docker model run hf.co/eulogik/Bharat-Tiny-LLM-v2
Brahmi: Efficient Devanagari Token Injection for Multilingual LLMs (Technical Breakdown)
Brahmi: Efficient Devanagari Token Injection for Multilingual LLMs
Abstract & Problem Overview
Multilingual transformer models built on English-heavy training corpora penalize Indian languages with a severe "Token Tax". Standard Byte-Pair Encoding (BPE) tokenizers (such as Qwen2.5's 151.9k vocabulary) split common Devanagari words into 3 to 4 fragmented byte tokens.
For example, the simple Hindi sentence:
"ज़रूरी बात है क्या करते हो"
- Base Qwen2.5 Tokenizer: Burns 26 tokens 🔴
- Bharat-Tiny-LLM v2 (Brahmi Tokenizer): Requires only 11 tokens 🟢 (58% Token Savings)
This token bloat inflates memory bandwidth requirements, slows down generation throughput, and forces early context window exhaustion.
Technical Innovation: Brahmi Token Injection
Instead of retraining a 1.5B model from scratch, we developed Brahmi Token Injection — a surgical two-stage vocabulary expansion and embedding alignment technique:
- Vocabulary Expansion: Identified top 300 recurring Devanagari subwords from a 50GB Hindi corpus and injected them into the tokenizer dictionary (expanding vocabulary from 151,936 to 152,236 tokens).
- Stage 1 (Embedding Alignment): Initialized new embedding matrix rows. Froze the transformer decoder backbone and trained strictly the 300 new token embeddings to align their representations with existing semantic space.
- Stage 2 (LoRA Fine-Tuning): Attached rank-16 PEFT LoRA adapters ($lpha=32$) across attention projection matrices (
q_proj,k_proj,v_proj,o_proj) for downstream instruction tuning.
Empirical Benchmarks & Quantitative Results
| Metric | Base Qwen2.5-1.5B | Bharat-Tiny-LLM v2 | Technical Advantage |
|---|---|---|---|
| Tokens for 1,000 Hindi Chars | ~950 tokens | ~630 tokens | 33.8% Token Reduction |
| Hindi Inference Speed | 50 tok/s | 68 tok/s | +36% Faster Throughput |
| Validation Loss (Hindi Corpus) | 2.776 | 1.837 | 52.5% Loss Reduction (Perplexity: 16.1 → 6.3) |
| Model Size (Q4 Affine) | 880 MB | 880 MB | Runs in <3.8 GB RAM (Apple Silicon / PyTorch) |
Code Quickstart
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_name = "eulogik/Bharat-Tiny-LLM-v2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
prompt = "भारत की सांस्कृतिक विविधता के बारे में बताइए:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=150, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Open Weights & Apache 2.0 License. Built by Eulogik (@GautamKishore ).