5 yesterday

indus-5m: A 5.52M-parameter conversational LLM trained 100% from scratch with a custom SentencePiece tokenizer, exported to GGUF for Ollama.

ollama run theunwindfront/indus-5m

Details

yesterday

53ebab1bf524 · 5.9MB

llama
·
5.52M
·
Q8_0
{{- range .Messages }}<|im_start|>{{ .Role }} {{ .Content }}<|im_end|> {{ end }}<|im_start|>assistan
You are a helpful, concise conversational assistant. Adapt your tone, terminology, and guardrails to
{ "num_ctx": 512, "stop": [ "<|im_start|>", "<|im_end|>" ], "tempera

Readme

Indus-5M — Custom From-Scratch Industry LLM

LLM Architecture

indus-5m is a lightweight, 100% from-scratch conversational LLM trained with a custom SentencePiece BPE tokenizer and randomly initialized Transformer weights (zero 3rd-party pre-trained weights), exported to GGUF and published on Ollama:


Model Overview

Model Name Parameters Architecture Tokenizer Format Size
indus-5m 5.52M Decoder-only Transformer (Llama-style) Custom SentencePiece BPE (800 vocab + byte fallback) GGUF (Q8_0) 5.88 MB

Architecture Specifications

  • Layers (num_hidden_layers): 6
  • Attention Heads (num_attention_heads): 4
  • Hidden Size (hidden_size): 256
  • FFN Intermediate Size (intermediate_size): 768
  • Context Length (max_position_embeddings): 512
  • Parameters: ~5.52M (initialized from random weights, 0% 3rd-party weights)
  • Tokenizer: Custom SentencePiece BPE (vocab_size=800, byte_fallback=True, custom <|system|>, <|user|>, <|assistant|> tokens)
  • Supported Industries (Starter Dataset): Healthcare, E-Commerce, Real Estate, Fintech / Banking, Hospitality

Requirements for Building & Scaling Your Own Model

1. Software Stack

  • Python: 3.12+
  • Training & Tokenizer: torch, transformers, datasets, accelerate, sentencepiece, protobuf
  • GGUF Conversion: llama.cpp (convert_hf_to_gguf.py) + gguf
  • Local Inference Runtime: Ollama (Docker or host)

2. Dataset Requirements (data/train.jsonl)

Because indus-5m starts from random weights (no 3rd-party pre-trained knowledge), it learns grammar, tone, and domain facts exclusively from your dataset.

Format each conversation as one JSON object per line:

{"messages": [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]}
Stage Dataset Volume Expected Capability
Pipeline Test 10–100 conversations Verifies tokenization, training, GGUF export, and Ollama serving end-to-end
Narrow Domain Bot 50,000–200,000+ conversations (10M–50M tokens) Handles structured, predictable industry dialogues
Fluent Multi-Industry Chat Millions of dialogues + general text (1B+ tokens) Natural, flexible multi-turn conversation

3. Hardware & Scaling Guide

Model Scale Example Config Recommended Hardware
Tiny (~5M–15M params) --layers 6 --hidden-size 256 --heads 4 --vocab-size 800 CPU (16 GB RAM) — great for pipeline testing
Small (~50M–150M params) --layers 12 --hidden-size 512 --heads 8 --vocab-size 16000 1x GPU (16–24 GB VRAM)
Medium (~300M–1B params) --layers 16 --hidden-size 1024 --heads 16 --vocab-size 32000 1–4x A100/H100 GPUs

Project Files


Quickstart

1. Install Dependencies

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 -r requirements.txt

2. Train From Scratch

.venv/bin/python scripts/train_from_scratch.py --epochs 20

3. Convert to GGUF & Load into Ollama

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
python3 scripts/push_to_ollama.py --gguf exports/indus-5m.gguf --name indus-5m

4. Run Inference in Ollama

curl http://localhost:11434/api/chat -d '{
  "model": "indus-5m:latest",
  "messages": [{"role": "user", "content": "Hi"}],
  "stream": false
}'

Evaluation Checklist & Limitations

  • Evaluation: Check training loss convergence, multi-turn coherence, industry persona adherence (healthcare, ecommerce, realestate, fintech, hospitality), and vocabulary coverage.
  • Current Stage: Trained as a 5.52M-parameter prototype on the starter dataset in data/train.jsonl. Scale dataset size and model dimensions before production use.
  • Intended Use: Educational/custom model development and local Ollama deployment with 0% 3rd-party pre-trained weights.

[!CAUTION] Check each dataset’s licence before you redistribute a trained model. When expanding data/train.jsonl with external or industry datasets, treat indus-5m weights as research-only until upstream data terms are confirmed.


📜 License

Code in this repository is released under the Apache License 2.0. Released model weights (indus-5m) are Apache-2.0 as well, subject to the terms of their training data (see above).


If this helped you, consider giving it a ⭐