Katha-31M - educational Llama model from scratch
2 min readupdated
Katha-31M is a compact language model built on the Llama architecture with approximately 31.5 million parameters, pretrained from scratch on the TinyStories dataset. The model's name means "story" in Hindi and Telugu. Created for educational purposes to study the full model pretraining cycle, it is not intended for production use. It continues text in the style of simple children's stories in English and works great for text generation experiments.
Key features
- Pretrained from scratch on random weight initialization using a subset of the TinyStories dataset.
- Built on a decoder-only transformer architecture featuring SwiGLU, grouped-query attention, and RoPE positional embeddings.
- Uses the SmolLM2-135M tokenizer with a vocabulary size of 49,152 tokens.
- Trained in just 3 hours on a free NVIDIA T4 GPU in Google Colab.
What you can do
- Run inference locally or in a notebook to generate short children's stories in English.
- Explore memory behavior, profiling, and training metrics on a miniature language model.
- Use as a lightweight testbed for setting up inference tools or fine-tuning experiments.
Example
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "ucmani/Katha-31M"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo)
inputs = tok("Once upon a time", return_tensors="pt")
out = model.generate(**inputs, max_new_tokens=60, do_sample=True, temperature=0.8)
print(tok.decode(out[0], skip_special_tokens=True))
Read more
DetailsFinal validation loss: 1.50 (down from an initial 10.83)
Hardware requirements: NVIDIA T4 GPU (16 GB), weights take up about 126 MB (fp32)
Limitations: trained exclusively on synthetic children's stories, lacks general knowledge, and is not designed for chat or tasks requiring factual information










Comments