A 5.52M-parameter LLM trained 100% from scratch. Choose an industry below or try a prompt.
OLLAMA_ORIGINS="*" ollama serve
A comprehensive walk-through on designing, training, quantizing, and deploying a lightweight 5.52M-parameter language model with a custom SentencePiece BPE tokenizer, zero third-party pre-trained weights, and native Ollama distribution.
Indus-5M implements a decoder-only autoregressive Transformer using a modern LLaMA-style topology with RoPE (Rotary Position Embeddings), RMSNorm, and SwiGLU activation functions.
| Hyperparameter | Config Value | Engineering Rationale |
|---|---|---|
| num_hidden_layers | 6 | Sufficient compositional depth for grammatical and domain intent capture. |
| num_attention_heads | 4 | Allows parallel self-attention computation with 64 dimensions per head. |
| hidden_size | 256 | Compact embedding projection suited for ultra-low memory footprints (<10 MB). |
| intermediate_size (FFN) | 768 | Standard 3x hidden size ratio for SwiGLU feed-forward networks. |
| max_position_embeddings | 512 | Context window optimized for multi-turn structured industry customer service. |
| vocab_size (BPE) | 800 + byte fallback | Drastically reduces embedding weight matrix size without losing any character support. |
| Total Parameters | 5,524,480 (~5.52M) | 100% trained from random Gaussian initialization. Zero inherited weights. |
Most small models fail because they use huge tokenizers (like 32,000+ vocab) where the embedding layer consumes 90% of all parameters. Indus-5M uses a tailored 800-vocabulary SentencePiece BPE with byte-fallback to guarantee that unknown characters never crash the tokenizer.
<|system|> You are a helpful conversational assistant for the healthcare industry. <|user|> I need to reschedule my dental cleaning for next Tuesday. <|assistant|> I'd be happy to help you reschedule your dental cleaning. Could you share your full name and preferred time?
The model is trained entirely with PyTorch and Hugging Face Accelerate. The training dataset (data/train.jsonl) contains multi-turn JSON objects for the target domains.
uv venv --python python3.12 .venv uv pip install --python .venv/bin/python torch --index-url https://download.pytorch.org/whl/cpu uv pip install --python .venv/bin/python transformers datasets accelerate sentencepiece protobuf
.venv/bin/python scripts/train_from_scratch.py --epochs 20 --output-dir outputs/scratch_model
Once the Hugging Face model checkpoint is saved, we convert the weights to GGUF using llama.cpp and quantize to Q8_0 (8-bit quantization) to preserve full precision while keeping the file under 6 MB.
git clone --depth 1 https://github.com/ggml-org/llama.cpp /tmp/llama.cpp
mkdir -p exports
.venv/bin/python /tmp/llama.cpp/convert_hf_to_gguf.py outputs/scratch_model \
--outfile exports/indus-5m.gguf \
--outtype q8_0
Ollama Modelfile Configuration:
FROM ./exports/indus-5m.gguf
TEMPLATE """<|system|>
{{ .System }}
<|user|>
{{ .Prompt }}
<|assistant|>
"""
PARAMETER stop "<|system|>"
PARAMETER stop "<|user|>"
PARAMETER stop "<|assistant|>"
PARAMETER temperature 0.7
PARAMETER top_p 0.9
Register & Push to Ollama Hub:
ollama create theunwindfront/indus-5m -f ollama/Modelfile ollama push theunwindfront/indus-5m
curl http://localhost:11434/api/chat \
-d '{
"model": "theunwindfront/indus-5m",
"messages": [
{"role": "user", "content": "Hi!"}
]
}'
from ollama import chat
res = chat(
model='theunwindfront/indus-5m',
messages=[{'role': 'user', 'content': 'Hello!'}]
)
print(res.message.content)
import ollama from 'ollama';
const res = await ollama.chat({
model: 'theunwindfront/indus-5m',
messages: [{ role: 'user', content: 'Hello!' }]
});
console.log(res.message.content);
# Download and start interactive REPL ollama run theunwindfront/indus-5m # Check local model list ollama list
| Scale Tier | Parameters | Recommended Hardware | Target Capabilities |
|---|---|---|---|
| Tiny (Current) | ~5.52M | Standard CPU (16 GB RAM) | Pipeline verification, structured intents, edge devices |
| Small | ~50M–150M | 1x Consumer GPU (16–24 GB VRAM) | Multi-turn structured dialogues & enterprise FAQ agents |
| Medium | ~300M–1B | 1–4x A100 / H100 GPUs | Fluent generative synthesis, reasoning & multi-task execution |
© 2026 Sagar Pansuriya • Released under Apache 2.0 License