Skip to content
AIRepoHub

minimind

by jingyaogong

Project that shows how to train your own small 64M language model from scratch in about two hours.

Developer ToolsPythonApache 2.0 license
Stars
70,490
stars
Forks
9.2k
forks
Last push
2 days ago
Activity
Active
minimind: quick start
# Get the code$ git clone --depth 1 https://github.com/jingyaogong/minimind
cd minimind && pip install -r requirements.txt# Chat with the released model$ git clone https://huggingface.co/jingyaogong/minimind-3
python eval_llm.py --load_from ./minimind-3

Commands from the project's README. Run them after installing (see below).

Overview

Understand minimind in 60 seconds

What it does
MiniMind is an open-source project for training a tiny language model (about 64M parameters) completely from scratch on a personal GPU. It includes the full pipeline, from tokenizer and pretraining to fine-tuning, reinforcement learning and tool use, written in plain PyTorch.
The problem it solves
Libraries like transformers and trl hide how LLMs are actually built behind a few lines of code. MiniMind implements every stage itself so you can read, run and change it, and the README says a basic model can be trained in about 2 hours on one RTX 3090.
Why choose it
Choose it as a hands-on, reproducible tutorial for building an LLM. The models are deliberately tiny, so they're for learning, not production use.
Who should use it
  • Learners who want to understand LLM training end to end
  • Students with a single consumer GPU
  • Researchers prototyping training ideas cheaply
  • Readers of Chinese or English
Setup difficulty

You'll need:

  • Python 3.10 (the author used 3.10.16)
  • PyTorch, ideally with an NVIDIA GPU (CPU and MPS work but are slower)
  • Git

How minimind works

MiniMind provides a Dense and MoE model architecture aligned with the Qwen3 ecosystem, plus tokenizer training code. Training stages cover pretraining, supervised fine-tuning, LoRA, DPO, reinforcement learning from AI feedback (PPO, GRPO, CISPO), tool use, agentic RL, adaptive thinking and distillation, all implemented from scratch.

Datasets for every stage are published, and for a quick start you only need two small files to reproduce the MiniMind Zero chat model. Training supports single or multi-GPU (DDP, DeepSpeed), wandb or swanlab logging and resuming from checkpoints.

Trained models work with transformers, llama.cpp, vLLM and Ollama, and the project includes an OpenAI-compatible API server and a Streamlit chat web UI. The README's 2-hour and RMB 3 figures refer to one epoch of SFT on a single RTX 3090.

Features

Key features

Train from scratch

About 64M parameters on a personal GPU.

Full pipeline

Pretraining, SFT, LoRA, DPO, PPO, GRPO and distillation.

Plain PyTorch

Core algorithms without high-level wrappers.

Open datasets

Data for every training stage.

Works with common tools

transformers, llama.cpp, vLLM and Ollama.

Chat UI and API

Streamlit web demo and OpenAI-compatible server.

Strengths

  • Excellent for learning how LLMs are built
  • Cheap and fast to reproduce
  • Covers modern training methods
  • Apache-2.0 licensed

Limitations

  • Tiny models; not capable enough for real-world tasks
  • Fastest with an NVIDIA GPU
  • Main README is Chinese; English README is available

Practical use cases

Learn LLM training

Train MiniMind Zero yourself and inspect each stage.

Experiment with RL

Try GRPO or DPO on a small model.

Classroom demos

Show a full training run in a few hours.

Installation

Install minimind

Based on official documentation

Commands come from MiniMind's README. AIRepoHub hasn't run them yet. View source

Prerequisites

  • Python 3.10
  • PyTorch
  • A GPU recommended

Supported systems

  • Linux
  • Windows
  • macOS
  1. 1

    Clone and install

    Shell
    git clone --depth 1 https://github.com/jingyaogong/minimindcd minimind && pip install -r requirements.txt
  2. 2

    Check PyTorch sees your GPU

    Shell
    python -c "import torch; print(torch.cuda.is_available())"
  1. 1

    Run the released model

    Shell
    ollama run jingyaogong/minimind-3

Configuration and API keys

SettingWhat it's for

First run

  1. 1

    Download the model and chat in the terminal

    Shell
    git clone https://huggingface.co/jingyaogong/minimind-3python eval_llm.py --load_from ./minimind-3

minimind's documentation doesn't include sample output, so we don't show any. Expect the results in your terminal.

Your first project

Train MiniMind Zero from scratch

Pretrain and fine-tune a tiny chat model on your own GPU.

Before you start

  • The repository cloned and requirements installed
  • A GPU (an RTX 3090 was used for the README's timing)
  1. 1

    Download the data

    Put pretrain_t2t_mini.jsonl and sft_t2t_mini.jsonl from the project's ModelScope dataset into ./dataset.

  2. 2

    Pretrain

    Produces out/pretrain_*.pth.

    Shell
    cd trainer && python train_pretrain.py
  3. 3

    Fine-tune for chat

    Produces out/full_sft_*.pth.

    Shell
    cd trainer && python train_full_sft.py
  4. 4

    Test it

    Shell
    python eval_llm.py --weight full_sft

What to expect

A small chat model you trained yourself, which you can talk to in the terminal.

Next steps

  • Try LoRA or DPO training
  • Run the Streamlit web demo
  • Serve it with the OpenAI-compatible API

Costs and requirements

What it costs to run

License
Apache-2.0.Free
Software and data
Free.Free
Compute
Your own GPU or rented GPU time; the README cites about RMB 3 for one SFT epoch on a rented 3090.Depends

Troubleshooting

Common setup issues

Training is very slow

Check torch.cuda.is_available(); CPU and MPS work but are much slower.

Source: README_en.md

Training was interrupted

Add --from_resume 1 to resume from the last checkpoint.

Source: README_en.md

Web demo can't find the model

Copy the transformers-format model folder into ./scripts/ first, for example cp -r minimind-3 ./scripts/minimind-3.

Source: README_en.md

Alternatives

Similar AI repositories