happy-llm README

The project's README from github.com/datawhalechina/happy-llm. As one markdown file: README.md.

alt text

Happy-LLM

GitHub stars GitHub forks Language GitHub Project SwanLab
datawhalechina%2Fhappy-llm | Trendshift

中文 | English

📚 在线阅读地址

📚 从零开始构建大模型

深入理解 LLM 核心原理,动手实现你的第一个大模型


🎯 项目介绍

  很多小伙伴在看完 Datawhale开源项目: self-llm 开源大模型食用指南 后,感觉意犹未尽,想要深入了解大语言模型的原理和训练过程。于是我们(Datawhale)决定推出《Happy-LLM》项目,旨在帮助大家深入理解大语言模型的原理和训练过程。

  本项目是一个系统性的 LLM 学习教程,将从 NLP 的基本研究方法出发,根据 LLM 的思路及原理逐层深入,依次为读者剖析 LLM 的架构基础和训练过程。同时,我们会结合目前 LLM 领域最主流的代码框架,演练如何亲手搭建、训练一个 LLM,期以实现授之以鱼,更授之以渔。希望大家能从这本书开始走入 LLM 的浩瀚世界,探索 LLM 的无尽可能。

✨ 你将收获什么?

📖 内容导航

章节 关键内容 状态
学习与环境准备 分章依赖、硬件建议与实践入口 ✅
前言 本项目的缘起、背景及读者建议 ✅
第一章 NLP 基础概念 什么是 NLP、发展历程、任务分类、文本表示演进 ✅
第二章 Transformer 架构 注意力机制、Encoder-Decoder、手把手搭建 Transformer ✅
第三章 预训练语言模型 Encoder-only、Encoder-Decoder、Decoder-Only 模型对比 ✅
第四章 大语言模型 LLM 定义、训练策略、涌现能力分析 ✅
第五章 动手搭建大模型 实现 LLaMA2、训练 Tokenizer、预训练小型 LLM ✅
第六章 大模型训练实践 预训练、有监督微调、LoRA/QLoRA 高效微调 ✅
第七章 大模型应用 模型评测、RAG 检索增强、Agent 智能体 ✅
第八章 Agentic-RL GRPO、OPD、Search-R1、ReTool(Coding Agent-RL) ✅
Extra Chapter LLM Blog 优秀的大模型 学习笔记/Blog ,欢迎大家来 PR ! 🚧

第六章正文已覆盖 Pretrain、SFT 与 PEFT 等核心训练流程,建议结合 第六章实践说明 和 学习与环境准备 一起阅读。

第八章聚焦 GRPO、OPD、Search-R1 与 ReTool。更多 Agentic RL 算法、训练代码与实验实践,可以前往作者持续维护的另一个仓库 agentic-rl-lab;该仓库更新频率更高,会持续跟进新的算法与环境。

Extra Chapter LLM Blog

  如果大家在学习 Happy-LLM 项目或 LLM 相关知识中有自己独到的见解、认知、实践,欢迎大家 PR 在 Extra Chapter LLM Blog 中。请遵守 Extra Chapter LLM Blog 的 PR 规范,我们会视 PR 内容的质量和价值来决定是否合并或补充到 Happy-LLM 正文中来。

模型下载

模型名称 下载地址
Happy-LLM-Chapter5-Base-215M 🤖 ModelScope
Happy-LLM-Chapter5-SFT-215M 🤖 ModelScope

ModelScope 创空间体验地址:🤖 创空间

PDF 版本下载

  本 Happy-LLM PDF 教程完全开源免费。为防止各类营销号加水印后贩卖给大模型初学者,我们特地在 PDF 文件中预先添加了不影响阅读的 Datawhale 开源标志水印,敬请谅解~

Happy-LLM PDF : https://github.com/datawhalechina/happy-llm/releases/tag/v1.0.2

PPT 资源下载

  本项目配套教学讲义PPT课件资源获取链接:https://github.com/HZAI-ZJNU/happy-llm-ppt 或可在本项目的 Releases 页面下载。

💡 如何学习

  本项目适合大学生、研究人员、LLM 爱好者。在学习本项目之前,建议具备一定的编程经验,尤其是要对 Python 编程语言有一定的了解。最好具备深度学习的相关知识,并了解 NLP 领域的相关概念和术语,以便更轻松地学习本项目。

  如果你计划复现章节代码,建议先阅读 学习与环境准备。仓库当前按章节拆分依赖,不同章节建议使用独立的 Python 环境,以减少版本冲突。

  本项目分为两部分——基础知识与实战应用。第1章~第4章是基础知识部分,从浅入深介绍 LLM 的基本原理。其中,第1章简单介绍 NLP 的基本任务和发展,为非 NLP 领域研究者提供参考;第2章介绍 LLM 的基本架构——Transformer,包括原理介绍及代码实现,作为 LLM 最重要的理论基础;第3章整体介绍经典的 PLM,包括 Encoder-Only、Encoder-Decoder 和 Decoder-Only 三种架构,也同时介绍了当前一些主流 LLM 的架构和思想;第4章则正式进入 LLM 部分,详细介绍 LLM 的特点、能力和整体训练过程。第5章~第8章是实战应用部分,将逐步带领大家深入 LLM 的底层细节。其中,第5章将带领大家基于 PyTorch 亲手搭建一个 LLM,并实现预训练、有监督微调的全流程;第6章将引入目前业界主流的 LLM 训练框架 Transformers,带领学习者基于该框架快速、高效地实现 LLM 训练过程;第7章介绍 LLM 的评测、检索增强生成(Retrieval-Augmented Generation,RAG)和智能体(Agent);第8章进一步介绍 GRPO、OPD,以及 Search-R1 与 ReTool 两类 Agentic RL 实践。你可以根据个人兴趣和需求,选择性地阅读相关章节。

  在阅读本书的过程中,建议你将理论和实际相结合。LLM 是一个快速发展、注重实践的领域,我们建议你多投入实战,复现本书提供的各种代码,同时积极参加 LLM 相关的项目与比赛,真正投入到 LLM 开发的浪潮中。我们鼓励你关注 Datawhale 及其他 LLM 相关开源社区,当遇到问题时,你可以随时在本项目的 issue 区提问。

  最后,欢迎每一位读者在学习完本项目后加入到 LLM 开发者的行列。作为国内 AI 开源社区,我们希望充分聚集共创者,一起丰富这个开源 LLM 的世界,打造更多、更全面特色 LLM 的教程。星火点点,汇聚成海。我们希望成为 LLM 与普罗大众的阶梯,以自由、平等的开源精神,拥抱更恢弘而辽阔的 LLM 世界。

🤝 如何贡献

我们欢迎任何形式的贡献!

🙏 致谢

核心贡献者

Extra-Chapter 贡献者

特别感谢

Star History

Datawhale

⭐ 如果这个项目对你有帮助,请给我们一个 Star!

关于 Datawhale

Datawhale

扫描二维码关注 Datawhale 公众号,获取更多优质开源内容


📜 开源协议

本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

happy-llm (datawhalechina/happy-llm)

Searching Database…

34.4K ·GitHub
What is this?Happy-LLM is Datawhale's free open-source LLM course: a systematic tutorial that goes from NLP basics and the Transformer architecture to building and training your first large language model, then applying it with RAG and agents.
Is this software I install, or a course I read?A course you read: eight chapters of tutorial text with companion Python/Jupyter code to reproduce, plus a free PDF edition (lightly watermarked to deter resellers) and PPT slides available in Releases.
How do I set up to run the chapter code?Dependencies are split per chapter, so the repo recommends a separate Python environment per chapter to avoid version conflicts; start with the Learning and Environment Preparation chapter, which also gives hardware advice.
Which frameworks does the hands-on part use?Chapter 5 works in plain PyTorch, then chapter 6 switches to the mainstream Transformers framework for pretraining, supervised fine-tuning and efficient LoRA/QLoRA (PEFT) fine-tuning; chapter 7 adds evaluation, RAG and agents.
Does the material keep up with how fast LLMs move?All eight chapters are complete, and chapter 8 already covers recent Agentic-RL methods (GRPO, OPD, Search-R1, ReTool); for newer algorithms the authors point readers to their faster-updating agentic-rl-lab repo.
Do I need prior ML experience to follow it?It targets students, researchers and LLM enthusiasts; you should have some programming experience, ideally Python, and deep-learning knowledge plus NLP terminology will make it much smoother.
Can I reuse the material in my own course or product?Not commercially: the work is licensed CC BY-NC-SA 4.0, so sharing and adapting with attribution under the same license is fine, but commercial use is excluded. GitHub lists it as NOASSERTION.
Will I need a beefy GPU to follow along?Specific requirements are not listed here, but the Learning and Environment Preparation chapter provides per-chapter dependencies and hardware suggestions for reproducing the code.
Why did Datawhale create this course?After their self-llm guide on using open-source LLMs, many readers wanted to go deeper, so Datawhale built Happy-LLM to explain the principles and training process behind large language models rather than just how to use them.
Can I try or download the model built in the book?Yes. The chapter 5 checkpoints — Happy-LLM-Chapter5-Base-215M and Happy-LLM-Chapter5-SFT-215M — are downloadable from ModelScope, and there is an online ModelScope demo space to try them in the browser.
Is the tutorial available in English?Yes. The README links both a Chinese and an English edition, so you can follow the course without reading Chinese.
Size
52.1 MB
Stars
34.4K
Age
2y
Commits · 90 Days