Repo of the Day
jingyaogong/minimind
Published: Nov 30, 2026
Open repository ↗🧠 Train a 64M-parameter LLM from scratch in just 2h!
Summary
MiniMind is a Python repository that covers the full lifecycle of building a small language model — pretraining, SFT, LoRA, DPO, RLAIF (PPO/GRPO/CISPO), Tool Use, Agentic RL, and distillation — with the core algorithms written directly in PyTorch rather than hidden behind high-level framework abstractions. The headline target is a ~64M-parameter dense model that the README says can be trained from scratch in roughly 2 hours on a single NVIDIA 3090 (the SFT stage, 1 epoch, about ¥3 of rented GPU time), with a 198M-A64M MoE variant alongside it. The repo is Apache-2.0 licensed and ships both checkpoints and the training datasets.
What it is useful for
- Learning how LLM training actually works. The README frames the project as both a full-stage reproduction and a tutorial, so it suits engineers who want to read the training loop rather than call a wrapper API.
- Producing a small chat model on modest hardware.
minimind-3is a decoder-only transformer with 8 layers,d_model=768, a 6,400-token vocab, andmax_position_embeddings=32768, using pre-norm + RMSNorm, SwiGLU, and RoPE, aligned with the Qwen3 ecosystem for easier conversion. - Serving and integration. The README documents compatibility with
transformers,trl,peft,llama.cpp,vllm,ollama, and Llama-Factory, plus an OpenAI-protocol server (serve_openai_api.py) exposingreasoning_content,tool_calls, andopen_thinking, and a Streamlit chat UI (web_demo.py). - Tool and agent workflows. Tool-call data is mixed into the main SFT sets, and
train_agent.pyruns multi-turn tool-use GRPO/CISPO. - Measurement. Evaluation on C-Eval, C-MMLU, and OpenBookQA is supported, along with YaRN long-context extrapolation.
Documented limits: the README's own sample conversation notes that factual knowledge and generalization remain limited; the 6,400-token tokenizer has weaker encode/decode efficiency than Qwen2 or GLM tokenizers; the current MoE implementation is roughly 50% slower than dense at 4 experts / top-1 and gets much slower as experts grow without fused kernels; and max_seq_len trades padding waste against truncation of semantics. Models released before the 2025-04-26 update can no longer be loaded directly for inference.
How engineers can use it
Clone and install the documented dependencies:
git clone --depth 1 https://github.com/jingyaogong/minimind
cd minimind && pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
For inference, download a released checkpoint (modelscope download --model gongjy/minimind-3 --local_dir ./minimind-3) and run python eval_llm.py --load_from ./minimind-3; the optional web UI needs the model folder copied into ./scripts/ before streamlit run web_demo.py.
For training, place the downloaded files in ./dataset — pretrain_t2t_mini.jsonl and sft_t2t_mini.jsonl are enough for a quick reproduction — then run cd trainer && python train_pretrain.py followed by python train_full_sft.py, which write pretrain_*.pth and full_sft_*.pth into ./out. Add --from_resume 1 to restore from ./checkpoints/, use torchrun --nproc_per_node N train_xxx.py for multi-GPU runs, and --use_wandb for tracking (SwanLab is now the default visualizer).