Instructions to use mamleshva/kural-270m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mamleshva/kural-270m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mamleshva/kural-270m") 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("mamleshva/kural-270m") model = AutoModelForCausalLM.from_pretrained("mamleshva/kural-270m", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mamleshva/kural-270m with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mamleshva/kural-270m" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mamleshva/kural-270m", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mamleshva/kural-270m
- SGLang
How to use mamleshva/kural-270m 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 "mamleshva/kural-270m" \ --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": "mamleshva/kural-270m", "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 "mamleshva/kural-270m" \ --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": "mamleshva/kural-270m", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use mamleshva/kural-270m with Docker Model Runner:
docker model run hf.co/mamleshva/kural-270m
Kural 270M — Tamil chat model (v0.1)
அகர முதல எழுத்தெல்லாம் ஆதி பகவன் முதற்றே உலகு.
Kural 270M is Gemma 3 270M-it fine-tuned on Tamil instruction data. It is a tiny (268M-parameter) model that runs on any laptop CPU, made as a first step toward a Tamil-first small language model.
Status: early experimental release (v0.1). It is measurably better at Tamil than the base model, but it is still small and lightly trained: it often states wrong facts, rambles after answering and does not handle Tanglish (romanized Tamil) yet. Don't rely on it for facts.
| Base model | google/gemma-3-270m-it (via the ungated mirror unsloth/gemma-3-270m-it) |
| Parameters | 268.1M (167.8M embedding + 100.3M transformer) |
| Languages | Tamil (primary), English |
| Context used in training | 384 tokens |
| Weights | model.safetensors, fp32, 1.07 GB |
| Tokenizer | original Gemma 3 tokenizer (262k vocab), unchanged |
| Chat format | Gemma chat template (included) |
Quick start
Python (transformers)
pip install "transformers>=4.53,<5" torch sentencepiece
from transformers import pipeline
chat = pipeline("text-generation", model="itspigeon/kural-270m")
messages = [{"role": "user", "content": "தமிழ்நாட்டின் தலைநகரம் எது?"}]
out = chat(messages, max_new_tokens=128, do_sample=False, repetition_penalty=1.15)
print(out[0]["generated_text"][-1]["content"])
Manual generation (more control)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "itspigeon/kural-270m"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.float32).eval()
messages = [{"role": "user", "content": "ஒளிச்சேர்க்கை என்றால் என்ன? எளிய தமிழில் விளக்குங்கள்."}]
enc = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
with torch.no_grad():
ids = model.generate(**enc, max_new_tokens=128, do_sample=False, repetition_penalty=1.15)
print(tok.decode(ids[0, enc["input_ids"].shape[1]:], skip_special_tokens=True))
Interactive chat in your terminal
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
model_id = "itspigeon/kural-270m"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.float32).eval()
streamer = TextStreamer(tok, skip_prompt=True, skip_special_tokens=True)
history = []
while True:
user = input("\nநீங்கள்: ").strip()
if user in {"", "exit", "quit"}:
break
history.append({"role": "user", "content": user})
enc = tok.apply_chat_template(history, add_generation_prompt=True, return_tensors="pt", return_dict=True)
ids = model.generate(**enc, max_new_tokens=160, do_sample=False, repetition_penalty=1.15, streamer=streamer)
history.append({"role": "assistant",
"content": tok.decode(ids[0, enc["input_ids"].shape[1]:], skip_special_tokens=True)})
Download the files
pip install -U "huggingface_hub[cli]"
hf download itspigeon/kural-270m --local-dir kural-270m
or git clone https://huggingface.co/itspigeon/kural-270m (needs git lfs).
Google Colab
Open a new notebook (a free CPU or T4 runtime is enough), run !pip install -q "transformers>=4.53,<5",
then paste the Python (transformers) example above.
Tips: use greedy decoding (do_sample=False) with repetition_penalty around 1.1–1.2, and keep
max_new_tokens around 100–160. Longer outputs tend to drift. On a laptop CPU it generates at about
3 tokens/s in fp32. A GPU is much faster.
Evaluation
All numbers were measured on CPU with the same code for both models: zero-shot log-likelihood,
acc_norm = per-byte-normalized choice accuracy, greedy generation for the chat prompts.
| Metric | gemma-3-270m-it (base) | kural-270m (this model) |
|---|---|---|
| Bits per byte, held-out Tamil text (lower is better) | 0.606 | 0.548 (−9.6%) |
| Tamil cloze sanity set (22 items) | 0.409 | 0.455 |
| IndicCOPA-ta (500, chance = 0.50) | 0.522 | 0.546 |
| IndicSentiment-ta (998, chance ≈ 0.50) | 0.493 | 0.495 |
| Chat test prompts with a short reference answer, answer contains it (14) | 1/14 | 3/14 |
| SFT validation loss (58 held-out conversations) | – | 2.364 (ppl 10.6) |
How to read these:
- The clearest gain is bits per byte on Tamil text the model never saw: 200 passages from the Tamil SQuAD 2.0 validation split (training used only the train split). This means the model predicts natural Tamil noticeably better.
- IndicCOPA moved +2.4 points, which is within noise for 500 items. Sentiment stays at chance for both models, so it is not a useful signal at this size.
- The chat-prompt check is a crude string match. The fine-tuned model gets the capital of Tamil Nadu (சென்னை) and the number of Tamil vowels (12) right where the base model did not, but it still misses Thiruvalluvar, translation and simple reasoning.
The full report with every model answer is in eval/report.md, and the raw
numbers are in eval/results.json.
Training
Full-parameter supervised fine-tuning (all 268M weights), 1 epoch on a single Colab T4 GPU (~6 minutes).
| Source | Conversations sampled | License |
|---|---|---|
| abhinand/tamil-alpaca-orca | 1,500 | GPL-3.0 |
| CohereForAI/aya_dataset (Tamil only) | 600 | Apache-2.0 |
| RajeevanL/tamil_squad-2.0 (train) | 498 | not stated |
| yahma/alpaca-cleaned (English replay) | 300 | CC BY 4.0 |
| Hand-written Tamil / spoken / Tanglish examples | 16 | Apache-2.0 |
After dropping examples longer than 384 tokens: 2,169 train / 58 validation conversations.
| Hyperparameter | Value |
|---|---|
| Learning rate | 5e-5, cosine, 5% warmup |
| Batch size | 16 (no accumulation), 136 steps |
| Max sequence length | 384 (longer examples dropped) |
| Loss | assistant tokens only |
| NEFTune noise alpha | 5 |
| Precision | mixed precision on GPU (auto), weights saved in fp32 |
Limitations and risks
- Hallucinations: it confidently states wrong facts (for example, it does not reliably know who wrote the Thirukkural).
- Rambling and repetition: after a correct short answer it often keeps generating loosely related text.
- Tanglish / romanized Tamil: not learned yet. It tends to echo the prompt back.
- Safety: no safety tuning beyond what the base Gemma model had. It did not decline the hacking request in the test set.
- Small data: trained on about 2.2k conversations for one epoch. Treat it as a baseline for further work.
License
This model is a derivative of Gemma and is distributed under the Gemma Terms of Use. Your use must also follow the Gemma Prohibited Use Policy. The training data includes Tamil Alpaca (GPL-3.0) and other datasets with their own licenses (see the table above). Check them before commercial use.
Citation
@misc{kural270m2026,
title = {Kural 270M: a small Tamil instruction-tuned Gemma 3 model},
author = {itspigeon},
year = {2026},
url = {https://huggingface.co/itspigeon/kural-270m}
}
- Downloads last month
- -
Model tree for mamleshva/kural-270m
Datasets used to train mamleshva/kural-270m
yahma/alpaca-cleaned
RajeevanL/tamil_squad-2.0
Evaluation results
- acc_norm on IndicCOPA (Tamil, test)test set self-reported0.546
- acc_norm on IndicSentiment (Tamil, test)test set self-reported0.495
- bits per byte (lower is better) on Tamil SQuAD 2.0 validation passages (200, held out)validation set self-reported0.548