Train an LLM From Scratch in 2 Hours for $0.40: What MiniMind Teaches Developers
Train an LLM From Scratch in 2 Hours for $0.40: What MiniMind Teaches Developers
MiniMind is an open-source project that trains a 64-million-parameter language model from random weights on a single consumer GPU. It won't replace ChatGPT, but that's not the point.
A 64-million-parameter language model is, by any production standard, tiny. Frontier models such as GPT-4 are generally believed to be orders of magnitude larger. Llama 3's tokenizer vocabulary alone is twenty times larger than MiniMind's entire token set. So why has a project that trains a model this small accumulated nearly 70,000 GitHub stars and landed on GitHub's trending page?
Because MiniMind doesn't promise capability. It promises comprehension. The project gives any developer with access to a rented GPU — or even just a CPU — a complete, readable pipeline for building a language model from nothing: tokenizer training, pretraining on raw text, supervised fine-tuning, and reinforcement learning from human preferences. MiniMind trains a 64M-parameter model on one RTX 3090 in about 2.3 hours for 3 yuan, roughly $0.40 at current exchange rates, as ClaudeGPT Si noted in its breakdown. The result is a model that can hold a basic conversation. The real product is the education.
What MiniMind actually is
MiniMind is an Apache 2.0-licensed repository maintained by a solo developer, jingyaogong, as a side project. Its GitHub README frames the motivation bluntly: most people who claim to be "training" language models are really just fine-tuning someone else's work with LoRA adapters. That's useful, but it's the equivalent of teaching Newton how to use a smartphone — interesting, not fundamental.
The project's architecture is a standard transformer stack: 8 layers, each 768 dimensions wide, with 8 query heads sharing 4 key-value heads (a technique known as grouped-query attention, which reduces memory use during inference by letting multiple query heads share the same key-value projections). A mixture-of-experts variant adds 4 experts per layer. The vocabulary is deliberately small at 6,400 tokens, compared to 128,000 for Llama 3 or 151,643 for Qwen2, as documented in the README. That compression is a conscious design choice. In a 64M-parameter budget, a large vocabulary would consume most of the model's capacity just in its embedding and output layers.
The "2 hours" claim comes with fine print the author doesn't hide. Two hours is the measured time for one epoch of the SFT stage on a single RTX 3090, AI Frontier Post verified in a hands-on tutorial, with ¥3 as the rental cost at roughly ¥1.3 per hour. Pretraining — the stage where the model learns language from raw text — takes longer. The sources do not give a total time for the full pipeline, so the headline figure should be read as the SFT stage only, not an end-to-end estimate.
The released MiniMind-3 weights clock in at 122 MB. You can download them, chat with the model, and then retrain the whole thing yourself to see exactly how the weights got there.
The gap between toy-scale and production
It would be irresponsible to discuss MiniMind without being direct about what 64 million parameters can and cannot do. This model will not write reliable code. It will not summarize legal documents accurately. It will not compete with any model you'd actually deploy in a product.
For scale, consider nanochat, Andrej Karpathy's parallel effort to build an LLM from scratch. It targets GPT-2-level performance and requires 8 H100 GPUs at a cost of about $48, ClaudeGPT Si reported. That's still cheap by industry standards, but it's two orders of magnitude more expensive than MiniMind, and the resulting model is still far below what any frontier lab ships today.
The cost curve between these two projects illustrates an important reality about LLM training: capability doesn't scale linearly with compute. Going from a model that can string together coherent sentences to one that can reason about multi-step problems requires exponentially more data, compute, and engineering. MiniMind sits at the very bottom of that curve, where the learning-per-dollar ratio is highest for the developer, even if the model-capability-per-dollar ratio is lowest.
What developer autonomy actually means here
The word "democratization" gets thrown around a lot in AI circles, usually without much substance. MiniMind earns a more specific claim: it gives individual developers the ability to understand, not just use, the full LLM training stack.
This matters because the dominant tools for working with language models — Hugging Face's Transformers, TRL, PEFT — are designed for productivity, not pedagogy. As the MiniMind README puts it, you can complete the entire flow of loading a model, loading a dataset, running inference, and performing reinforcement learning in about ten lines of code. That abstraction is powerful, but it also isolates developers from the mechanics underneath.
MiniMind strips away those abstractions. Every training script is plain PyTorch. Checkpoint saving, multi-GPU training via DDP, tokenizer construction — it's all exposed. The project even includes a tokenizer training script, though the author advises against retraining it because changing the vocabulary breaks compatibility with released weights, datasets, and evaluation metrics.
The practical value here isn't building a production model. It's building the intuition to make better decisions when working with production models. A developer who has trained a transformer from random initialization understands, viscerally, why learning rate schedules matter, why tokenizer choice affects everything downstream, and why evaluation metrics like perplexity can mislead when comparing models with different vocabularies. The README notes that bits-per-byte (BPB) is a more reliable cross-tokenizer comparison metric than perplexity — a nuance that matters in practice but rarely appears in introductory materials.
Where a 64M model is actually useful
Despite its limitations, a model this small has genuine applications beyond education.
Use cases
Embedded and edge inference. At 122 MB, MiniMind is small enough to run on a low-end phone or similar edge hardware. For constrained-vocabulary tasks — simple command parsing, template-based text generation, basic classification — a tiny model that runs locally with zero latency and zero API cost has real utility.
Research prototyping. Testing a new training technique on a 7-billion-parameter model takes days and hundreds of dollars. Testing the same idea on a 64M model takes minutes. Small models are a common way to test ideas cheaply before scaling up.
Privacy-sensitive applications. A model that never leaves the device never leaks data. For scenarios where even encrypted API calls are unacceptable, local inference on a minimal model may be the only option.
Understanding model internals. Recent work on model surgery — like the LLM Circuit Finder project, which found that duplicating specific transformer layers can boost reasoning performance without any training — depends on understanding how transformers organize themselves internally. Small, fully transparent models like MiniMind make this kind of experimentation accessible on consumer hardware.
Where a 64M model is not useful: anything requiring factual reliability, nuanced reasoning, long-context understanding, or multilingual fluency. These capabilities require parameter counts, training data volumes, and alignment work that are orders of magnitude beyond MiniMind's scope.
The broader context: who controls model training matters
MiniMind's transparent, small-scale approach also arrives at a moment when the legal and economic frameworks around LLM training are still being contested. As TechCrunch reported, the Trump administration filed a brief in The New York Times' lawsuit against OpenAI, arguing that restricting the use of copyrighted material for LLM training would hinder American AI competitiveness. That case concerns frontier models trained on massive datasets scraped from the open web. MiniMind operates at a very different scale, though the sources I reviewed do not address its own training-data licensing.
But the legal uncertainty around training data reinforces why developer-level understanding of the training pipeline matters. If copyright rulings eventually restrict what data can be used for training, organizations may need to build models on proprietary or licensed datasets. Developers who understand the full pipeline — not just the fine-tuning layer — will be the ones capable of doing that work.
What comes next for developers who train an LLM from scratch
MiniMind is not a product. It's a curriculum disguised as a repository. Its value is measured not in benchmark scores but in the number of developers who finish the pipeline and understand what happened at each step.
The project points toward a future where training a small language model is a standard developer skill, like writing a web server or building a compiler. Not because every developer needs to train their own model, but because understanding the process changes how you think about the models you use. The gap between MiniMind's 64 million parameters and GPT-4's capabilities is vast. The gap between a developer who has trained a model from scratch and one who hasn't is arguably more consequential.
About Ownlife
Ownlife is a developer-focused blog covering web development, software engineering, and tech industry insights. We write practical guides and deep dives to help developers level up their skills and stay ahead of the curve.
🌐 Explore more at www.ownlife.dev
Ownlife is a Becalmed Media production. Thanks for reading! Follow for more dev content.