Table of Contents
🌏 中文版
Calling an LLM through an API and training one from scratch are the two ends of the same map. Everyone has tried the former; a few years ago the latter was a "big-lab-only" activity — billion-dollar budgets and thousands of GPUs. MiniMind pulled that line down to about $0.4 (the cost of renting one RTX 3090 for two hours), while at the other end LLM360 K2 shows what "fully reproducible" looks like at industrial scale: 65B parameters, 1.4T tokens. This is the introduction to the "Training an LLM from Scratch" series (11 articles): first we define what we selected and why, then lay out the cost spectrum, the coverage matrix, and the bias annotations, and finally the learning path.
What this series covers
The population definition for "training an LLM from scratch": projects that publish the complete training pipeline — code plus data or a full recipe — where the model is pretrained from random initialization. We exclude three kinds of projects commonly mistaken for "from scratch": weight-only releases (models like Llama), fine-tuning only (Llama-Factory and the like), and pure inference frameworks. In other words, this series only includes projects where "you get every button" — training hyperparameters, the data recipe, and checkpoints at each stage.
Why train from scratch: the learning-vs-product tradeoff
The same motivation, "I want to understand LLMs," grows into two very different shapes at either end of the spectrum. This is the most important classification axis of the series:
- Learning-oriented, typified by MiniMind: 64M parameters, about $0.4 and 2 hours, 56.8k stars, with the goal that "everyone can read every line of code." Its value is not the model itself — 64M is useless for any real task — but the decision chain it lays open: why 8 layers, why a 6,400-token vocabulary, why GRPO is more stable than PPO.
- Product-oriented, typified by LLM360 K2 (65B / 1.4T tokens): the training goal is to compete with commercial models on real tasks, and "full reproducibility" is its biggest asset — for any training decision you want to verify, you can find the original code, data, and intermediate checkpoints.
In between there is a whole pricing ladder: learn algorithms from Karpathy's minimal codebases, learn data efficiency from YuLan-Mini, learn industrial transparency from the OLMo family. The decisive question is one sentence: is your question "why is this written this way," or "can this be reproduced"? — pick the cheap tutorial project for the former, and for the latter pick the most open project, not the cheapest one.
The cost spectrum
The same goal can cost six orders of magnitude differently: budget, parameter scale, and openness all shift together.
| Project | Size | Budget | Data | Positioning | Series part |
|---|---|---|---|---|---|
| MiniMind | 64M | ~$0.4 / ~2h on one 3090 | full-stage Qwen3-style data | full-pipeline tutorial (PreTrain→SFT→RL) | 1 |
| nanochat (same lineage as llm.c) | GPT-2/GPT-3-small territory | ~$100 / ~4h on 8×H100; $300 = GPT-2 grade; $1,000/41h ≈ GPT-3-small | public data + time-to-GPT-2 racing | minimal, single-node | 2 |
| Chinese community: baby-llama2-chinese, ChatLM-mini-Chinese, Steel-LLM | 0.2B–1B | 4GB VRAM to 8×H800 | mostly Chinese corpora | Chinese-first teaching and long-run testing | 3 |
| YuLan-Mini | 2.4B | academic (1.08T tokens) | data recipe + full W&B logs | data-efficiency research (ACL 2025 Oral) | 4 |
| OLMo 3 (2025-11) | 7B / 32B (incl. Think 32B reasoning model) | industrial | Dolma 3, ~6T tokens | stage checkpoints, Apache 2.0 | 5 |
| LLM360 K2 | 65B | industrial | 1.4T tokens | fully reproducible | 5 |
| SmolLM3 | 3B | 11.2T tokens (full recipe published 2025-07) | testing the data ceiling of small models | —(covered in parts 5–6) | — |
A few numbers worth remembering: Karpathy spent roughly $43,000 training GPT-2 in 2019; nanochat's "time to GPT-2" speedrun has squeezed that to the ~$100 level in under 4 hours (the early-2026 official record is ~$48 / 2 hours; spot pricing varies). YuLan-Mini reaches parity or better than 7–18T-token baselines on math and code with 1.08T tokens. SmolLM3 shows a 3B model can ingest 11.2T tokens without saturating — TinyLlama's 1.1B eating 3T without saturation was the precedent.
Coverage matrix
Framed as a matrix, you can see which dimensions this series has a dedicated part for and which only get a passing mention:
| Dimension | Population representatives | Series coverage |
|---|---|---|
| Extremely cheap teaching (<$10) | MiniMind, baby-llama2-chinese | ✅ parts 1, 3 |
| Minimal engineering ($100–1,000) | nanochat, llm.c | ✅ part 2 |
| Chinese-data-first | baby-llama2-chinese, ChatLM-mini-Chinese, Steel-LLM | ✅ part 3 |
| Data-efficiency research | YuLan-Mini | ✅ part 4 |
| Industrial full openness | OLMo 3, LLM360 K2 | ✅ part 5 |
| Open recipe but smaller scale | SmolLM3, MiniCPM, etc. | ⚠️ partially covered |
| Retired research tools | Pythia, TinyLlama | ⚠️ discussed below |
| National / multilingual sovereignty | Apertus (Switzerland), LLM-jp (Japan) | ✅ part 7 |
| Efficiency / edge / multimodal | OpenELM (Apple), MiniCPM (OpenBMB) | ✅ part 8 |
| From-scratch training framework | LitGPT (Lightning AI) | ✅ part 9 |
| Non-Transformer architectures | RWKV, Mamba family | ⚠️ contrast section in part 7 |
Retired cases: we mention Pythia (EleutherAI's 154-checkpoint research suite) and TinyLlama (1.1B, 3T tokens), not because they broke, but because they finished their job and retired gracefully — Pythia's value lies in the intermediate checkpoints it left for research; TinyLlama proved "small models can also eat tokens to saturation." They are "past-tense tools still in use," used here only as reference points.
Bias note: what this map omits
- GitHub-star-selected population: selection leans heavily toward English and Chinese circles (GitHub's star mechanism inherently favors large language markets), so projects from non-English, non-mainstream communities are easily missed — LLM-jp has a complete Japanese ecosystem and high openness but did not make the cut on stars and mindshare alone. This is a known gap in this survey. (Update): this gap has been closed by part 7 — the two national-scale cases, Apertus and LLM-jp, are now part of the series.
- Retired cases are only research-oriented Pythia/TinyLlama: "retired" here means "finished the job and got overtaken," not failed. Pythia's 154 checkpoints remain tools for studying learning dynamics; TinyLlama delivered the experiment "a 1B model trained on 3T tokens." Including them shows that obsolescence in this category usually means someone did something to completion.
- Architecturally one-sided: every selection is a Transformer. RWKV and Mamba-style non-attention sequence models were once hot alternative paths but aren't part of the "fully open pipeline" selection here (or the main toolchains didn't follow) — for alternatives, CS336: Attention, MoE, and Mamba on this site is an existing match.
The arc (11 posts)
$0.4 ─────────────────────────────→ 65B (hundreds of thousands of dollars)
teaching / readability ────────→ product / reproducibility
English → Chinese → academic data-efficiency ──→ industrial transparency
| order | Article | Main thread |
|---|---|---|
| 0 | This introduction | selection criteria, cost spectrum, bias |
| 1 | MiniMind: train an LLM from scratch for $0.4 (published) | full-pipeline teaching at the $0.4 grade |
| 2 | Karpathy: nanochat, nanoGPT, and llm.c | minimalism and the time-to-GPT-2 race |
| 3 | Chinese community small-model training | data-first floor experience for Chinese |
| 4 | YuLan-Mini: data-efficient pretraining | 1.08T vs larger budgets: recipe and ablations |
| 5 | OLMo 3 and LLM360: fully open pretraining | checkpoint-grade transparency and full reproducibility |
| 6 | When to train an LLM from scratch | decision framework: fine-tuning vs RAG, and when NOT to |
| 7 | National-team training: Apertus and LLM-jp | language sovereignty and the compliance route |
| 8 | Efficiency and edge: OpenELM and MiniCPM | per-parameter performance and multimodal deployment |
| 9 | The from-scratch framework: LitGPT | abstraction-free from-scratch scaffolding |
| 10 | Running MiniMind on RunPod | the only hands-on post: from renting a machine to chatting |
How to read this
- Hands-on readers: parts 1 (MiniMind) → 2 (Karpathy) → 3 (Chinese community). Run the README once and you will have first-hand experience with training "your own" model from scratch.
- Research readers: parts 4 → 5. For a solid theoretical base, first read the CS336 overview — the reference course of this series — then come back for the cost and openness reality.
- Decision-makers / budget holders: read part 6's decision framework first, then backfill the cases you need.
- Policy / compliance angle: part 7. How non-English communities trade national-scale collaboration and data governance for sovereignty and legitimacy, with RWKV as the architecture contrast.
- Efficiency / deployment angle: part 8. If you want to train from scratch under tight parameter budgets or for multimodal edge scenarios, OpenELM and MiniCPM are the loadout.
- Framework angle: part 9. If you want mature tooling for a from-scratch rewrite instead of hand-writing every line, LitGPT is the entry point.
Each part is self-contained, but the arc's order follows the graduation of cost magnitude and data complexity; following it is the least tiring path.
Bottom line
The two ends of this spectrum answer different questions: MiniMind proves "cheap can teach," OLMo 3 / LLM360 prove "expensive can verify" — the common denominator is openness, just with different objects (code vs data + logs). The first published part is MiniMind; the rest climb the cost ladder, and the last part re-examines "when not to spend this money at all." The site's CS336 series and OLMo: full openness give you the theoretical base and the previous generation's full picture; Marin's 535B hero run shows another viable route for an individual pushing the limit. Any order works, but we suggest starting with MiniMind — it's the only one you can start on tonight.
References
- MiniMind GitHub
- karpathy/nanochat GitHub
- karpathy/llm.c
- Llama-Factory
- YuLan-Mini GitHub (RUC-GSAI)
- OLMo GitHub (AI2)
- Olmo-3-1125-32B model card (Hugging Face)
- LLM360 K2 training code (k2-train)
- SmolLM3-3B model card (Hugging Face)
- TinyLlama GitHub (jzhang38)
- Pythia GitHub (EleutherAI)
- baby-llama2-chinese GitHub
- ChatLM-mini-Chinese GitHub
- Steel-LLM GitHub
Loading...