Train a Small Language Model From Scratch for 3 RMB

Train a Small Language Model From Scratch for 3 RMB

MiniMind trains a 64M-parameter small language model from scratch for a stated 3 RMB and a stated 2 hours. And the whole implementation is a repository you can read line by line. The project, built by Jingyao Gong and hosted at jingyaogong/minimind, reconstructs its core algorithms in native PyTorch instead of leaning on third-party abstractions. If you have ever wanted to understand what actually happens between "data goes in" and "text comes out," this is the cheapest ticket anyone is currently selling. Those numbers are the project's own, from its README. So treat them as claims to verify rather than results I ran myself.

The stated purpose is education, not product.

Quoting the README directly: "the goal of this project is to lower the learning threshold for LLMs, allowing everyone to start by understanding each line of code.

And to train a very small language model from scratch, not just performing inference!" A related fork's changelog dates the first open-source release to 2024-08-27.

And the project has since been mirrored across multiple GitHub repositories.

There is an English README, and the entry point is one command: `git clone https://github.com/jingyaogong/minimind.git`.

The Claims, and the Small Print That Matters

The headline numbers are consistent across mirrors: roughly 64 million parameters, trained entirely from scratch, at a cost of about 3 RMB and a training time of about 2 hours. That cost figure is so small it reads like a typo next to any cloud invoice you have paid this year. But pay attention to the variance, because it tells you what kind of project this is. A related implementation describes its smaller variant as 26.88M parameters trained in 3 hours, not 2.

Two mirrors, two different times, two distinct sizes.

That is not a scandal, it is the texture of a project that people actually copy and modify. Your own numbers will differ again depending on what you run it on. Trust the shape of the claim, not the specific figure.

The line in the README that matters most to an operator is this one: "All core algorithm code is reconstructed from scratch using native PyTorch! It does not rely on abstract interfaces provided by third-party libraries." Abstractions are where debugging goes to die. When a fine-tune silently degrades three weeks after you shipped it, the answer usually lives below the interface everyone told you not to worry about. This project hands you the basement keys.

The Model Table Nobody in Marketing Would Print

A related implementation's model table lays out the family. And it contains the most honest piece of marketing copy I have read all year: subjective quality scores, printed by the project itself, starting at 50 out of 100.

| Model | Parameters | Tokenizer entries | Inference memory | Released | Subjective score | |---|---|---|---|---|---| | minimind-v1-small | 26M | 6,400 | 0.5 GB | 2024.08.28 | 50/100 | | MiniMind-V1 | 108M | 6,400 | 1.0 GB | 2024.09.01 | 60/100 | | minimind-v1-moe | 4x26M | 6,400 | 1.0 GB | 2024.09.17 | 55/100 |

Read the progression the way an engineer would. Going from 26M to 108M parameters bought ten points of subjective score, from 50 to 60. The mixture-of-experts build, four groups of 26M experts, landed at 55, between the two. Meanwhile the model that runs in 0.5 GB of inference memory is the one you could actually put on modest hardware you already own.

No vendor prints a 50/100 next to its own model. That number is the tell that this is a teaching artifact, not a pitch.

What 6,400 Tokenizer Entries Teach You

Every variant in that table shares the same 6,400-entry tokenizer. And that shared ceiling is the real lesson for anyone running small models in a business.

When a compact model mangles your domain vocabulary, the tokenizer is the first suspect, not the parameter count. A 6,400-entry vocabulary is tiny by any modern standard, which is a big part of why the subjective scores sit where they sit.

Here is why that changes how you work. Most operators treat "the model doesn't know our jargon" as a reason to buy a bigger model. After you have watched a from-scratch build assemble language from a vocabulary you can count, you start asking a separate question: is this a knowledge problem, a parameter problem, or a tokenization problem? Those three failures look identical from the outside and have wildly other price tags. MiniMind is two hours of inoculation against misdiagnosing them.

Should You Actually Train From Scratch?

For a shippable assistant, no, and the project's own scorecard says so. A model rated 60 out of 100 subjectively is not carrying your customer support. Fine-tune a pre-trained model for that job, prompt it well, and move on. The decision framework I would apply looks like this:

- Money: about 3 RMB, stated by the project. Fine-tuning pre-trained models costs more but starts from competence. - Time: about 2 hours, stated by the project. Fine-tuning takes longer but produces something deployable. - Performance: 50 to 60 out of 100, subjectively rated by the project's own table. From-scratch loses here, openly. - Understanding: you can read every line, which is the stated goal. No pre-trained model gives you this at any price.

Train from scratch when the deliverable is your own comprehension: what a training loop does, what a tokenizer constrains, what "trained on" actually describes. Fine-tune when the deliverable is a model that answers customers. Mixing those two goals up is how budgets die.

What To Do With Two Hours

Clone the repository, open the core training code. And read one file end to end before your next model decision. The README quotes the training time at about 2 hours and the cost at about 3 RMB. And even if your run lands nowhere near those numbers, the reading costs you nothing but attention. Watch a model learn from nothing, once, on purpose.

After that, the phrase "trained on" in a vendor pitch stops being magic. You will know to ask what tokenizer, what data, what size, and who assigned the score. Most pitches fall apart under exactly those four questions.

The full project lives at jingyaogong/minimind, with an English README and mirrors across GitHub. Spend one evening reading it, then check whether model training still intimidates you. If this teardown earned its space, I write one of these every week about tools that teach instead of tools that pitch. And that is where the next one will land.