Train a 64M Language Model From Scratch in Two Hours (Yes, Really)
You've probably fine-tuned a model or two by now. Maybe you've even run through a LoRA tutorial and felt that small thrill of watching loss go down. But somewhere in the back of your mind, there's a nagging question: what actually happens between a pile of text files and a model that can hold a conversation? MiniMind is a project that answers that question by letting you build the whole thing yourself—a 64M-parameter language model, trained from scratch, on a single GPU, for about the cost of a coffee.
What It Does
MiniMind is an open-source project that trains a tiny language model from zero. The mainline model is roughly 1/2700th the size of GPT-3, which means it fits comfortably on ordinary personal hardware—the README's benchmark runs on a single NVIDIA 3090. The "2 hours" refers to one epoch of the SFT stage on that card, and the "3 yuan" (about three bucks) is the corresponding GPU rental cost.
What sets it apart is scope. This isn't just a training script. The project open-sources the full pipeline: the minimalist model architecture, data cleaning, pretraining, supervised fine-tuning, LoRA, RLHF via DPO, RLAIF with PPO/GRPO/CISPO, tool use, agentic RL, adaptive reasoning, and model distillation. There's also a family of spin-off variants—MiniMind-V for vision, MiniMind-O for multimodal Omni, MiniMind-dLM for diffusion language models, and MiniMind-Linear for linear models—documented in the project's Discussions.
Every core algorithm is implemented in native PyTorch from scratch. No transformers, no trl, no peft doing the heavy lifting behind an abstraction layer.
Why It's Cool
-
The abstractions are gone, on purpose. The README makes a sharp point: with modern libraries, you can do "load model + load dataset + inference + RL training" in about a dozen lines. That's convenient, but it also puts a wall between you and the actual mechanics. MiniMind tears that wall down. If you've ever wondered what DPO is doing under the hood, here's the code, plainly written.
-
It's a complete curriculum, not a demo. Most "train your own LLM" repos stop at pretraining and call it a day. This one walks through the entire modern LLM lifecycle—pretraining, SFT, preference optimization, reinforcement learning, tool use, distillation—each as a distinct stage you can run and inspect.
-
The cost claim is refreshingly honest. The README explicitly defines its numbers: 2 hours means one SFT epoch on a 3090, and 3 yuan means the rental cost for that window. It's the kind of precision you don't always get from projects making bold claims.
-
It's framed as a tutorial, not just a codebase. The author describes it as both a full-stage reproduction project and a teaching resource for people getting into LLMs. That framing shows up in the design—the goal is a reproducible, understandable, extensible starting point.
-
The variants suggest a real research playground. Vision, multimodal, diffusion, and linear architectures branching off a shared minimal base is a nice signal that this is a living project rather than a one-off writeup.
How to Try It
- Head to the repository and read the README (there's an English version linked at the top if you need it).
- Check the hardware requirements—you'll want a reasonably modern GPU. The reference setup is a single 3090, but the model is small enough that lesser cards are worth exploring.
- Follow the setup and training instructions in the repo. The pipeline is staged, so you can start with pretraining and work your way through SFT and beyond at your own pace.
- If you just want to see what the result looks like before committing, there's an online demo on ModelScope and a video walkthrough on Bilibili.
- Pretrained weights and related assets are hosted on Hugging Face and ModelScope.
The project is Apache 2.0 licensed and free to use. If you find it useful, the README notes that sponsorship is welcome but entirely voluntary and buys no special treatment.
Final Thoughts
MiniMind won't give you a model that competes with anything you'd actually deploy—64M parameters is a teaching scale, and that's the point. What it gives you is something rarer: a full, legible path from raw data to a working chat model, with every stage written in code you can read. If you've been meaning to move past fine-tuning and actually understand how these systems are built, this is one of the more complete on-ramps out there. The tagline says "大道至简"—the great way is simple—and for once, that's not just a slogan.
Follow @githubprojects for more developer tools and open source projects.