A small (337M parameter) Hindi-only language model, pretrained from scratch on 10 billion tokens of Hindi text and then instruction-tuned on about 59k Hindi instruction/response pairs.
It is a research/hobby-scale model. It writes fluent Hindi and follows the instruction format, but it is not reliable on facts, arithmetic or reasoning (see Limitations).
| Architecture | Llama-style decoder (LlamaForCausalLM): RMSNorm, SwiGLU, RoPE, grouped-query attention, tied embeddings |
| Parameters | ~337M |
| Layers / hidden / FFN | 27 / 1024 / 2816 |
| Attention | 16 heads, 4 KV heads, head dim 64 |
| Context length | 2048 tokens |
| Vocabulary | 32,000 (SentencePiece BPE trained on Hindi, byte fallback, digits split) |
| RoPE theta | 10,000 |
| Weights | float32 safetensors (~1.3 GB) |
| Language | Hindi (Devanagari). English and other languages are not supported. |
Special tokens: <unk>=0, <s>=1, </s>=2, <pad>=3. The tokenizer also defines <|im_start|> and <|im_end|>, but they were not used in training. This model uses the plain-text template below.
The model was tuned on single-turn prompts in exactly this template. Use it, or the outputs will be noticeably worse.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "srivassid/hindi-llm-340m-instruct"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16).to("cuda").eval()
PROMPT = "### निर्देश:\n{instruction}\n\n### उत्तर:\n"
def ask(instruction, max_new_tokens=300):
ids = tok(PROMPT.format(instruction=instruction), return_tensors="pt").to("cuda")
with torch.no_grad():
out = model.generate(
**ids,
max_new_tokens=max_new_tokens,
do_sample=False, # greedy; use do_sample=True, temperature=0.7, top_p=0.9 for variety
repetition_penalty=1.1, # helps with looping lists
eos_token_id=tok.eos_token_id,
)
return tok.decode(out[0, ids["input_ids"].shape[1]:], skip_special_tokens=True).strip()
print(ask("भारत की राजधानी क्या है?"))
Notes:
repetition_penalty of about 1.1 is recommended; without it, list-style answers (recipes, steps) tend to loop.hin) portion of AI4Bharat Sangraha, using the verified, unverified and synthetic subsets (native Devanagari only; romanized *_Latn synthetic data was excluded). 277 parquet files (~97 GB of text). About 25B Hindi tokens were available; the run consumed 10B tokens (19,074 steps).torch.compile.| Source | Examples |
|---|---|
| anudesh | 7,253 |
| dolly (translated) | 14,459 |
| wikihow | 4,949 |
| oasst1 | 3,389 |
| lm_sys | 15,000 (capped) |
| flan_v2 | 15,000 (capped) |
| Total | 60,050, split into 59,050 train / 1,000 validation |
Scored by comparing the model's log-likelihood of each answer choice (no prompting tricks), on the Hindi test sets. "Sum" means total log-probability of the choice; this is the headline number.
| Benchmark | Chance | Pretrained base | This model (SFT) |
|---|---|---|---|
| IndicCOPA (hi, 449 items) | 50% | 55.0% | 57.9% |
| Belebele (hin_Deva, 900 items) | 25% | 29.6% | 29.8% |
Accuracy, in percent. "Sum" ranks answer choices by total log-probability; "norm" divides by the number of answer tokens first. Both are shown because they differ by a point or two; compare models using the same column.
| Benchmark / slice | n | Chance | Base (sum) | Base (norm) | SFT (sum) | SFT (norm) |
|---|---|---|---|---|---|---|
| IndicCOPA, all | 449 | 50 | 55.0 | 53.5 | 57.9 | 54.3 |
| IndicCOPA, "cause" questions | 223 | 50 | 56.1 | 53.4 | 59.2 | 54.7 |
| IndicCOPA, "effect" questions | 226 | 50 | 54.0 | 53.5 | 56.6 | 54.0 |
| Belebele hin_Deva | 900 | 25 | 29.6 | 28.2 | 29.8 | 27.9 |
Held-out language-model loss (not a benchmark, for reference): pretraining validation loss 2.545 nats/token on Hindi text (perplexity ≈ 12.7); SFT validation loss 1.818 on 1,000 held-out instruction examples.
How to read these: the standard error is about ±2.4 points on IndicCOPA (±3.3 on the cause/effect halves) and ±1.4 on Belebele. Both models are above chance, but the differences between base and SFT are within noise. Scores at this level are typical for a model of this size; it has little commonsense or reading-comprehension ability. Only two benchmarks were run; no knowledge (MMLU-style) or maths benchmarks were attempted because a model this size is expected to score near chance.
"<premise without final danda> क्योंकि" for cause questions and "... इसलिए" for effect questions, followed by each choice. The choice with the higher log-likelihood is the prediction. No SFT prompt template is used, so this measures the language model rather than instruction following."<passage>\nप्रश्न: <question>\nउत्तर:" followed by each of the four answers; the answer with the highest log-likelihood is the prediction.hindillm/eval/ (copa.py, belebele.py); datasets are the public test files from the linked repositories.Please read before using the model.
Do not use this model for medical, legal, financial or other high-stakes decisions. Treat it as an experiment and a base for further research or fine-tuning.
The model weights and code in this repository are released under the Apache License 2.0.
Please note that the training data comes from several sources with their own terms, and the instruction data collection (ai4bharat/indic-instruct-data-v0.1) does not declare a single licence:
If your use is commercial or you redistribute derivative models, review the upstream terms yourself. The model author makes no legal claim about the data's terms.
HindiLLM), exported to Hugging Face format.