Tag: PyTorch

  • MiniMind: Train Your Own 64M LLM in 2 Hours

    MiniMind: Train Your Own 64M LLM in 2 Hours

    The pitch is almost too good to believe: train your own large language model from scratch, in two hours, for 3 yuan — about 43 cents. No API key, no cloud subscription, no pre-trained weights to download. Just you, a GPU, and a repository with 67,000 stars.

    That repository is MiniMind, a Chinese open-source project by Jingyao Gong that has been quietly building since July 2024 and is now one of the most-starred AI projects on GitHub. The pitch is real. But the fine print matters, and to the project’s credit, it prints the fine print itself. This is a story about what “train your own LLM” actually means — and about a project that is unusually honest about where its own limits are.

    What MiniMind actually is

    MiniMind is not a model you download and chat with. It is the whole pipeline for building one, from nothing, in plain PyTorch. The repository covers the tokenizer and its training code, pretraining, supervised fine-tuning, LoRA, knowledge distillation, RLHF with DPO, RLAIF with PPO, GRPO, and CISPO, tool calling, agentic RL, adaptive thinking, and model conversion — and every core algorithm is implemented from scratch, in native PyTorch, without leaning on the high-level abstractions of frameworks like Transformers, TRL, or PEFT.

    That last point is the project’s whole philosophy, stated in the README in Chinese: most LLM tutorials stop at fine-tuning someone else’s model, and most frameworks hide the interesting parts behind ten lines of API calls. MiniMind wants you to read every line of code and understand what it does. “Building a plane from Lego yourself is far more exciting than sitting in first class,” the author writes — and the project is built around that idea.

    The numbers: Apache-2.0 license, created July 27, 2024, 437 commits, 2 releases, 2 tags, 32 open issues, 54 pull requests. The current mainline model is minimind-3, a 64-million-parameter dense model released April 1, 2026, alongside minimind-3-moe, a 198-million-parameter mixture-of-experts model with 64 million active parameters. Older models in the family run from 26 million to 145 million parameters. The structure is aligned with the Qwen3 ecosystem. Pretrained weights are published on Hugging Face (jingyaogong/minimind-3) and ModelScope, and there is an online demo on ModelScope if you just want to try the finished model before committing to the build.

    MiniMind README badges, including its #1 Repository of the Day award and Apache-2.0 license
    Screenshot: github.com/jingyaogong/minimind — the README’s badges, including its #1 Repository of the Day award, Apache-2.0 license, and the claim that started it all.

    The two-hour, 43-cent claim — read carefully

    Here is where most coverage of this project stops, and where the honest version starts. The README’s own training-cost table breaks the claim down precisely. On a single rented RTX 3090 at about ¥1.3 per hour, pretraining the small dataset takes about 1.21 hours (¥1.57) and supervised fine-tuning takes about 1.10 hours (¥1.43). Add them together: about 2.31 hours and about ¥3.0 — roughly $0.43 — for one epoch of each, producing what the project calls “MiniMind Zero,” a basic dialogue model trained from zero.

    That is the claim, and it is a real, measured, reproducible one. But notice what it is not. It is one epoch, on the small datasets, on a rented 3090. It is not the full pipeline — the tool-calling stage, the RLAIF stage, and the rest of the training chain each add roughly another hour. And it is not a capable model. The README’s own sample conversation with the Zero model shows it garbling an English answer into nonsense (“Introok’s the believeations of theument”), and the project says plainly, in its own words, that the Zero model’s factual knowledge and generalization “are still limited” and that it is best understood as proof that the training route works.

    None of that is a flaw. It is the point. A 64-million-parameter model is a toy by modern standards — the README notes it is about 1/2700th the size of GPT-3 — and nobody should expect it to answer questions well. What it does is let you watch a language model learn, from the first token to a model that talks, on hardware you can rent for the price of a coffee.

    What you get for your 43 cents

    The full pipeline is the real deliverable, and it is unusually complete. The training chain runs: pretrain, then full supervised fine-tuning, then optionally LoRA for cheap domain adaptation, distillation from a teacher model, DPO preference tuning, and RLAIF with PPO, GRPO, or CISPO — all with checkpoint resume, multi-GPU DDP support, and training visualization through SwanLab (the China-friendly WandB replacement the project defaults to). There is a Streamlit chat WebUI with thinking display and tool selection, an OpenAI-compatible API server so the model plugs into FastGPT or Open-WebUI, and inference through the usual suspects: Transformers, llama.cpp, vllm, SGLang, MNN, and Ollama, where ollama run jingyaogong/minimind-3 is all it takes to try the finished model.

    The project also supports evaluation on C-Eval, C-MMLU, and OpenBookQA, and RoPE long-text extrapolation through YaRN. And it keeps growing sideways: the README points to sibling projects for vision (MiniMind-V), multimodal Omni (MiniMind-O), a diffusion language model, and a linear-attention variant.

    How to start

    Step zero is two commands: clone the repo and install the dependencies. One note for readers outside China: the README’s install line points pip at an Aliyun mirror. It works fine, but you will probably want your own package index instead.

    MiniMind README Quick Start Step 0: clone the repo and install the dependencies
    Screenshot: github.com/jingyaogong/minimind — Step 0 of the Quick Start: clone the repo and install the dependencies. Note the Aliyun PyPI mirror in the install command; use your own package index outside China.

    From there, the path is: download the datasets from ModelScope into the dataset folder (the quick-start route needs only pretrain_t2t_mini.jsonl and sft_t2t_mini.jsonl), run python train_pretrain.py in the trainer directory, then python train_full_sft.py, then test the result with python eval_llm.py --weight full_sft. Every training script supports checkpoint resume with --from_resume 1, and multi-GPU runs use torchrun. If you would rather skip the training entirely, download the pretrained weights from Hugging Face or ModelScope and run the CLI, the WebUI, or Ollama.

    One practical warning: the main documentation is in Chinese. An English README exists (README_en.md), and the code comments and command names are in English, but the deep explanations — the training chapters, the RL theory, the experiment notes — are Chinese-first. Machine translation gets you most of the way, but budget some patience if you don’t read Chinese.

    Who this is for, and who should skip it

    MiniMind is for anyone who has ever wondered what actually happens inside a language model and wanted to see it happen on their own machine. Students, tinkerers, and engineers who learn by building will get more from two hours with this repo than from a month of API calls. It is also the rare project that teaches the whole modern training stack — pretraining, SFT, RLHF, RLAIF, tool use, agentic RL — in one place, in readable code, for free.

    It is not for anyone who wants a useful assistant. If you need a model that answers questions well, download Qwen or Gemma and skip the training entirely. It is not for anyone without a GPU, either: CPU and Apple Silicon runs are possible, but the README is clear that training speed and compatibility drop sharply. And it is not a shortcut to building a competitive model — 64 million parameters will never compete with the billion-parameter models, and the project never claims otherwise.

    The catch, stated plainly

    The honest caveat is the one the project states itself: the model you train in two hours is a proof of concept, not a product. Its knowledge is thin, its English is shaky, and its value is in the code you read and the process you run, not in the weights you end up with. The benchmarks exist, but they are not the point — the point is that, for about 43 cents of rented GPU time, you can go from zero to a working language model and understand every step in between. In a field where the real models cost hundreds of millions of dollars to train and arrive as black boxes, that is a genuinely useful thing to be able to do.

    Also today: Gemini 4 Neon costs $3/$15 per million tokens — but Carbon is cheaper until Dec 1 — and NVIDIA’s RTX Spark desktops put the 128GB N1X chip in a mini PC from $4,499.

    Related: Qwen Code, the free AI coding agent for your terminal — AG-UI, the free standard connecting agents to apps — Google Skills, 186 free agent skills for Google Cloud — last30days, the free AI skill that researches any topic.

    Screenshot credit: all images in this article are screenshots of github.com/jingyaogong/minimind, captured November 20, 2026.