minimind
Train a 64M-parameter LLM in 2 hours on a single GPU
Replaces Databricks, Google Cloud Vertex Ai, Amazon Sagemaker, Azure Machine Learning, Together Ai

Who it's for
minimind's implementation-first design makes every component inspectable: the attention mechanism, tokenizer training, and RLHF reward model are each written from scratch. Researchers can compare GRPO versus PPO reward shaping directly in the codebase and observe effects without framework interference.
You need a production-grade model for serving end users. minimind produces a research-scale 64M-parameter model suitable for studying training dynamics, not for handling real user queries.
The project covers a full curriculum in one repository: tokenizer construction, pretraining data formatting, SFT, and alignment. The hardware bar is low; a single rented GPU completes the full pipeline in one session at a cost roughly equivalent to a coffee.
You need a working chatbot for a product. Starting from a pre-trained base model and fine-tuning is faster and produces a better result for deployment.
minimind's JSONL formats for pretraining and SFT are simple enough to replace with a custom domain corpus. The Agentic RL training script demonstrates multi-turn tool-use end to end, serving as a reference implementation for teams building task-specific agents.
Your team lacks GPU access or ML engineering bandwidth to adapt the training scripts. minimind provides no managed training path.
All three RLAIF algorithms share a decoupled rollout engine, making it practical to swap between them and observe behavioral differences on the same base model and dataset. The rlaif-mini dataset is included for quick experiments without downloading the full training set.
You need RLAIF at billion-parameter scale. minimind targets 64M models and has not been validated for large-scale training runs.
The problem
Learning how large language models actually work is harder than it should be. Most educational resources stop at fine-tuning pre-trained models through high-level library APIs, which hides the tokenizer, the pretraining loop, and the alignment stages behind abstractions. Building a model from scratch has historically required either access to expensive cloud GPU clusters or navigating large codebases that expose only managed training interfaces. For researchers and engineers who want to understand every layer of an LLM, from tokenizer vocabulary design through pretraining data formatting and RLAIF reward shaping, the gap between reading papers and running working code is significant. Cloud training platforms abstract away exactly the parts that matter for deep understanding, while consumer hardware has been assumed insufficient for meaningful LLM experiments at reasonable cost.
How it works
Covers tokenizer training, pretraining, supervised fine-tuning (SFT), LoRA, DPO, and RLAIF including PPO, GRPO, and CISPO, plus a dedicated Agentic RL script for multi-turn tool-use training. All stages are implemented directly in PyTorch without wrapping transformers, trl, or peft, making every training step readable and modifiable.
The benchmark configuration trains the 64M Dense model in approximately two hours on one NVIDIA RTX 3090 using the mini datasets (pretrain_t2t_mini.jsonl and sft_t2t_mini.jsonl). Multi-card training via DDP and DeepSpeed is also supported for faster runs or larger parameter budgets.
serve_openai_api.py exposes the trained model through an OpenAI-compatible endpoint supporting reasoning_content, tool_calls, and open_thinking. This lets any chat interface that accepts the OpenAI protocol connect directly to the locally trained model, including FastGPT, Open-WebUI, and Dify.
Native PyTorch implementations of PPO, GRPO, and CISPO share a decoupled rollout engine, making it practical to swap between algorithms on the same dataset. A separate Agentic RL training script (train_agent.py) supports multi-turn tool-use scenarios. The rlaif-mini dataset is included for quick experiments.
Trained models export to the transformers checkpoint format and run with llama.cpp, vLLM, ollama, and SGLang. The LoRA weight merge script (scripts/convert_model.py) produces a merged checkpoint compatible with all these inference backends. Pre-trained weights are published on HuggingFace and ModelScope.
All training scripts support checkpoint saving and automatic resume, preserving model weights, optimizer state, and training step. Recovery works across different GPU counts, and wandb or SwanLab run IDs are preserved across resumes to keep training curves continuous.
Features
- Full LLM training pipeline in native PyTorch
- Single consumer GPU training in approximately two hours
- OpenAI-compatible API server for the trained model
- RLAIF and Agentic RL training with PPO, GRPO, and CISPO
- Export to major inference frameworks
- Checkpoint resume with cross-GPU recovery
How to install
Install Python dependencies after cloning the repository, then run training or inference scripts.
git clone --depth 1 https://github.com/jingyaogong/minimind
cd minimind
pip install -r requirements.txtRecommended for this setup
Strengths
- No cloud subscription or per-compute-hour billing: The entire pipeline runs on a GPU you own or rent by the hour. There are no cloud accounts, no API keys, and no per-token charges. Unlike Amazon SageMaker AI or Google Cloud Vertex AI, which bill per compute hour and lock training runs to their infrastructure, minimind runs on any NVIDIA GPU with an internet connection or offline.
- Every training step readable in plain Python: DPO, LoRA, and RLAIF are each implemented from scratch without wrapping trl or peft. You can read the loss function, modify the reward model, or add a custom training stage without reverse-engineering a framework. This level of transparency is not achievable with managed training services.
- Dense and Mixture of Experts architectures included: The repository ships both a Dense Transformer (64M parameters) and a Mixture of Experts variant (198M total, 64M active per token), both aligned with the Qwen3 and Qwen3-MoE architecture. Both use RMSNorm, SwiGLU, RoPE with YaRN length extrapolation, and grouped-query attention.
- Actively maintained with over 56,000 GitHub stars: minimind-3 released in April 2026 with a full architecture refresh aligned to Qwen3, a new native Agentic RL training script, and an updated tokenizer. The repo received pushes as recently as August 2026 and has over 56,000 GitHub stars and 7,300 forks, reflecting a large contributor community.
Trade-offs
- Models are for learning, not production deployment: The 64M Dense model that minimind trains in two hours produces noticeably weaker outputs than even small production models like Qwen3-1.7B or Llama-3.2-1B. minimind is designed to teach the training process; the resulting model is a proof of concept suitable for studying LLM behavior, not for handling real user queries at scale.
- Practical training requires a dedicated NVIDIA GPU: Benchmark times and the stated cost figures assume a single NVIDIA RTX 3090 with 24GB VRAM. CPU and Apple MPS training are supported but the README notes significant speed and compatibility differences. Meaningful pretraining on CPU alone is not practical for most experiments.
- Primary documentation is in Chinese: The main README and most inline code comments in the training scripts are written in Chinese. An English README (README_en.md) exists but may lag the Chinese version after major updates, which means English-only readers may miss context around dataset choices and training configuration options.
Tech stack
FAQ
The pretraining plus SFT pipeline runs in approximately two hours on a single NVIDIA RTX 3090 using the mini datasets (pretrain_t2t_mini.jsonl and sft_t2t_mini.jsonl). Full dataset training takes longer. Times assume CUDA is available; CPU training is supported but significantly slower.
An NVIDIA GPU with 24GB VRAM, such as an RTX 3090, covers the recommended configuration for the benchmark training times. Multi-GPU training via DDP and DeepSpeed is supported for faster runs. CPU and Apple MPS (M-series Mac) training are possible but the README notes significant speed differences.
No. The 64M-parameter models minimind trains are designed to demonstrate and teach the training pipeline, not to serve end users. For production deployment, starting from a larger pre-trained open source model such as Qwen3 or Llama and fine-tuning it is the appropriate approach.
Yes. Trained models export to the transformers checkpoint format and run with ollama, vLLM, llama.cpp, and SGLang. minimind also ships a serve_openai_api.py server that accepts requests from any client using the OpenAI API protocol, including Open-WebUI and FastGPT.
Yes. The MiniMind-3-MoE variant uses 198M total parameters with 64M active parameters per token, following the Qwen3-MoE architecture. The MoE training pipeline is included alongside the Dense model scripts in the same repository. The MoE model uses approximately 1.0GB of GPU memory.