A 1.38B-parameter conversational language model trained from scratch, with native web-search and calculator tool use, an explicit thinking mode, and a 16K token context window.
Small, spicy, and entirely open — built on 8× NVIDIA H100 GPUs in a few hours by Manmohan Sharma. Weights, tokenizer, training data, and scripts are all here.
The companion dataset repository ManmohanSharma/nanochat-d24-training-data hosts the 40 parquet shards (~18 GB) used for base pretraining and continued pretraining.
Quick usage
Hit the live endpoint
bash
1curl -N -X POST https://manmohan659--samosachaat-inference-inference-generate.modal.run \2 -H 'Content-Type: application/json'\3 -d '{
4 "messages": [
5 {"role": "user", "content": "You are samosaChaat, a helpful AI assistant. Answer directly.\n\nWho created you?"}
6 ],
7 "temperature": 0.3,
8 "max_tokens": 256
9 }'
Returns a Server-Sent Events stream. Each data: {"token": "..."} line is one output token.
1import torch
2from nanochat.checkpoint_manager import load_model
3from nanochat.engine import Engine
4from nanochat.tools import build_default_tool_registry
56# Download the weights first:7# from huggingface_hub import snapshot_download8# snapshot_download("ManmohanSharma/nanochat-d24",9# allow_patterns=["chatsft_checkpoints/d24-sft-r6/*", "tokenizer/*"])1011device = torch.device("cuda")12model, tokenizer, meta = load_model(13"sft", device,"eval", model_tag="d24-sft-r6", step=75414)15engine = Engine(model, tokenizer, tools=build_default_tool_registry())1617# Direct chat18messages =[{"role":"user","content":19"You are samosaChaat, a helpful AI assistant. Answer directly and concisely.\n\n"20"What is samosa chaat?"}]21tokens = tokenizer.render_for_completion({"messages": messages +[{"role":"assistant","content":""}]})22out, _ = engine.generate_batch(tokens, num_samples=1, max_tokens=200, temperature=0.3)23print(tokenizer.decode(out[0]))
Enable web search
Set TAVILY_API_KEY in the environment. build_default_tool_registry() auto-detects it and swaps from the mock search backend to the real Tavily backend. Without the key, tool calls return mock results.
System prompt conventions
Two modes, distinguished purely by the system prompt (the model was trained on both):
Direct mode (concise answers):
You are samosaChaat, a helpful AI assistant. Answer directly and concisely.
Thinking mode (visible chain-of-thought):
You are samosaChaat, a helpful AI assistant. Think step by step inside <think>...</think> tags, then give your final answer.
You are samosaChaat, a helpful AI assistant with access to tools. Use web_search for facts that may change over time or require current information, and calculator for arithmetic. Otherwise answer directly.
All system prompts are merged into the first user message at tokenisation time, matching the nanochat tokenizer convention.
Evaluation
Final probe suite (33 prompts across 9 categories, PASS/FAIL grading — see evals/eval_results_v2.jsonl):
Category
d24-sft-r6
Factual recall (Paris, Au, 1945, speed of light, etc.)
6/6 (100%)
Indian cuisine / culture (samosa chaat, rasgulla, biryani, rupee, Taj Mahal, Diwali)
6/6 (100%)
Math (linear equations, percentages, rate problems)
4/4 (100%)
Identity (name, creator attribution, parameter count, rejects "are you ChatGPT?")
6/6 (100%)
Creative writing (haiku, limerick)
2/2 (100%)
General chat (intros, technical explanations, language compare)
3/3 (100%)
Tool use (web_search for current events, calculator for tips)
Numeric trivia hallucination — like all ~1 B parameter models, specific figures (GDP, population) may be wrong. The built-in web_search tool mitigates this when invoked.
Temporal reasoning — day-of-week arithmetic and similar multi-step temporal problems still miss.
Joint think-and-tool use — the SFT data trained <think> reasoning and <|python_start|> tool calling as separate patterns. When a user explicitly turns on thinking mode, the model sometimes reasons from memory rather than calling web_search. Turning off thinking mode (or using the tool-aware system prompt without the <think> clause) reliably invokes the search tool.
Knowledge cut-off — pretraining data cut-off is inherited from the base corpora. For current information always rely on web_search.
Safety and intended use
This model is released as an open educational artifact to demonstrate that a capable conversational LLM can be trained from scratch on modest academic-scale compute. It is not intended as a reference factual source — treat all outputs as draft information to be verified.
Credits
Built by Manmohan Sharma — AI Researcher and Full Stack Engineer, pursuing an MS in Computer Science (AI) at the University of San Francisco.