jingyaogong/minimind
🧠 Train a 64M-parameter LLM from scratch in just 2h!
From the publisher
README & documentation
Source previewRead the project’s overview, installation instructions and usage examples. The original README is the source of truth.
[](https://github.com/jingyaogong/minimind/stargazers) [](LICENSE) [](https://github.com/jingyaogong/minimind/commits/master) [](https://github.com/jingyaogong/minimind/pulls) [](https://huggingface.co/collections/jingyaogong/minimind-66caf8d999f5c7fa64f399e5) "大道至简" 中文 | English 🔗 在线体验 | 🔗 视频介绍 大语言模型(Large Language Model, LLM)的出现,引发了全球范围内对 AI 的空前关注。无论是 ChatGPT、DeepSeek 还是 Qwen,都以惊艳的效果让人真切感受到这场技术浪潮的冲击力。然而,动辄数百亿参数的模型规模,使得它们对个人设备而言不仅难以训练,甚至连部署都显得遥不可及。打开大模型的“黑盒子”,真正去理解其内部运作机制,本应是一件令人心潮澎湃的事。遗憾的是,绝大多数探索最终都止步于使用 LoRA 等技术对现有大模型做少量微调,学习一些新指令或特定任务。这更像是在教牛顿如何使用 21 世纪的智能手机——虽然有趣,却偏离了理解物理本质的初衷。 与此同时,第三方的大模型框架与工具库,如 transformers / trl / peft 等,往往只暴露出高度抽象的接口。只需短短十几行代码,就可以完成“加载模型 + 加载数据集 + 推理 + 强化学习”的全流程训练。这种高效封装固然便利,却也在一定程度上把开发者与底层实现隔离开来,削弱了深入理解 LLM 核心代码的机会。我认为 “用乐高自己拼出一架飞机,远比坐在头等舱里飞行更让人兴奋”,然而更现实的问题是,互联网上充斥着大量付费课程和营销内容,用漏洞百出、一知半解的讲解包装所谓的 AI 教程。正因如此,本项目的初衷就是尽可能降低 LLM 的学习门槛,让每个人都能从理解每一行代码开始,从 0 开始亲手训练一个极小的语言模型。是的,从零开始训练,而不是仅仅停留在推理层面。最低只需不到 3 块钱的服务器成本,就能亲身体验从 0 到 1 构建一个语言模型的全过程。 😊 一起感受创造的乐趣吧! 🔥 2026-04-01 2025-10-24 2025-04-26 More... 2025-02-09 如有旧代码的兼容性需要,可访问🔗旧仓库内容🔗。 2024-10-05 2024-09-27 2024-09-17 2024-09-01 2024-08-27 本人的软硬件配置(供参考) 在项目根目录: 注:提前确认 Torch 的可用后端 若你计划使用 CUDA 训练,建议先确认当前环境是否已正确识别 GPU。 若 cuda 不可用,也仍可根据自身设备选择 CPU 或 MPS 运行,但训练速度与兼容性会有非常大的差异。 如需安装或更换 PyTorch 版本,可参考 torchstable 与链接 从下文提供的数据集下载链接 下载所需数据文件,并放入 ./dataset 目录 如有更多需求,下文提供多种搭配方案,可根据自身任务目标与 GPU 资源灵活选择。 💡 检查点暂停续训 所有训练脚本均支持检查点保存。添加 --fromresume 1 参数后,即可自动检测并恢复训练进度: 断点续训说明: 确保待测试的模型 .pth 文件位于 ./out/ 目录下;也可直接前往此处下载我已训练好的 .pth 权重。 注:其它须知 1、所有训练脚本均基于 PyTorch 原生实现,并支持多卡加速。 2、若你的设备有 N (N > 1) 张显卡,可通过以下方式启动单机 N…
Read the full README ↗ · Preview checked 2026-10-30T19:44:05.924Z
Inside the original README — Document outline
Headings are captured from the source. Links open the publisher’s document, not a locally hosted copy.
Links from the README
References supplied by the publisher, not independently verified endorsements. Check the destination before downloading files or entering credentials.
Documentation belongs to its respective authors. Reported project/model license: Apache-2.0. A listing is not a grant of reuse or training rights. Confirm the document’s own terms at the source.
What this repository does
🧠 Train a 64M-parameter LLM from scratch in just 2h!
Repository facts
- Owner
- jingyaogong
- Primary language
- Python
- Stars
- 64,681
- Forks
- 8,455
- Open issues + pull requests
- 59
- License
- Apache-2.0
- Archived
- No
- Default branch
- master
- Created
- 2024-07-27T04:34:12.000Z
- Last push
- 2026-10-27T06:57:09.000Z
Topics and intended use
Owner-supplied topics: artificial-intelligence, large-language-model
Review the README for scope, installation, examples and limitations. We do not run repository code or certify it.
Evaluate before installing
Review licensing and dependencies, inspect recent commits and unresolved issues, and test in an isolated environment before production use. Stars and forks alone cannot answer these questions.
Source and freshness
Source: GitHub. Metadata observed 2026-10-31T13:20:02.570Z. Daily imports are snapshots, not real-time monitoring.
Popularity and source listings do not establish security, suitability, licensing rights or benchmark performance.
Related repositories
EbookFoundation/free-programming-books
donnemartin/system-design-primer