MiniMind
MiniMind Features and Quickstart: From a Released Checkpoint to a Tiny Training Run
A source-backed MiniMind walkthrough for inference demos, native PyTorch training stages, OpenAI-compatible serving, and reproducible evaluation.

What you will learn
- Validate MiniMind inference and training prerequisites
- Run and distinguish core training stages
- Serve and evaluate a tiny checkpoint reproducibly
Before you start
- Basic Git and command-line usage
- Comfort reading a project README
You can explain the project, run its documented first step, and decide what to verify before adopting it.
Key takeaways
- Use a released checkpoint and Streamlit demo to validate the environment first.
- Treat pretraining, SFT, LoRA, RL, and serving as separate reproducible stages.
- Compare checkpoints with the same data, templates, hardware, and evaluation protocol.
Start with inference, not a long training job
MiniMind exposes an unusually complete learning path: tokenizer, pretraining, SFT, LoRA, preference optimization, reinforcement learning, tool use, and distillation. The safest first feature test is a released checkpoint with the documented Streamlit demo. It confirms Python dependencies, model files, tokenizer paths, and GPU visibility before a training script adds more variables.
Create a run card containing the repository revision, checkpoint source, Python/PyTorch versions, GPU, prompt, and output directory. The README's two-hour/three-yuan headline is a measurement for one SFT epoch on one NVIDIA 3090, not a promise for every stage or hardware configuration.
Exercise the training stages deliberately
After inference works, run one-process pretraining or full SFT with the smallest supported dataset and `torchrun --nproc_per_node 1`. Observe data loading, tokenizer coverage, loss, checkpoint cadence, and resume behavior. Keep pretraining and SFT outputs in separate directories so a later comparison cannot confuse a base checkpoint with an instruction-tuned one.
Only then add LoRA, DPO, PPO/GRPO/CISPO, tool calls, or agentic RL. Each stage changes the data contract and evaluation question. Version the JSONL data, seed, maximum sequence length, gradient settings, and checkpoint hash; a faster run with different inputs is not a comparable experiment.
Serve the result through a stable interface
The repository documents `scripts/serve_openai_api.py` as a lightweight OpenAI-compatible service and `scripts/web_demo.py` as a Streamlit UI. Start the API locally, send one non-streaming request, then test streaming and any extra fields such as `reasoning_content`, `tool_calls`, or `open_thinking` only after the basic response is stable.
Keep the model directory read-only for the serving process, bind to localhost during evaluation, and log request IDs, model revision, latency, token counts, and errors without saving user prompts unless your retention policy allows it. A compatible response shape does not make a tiny model equivalent to a hosted frontier model.
Evaluate what changed
Use a held-out prompt set and compare baseline, SFT, and later post-training checkpoints with the same tokenizer, decoding settings, and hardware. The README discusses C-Eval, CMMLU, ARC-Easy, PIQA, OpenBookQA, HellaSwag, and Social-IQA through lm-evaluation-harness; reproduce the exact task list and template before interpreting a score.
The most useful quickstart output is a small report with loss curves, qualitative examples, benchmark configuration, cost/time, and known limitations. If a change improves a single task but harms safety, format adherence, or latency, keep both results visible and decide based on the target use case rather than a headline number.
Decision guide
| Criterion | Option A | Option B |
|---|---|---|
| Best when | You need predictable behavior and easy auditing | You need adaptive optimization and have reliable telemetry |
| Main risk | May leave performance on the table | Can become difficult to explain or debug |
Implementation steps
- 1
Create a pinned Python environment and run the released-checkpoint demo.
- 2
Run one-process pretraining or SFT on a tiny, versioned dataset.
- 3
Start `serve_openai_api.py` locally and test a basic OpenAI-compatible request.
- 4
Evaluate held-out prompts, record cost/time and hashes, and review safety before exposure.
Copy-ready example
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
# run from the documented trainer directory
torchrun --nproc_per_node 1 train_pretrain.py
# or a bounded SFT smoke test
torchrun --nproc_per_node 1 train_full_sft.py
# serve a verified checkpoint locally
cd scripts && python serve_openai_api.pyFrequently asked questions
Can I compare two MiniMind runs with different datasets?
Not as a clean training comparison. Keep data, seed, tokenizer, sequence length, hardware, and evaluation prompts fixed when attributing a change.
Does the OpenAI-compatible API guarantee model quality?
No. It standardizes a request/response surface; quality, safety, latency, and tool behavior still depend on the checkpoint and serving configuration.
Sources
- MiniMind README (captured 2026-08-31)Source checked 2026-08-31
- MiniMind repositorySource checked 2026-08-31