Instructions to use ucmani/Katha-31M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ucmani/Katha-31M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ucmani/Katha-31M")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ucmani/Katha-31M") model = AutoModelForCausalLM.from_pretrained("ucmani/Katha-31M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ucmani/Katha-31M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ucmani/Katha-31M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ucmani/Katha-31M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ucmani/Katha-31M
- SGLang
How to use ucmani/Katha-31M 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 "ucmani/Katha-31M" \ --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": "ucmani/Katha-31M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "ucmani/Katha-31M" \ --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": "ucmani/Katha-31M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ucmani/Katha-31M with Docker Model Runner:
docker model run hf.co/ucmani/Katha-31M
Model Card for Katha-31M
Katha-31M is a small (~31.5M-parameter) Llama-architecture language model pretrained from random initialisation on a subset of TinyStories. Katha means "story" in Hindi and Telugu. It is a learning project to understand the full pretraining workflow, not a model for real-world use.
Model Details
Model Description
- Developed by: mrmoney24
- Funded by [optional]: Self-funded (free Google Colab T4)
- Shared by [optional]: TODO: your Hugging Face username
- Model type: Decoder-only transformer (Llama architecture), base causal language model
- Language(s) (NLP): English
- License: TODO: verify (see metadata; depends on TinyStories dataset and SmolLM2 tokenizer terms)
- Finetuned from model [optional]: None. Trained from random initialisation. Only the tokenizer is reused, from
HuggingFaceTB/SmolLM2-135M.
Architecture: 8 layers, hidden size 384, MLP size 1024 (SwiGLU), 6 query heads and 2 key/value heads (grouped-query attention), RoPE positions, RMSNorm, tied input/output embeddings, vocabulary 49,152, context length 512. About 60% of the parameters are in the embedding table because the reused vocabulary is large for a model this size.
Model Sources [optional]
- Repository: None
- Paper [optional]: None
- Demo [optional]: None
- Case study: None
Uses
Direct Use
Studying, tinkering with and benchmarking a very small language model; a reference for how pretraining, memory budgeting, profiling and serving behave at tiny scale. It continues text in the style of simple children's stories.
Downstream Use
Possible as a small test model for inference tooling or fine-tuning experiments. It is not meant to be built into products.
Out-of-Scope Use
- Chat, instruction following or question answering (it is a base model).
- Any task needing factual knowledge, reasoning or safety guarantees.
- Anything outside simple English stories.
Bias, Risks, and Limitations
- Trained only on synthetic, simple children's-style English stories. No general knowledge; output can be repetitive, incoherent or meaningless.
- Inherits any biases of the TinyStories dataset, which was itself generated by language models.
- No safety tuning, filtering or red-teaming was done beyond what the dataset provides.
- Only training and validation loss are reported. No benchmark scores are claimed.
Recommendations
Treat it as an educational artifact. Do not use it for decisions, user-facing generation or anything where correctness matters.
How to Get Started with the Model
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "mrmoney24/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))
Training Details
Training Data
A subset of roneneldan/TinyStories: the first ~200,000 training stories (TODO: confirm count), about 222 tokens and 175 words per story. Check the dataset's own license and terms before reuse.
Training Procedure
Preprocessing
Each story was tokenized with the SmolLM2 tokenizer and an end-of-text token was appended. All stories were concatenated and cut into packed blocks of 512 tokens (no padding). 2% of the blocks were held out for validation (seed 0). Labels are a copy of the input ids; the model shifts them internally.
Training Hyperparameters
- Training regime: fp16 mixed precision (T4 has no bf16 support)
- Framework: Hugging Face
transformersTrainer,LlamaForCausalLMfrom aLlamaConfig - Batching: micro-batch 8 x 8 gradient-accumulation steps x 512 tokens = 32,768 tokens per optimizer step
- Optimizer: AdamW (beta2 = 0.95, weight decay 0.1), gradient clipping 1.0
- Learning rate: 1e-3 peak, 200 warm-up steps, cosine decay
- Steps: 3,000 (about 98M tokens seen)
- Checkpointing: every 500 steps; run was resumed from a checkpoint after a Colab disconnect (TODO: keep or delete to match what happened)
Speeds, Sizes, Times
- Throughput: TODO tokens/s on a T4
- Training time: 3 hours
- Weights:
model.safetensors, fp32, ~126 MB - Training checkpoint size: roughly 12 bytes per parameter including optimizer state (~380 MB)
Evaluation
Testing Data, Factors & Metrics
Testing Data
2% held-out packed blocks from the same TinyStories subset (in-distribution).
Factors
None. No disaggregated evaluation.
Metrics
Cross-entropy loss per token (and its exponential, perplexity). Loss is under this tokenizer, so it is not comparable with models using a different tokenizer.
Results
| Metric | Value |
|---|---|
| Initial loss (random weights) | 10.83 (ln 49,152 = 10.80, as expected) |
| Final training loss | 1.51 |
| Final validation loss | 1.50 |
Summary
"Validation loss fell from 10.83 to 1.5 over 3,000 steps."
Model Examination
Profiling of training steps with torch.profiler was done as a learning exercise (see the case study). No interpretability work.
Environmental Impact
- Hardware Type: NVIDIA T4 (16 GB)
- Hours used: TODO
- Cloud Provider: Google Colab
- Compute Region: TODO (not shown by Colab)
- Carbon Emitted: Not estimated
Model Architecture and Objective
Llama-style decoder-only transformer trained with next-token prediction (causal language modelling).
Compute Infrastructure
Hardware
One NVIDIA T4 GPU (Google Colab free tier).
Software
PyTorch, Hugging Face transformers, datasets, accelerate.
Citation
BibTeX:
@misc{katha31m,
title = {Katha-31M: a small Llama model pretrained from scratch on TinyStories},
author = {TODO},
year = {2026},
url = {https://huggingface.co/TODO-username/Katha-31M}
}
Dataset: Eldan and Li (2023), TinyStories: How Small Can Language Models Be and Still Speak Coherent English?, arXiv:2305.07759.
Glossary
- Packing: concatenating tokenized stories and cutting fixed-length blocks so no tokens are wasted on padding.
- GQA: grouped-query attention; several query heads share one key/value head to shrink the KV cache.
- RoPE: rotary position embeddings, applied inside attention (no learned position table).
- Tied embeddings: the input embedding matrix is reused as the output projection.
- Downloads last month
- -