SuperMart SLM

A 340M-parameter Qwen3-architecture language model trained from scratch (no pretrained weights) on supermarket transaction data and retail research papers. It answers retail-analytics questions about a 2.6M-line supermarket transaction dataset. Built for the AIML-C Design Thinking project.

Repository layout

The repository has two folders:

Folder Contents
model/ everything needed to use the model
notebook/ the Jupyter notebooks that build the model

README.md (this card), LICENSE and .gitattributes stay at the top level because Hugging Face requires them there.

model/

File Use
model.safetensors, config.json, generation_config.json πŸ€— transformers (Qwen3ForCausalLM, float32)
tokenizer.json, tokenizer_config.json, chat_template.jinja Qwen3 BPE tokenizer + ChatML chat template
supermart-slm-q8_0.gguf Ollama / llama.cpp (Q8_0, 367 MB)
Modelfile Ollama import: ChatML template, system prompt, stop tokens

notebook/

File What it is
6_supermart_slm_end_to_end.ipynb main notebook β€” the complete pipeline with all code inline: data cleaning, dataset build, statistics, train/val/test files, tokenizer, model, 3-stage training, evaluation, export, GGUF, Ollama, question test, browser chat
6_supermart_slm_end_to_end_training_run_2026-11-18.ipynb the executed training run (18 Nov 2026, RTX 4050 Laptop, ~7 h) with every live training log line
5_slm_from_scratch_qwen.ipynb first experiment: Qwen3 SLM on TinyStories
requirements.txt Python packages needed to run the notebooks

Architecture

Type decoder-only transformer, Qwen3 layout
Layers / hidden / FFN 12 / 768 / 3072 (SwiGLU)
Attention grouped-query, 12 query heads / 6 KV heads, head dim 64, QK-RMSNorm, RoPE ΞΈ = 10,000
Vocabulary Qwen3 BPE, 151,936
Context 512 tokens
Parameters 339.6M (untied embedding and LM head)

Training (only our own data, single RTX 4050 Laptop GPU, 6 GB)

Stage Data Steps Final train loss Final val loss
A β€” pre-training from scratch 262,659 supermarket baskets written as text (90M-token corpus; 4,000 steps β‰ˆ 33M tokens seen) 4,000 0.455 0.529
B β€” domain pre-training 11 cleaned retail research papers + glossary + data insights 800 1.317 6.635 (best 5.766)
C β€” chat fine-tuning (ChatML, loss on answers only) 452 Q&A conversations, 223 facts computed from the data 800 0.011 2.871 (best 1.927)

AdamW 8-bit (Ξ² 0.9/0.95, wd 0.1), linear warm-up + cosine decay, bf16 autocast with fp32 master weights, gradient checkpointing. About 7 hours in total. The final checkpoint of stage C is published.

Evaluation

Metric Value
Stage A validation perplexity (13,825 held-out baskets) 1.7
Numeric fact recall, questions seen in training (sample of 50) 95.3 %
Numeric fact recall, never-seen questions (67 held-out conversations) 4.8 %

Numeric fact recall = share of the numbers in the reference answer that the model reproduces (greedy decoding). The model memorises its training facts almost perfectly but does not generalise to new facts.

Use with Ollama

hf download nandangowda/supermart-slm model/supermart-slm-q8_0.gguf model/Modelfile --local-dir supermart-slm
cd supermart-slm/model
ollama create supermart-slm -f Modelfile
ollama run supermart-slm "Which departments generate the most sales?"

Use with transformers

from transformers import AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained("nandangowda/supermart-slm", subfolder="model")
model = AutoModelForCausalLM.from_pretrained("nandangowda/supermart-slm", subfolder="model")
system = "You are SuperMart SLM, a small language model trained from scratch to answer questions about supermarket retail analytics: sales, products, departments, discounts, baskets, customer demographics, gross margin, pricing, payment methods and tax. Answer concisely and use the numbers from the SuperMart transaction dataset when relevant."
msgs = [{"role": "system", "content": system},
        {"role": "user", "content": "What is the average basket size?"}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt", return_dict=True)["input_ids"]
out = model.generate(ids, max_new_tokens=128, do_sample=False)
print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True))

Example

Q: What time of day do customers shop the most? A: Sales peak at 17:00-18:00 (10.3% of daily sales). The morning (6-12) brings 16.1%, afternoon (12-17) brings 40.7%, evening (17-22) brings 38.1% of sales.

Limitations

A small model trained from scratch on a narrow domain. It reproduces the facts it was fine-tuned on exactly, but invents confident wrong answers for questions outside them (held-out validation facts are not recalled). Not for real business or financial decisions.

Downloads last month
431
GGUF
Model size
0.3B params
Architecture
qwen3
Hardware compatibility
Log In to add your hardware

8-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Dataset used to train nandangowda/supermart-slm