{"data":{"slug":"datawhalechina-base-llm","name":"base-llm","tagline":"从 NLP 到 LLM 的算法全栈教程","github_url":"https://github.com/datawhalechina/base-llm","owner":"datawhalechina","repo":"base-llm","owner_avatar_url":"https://avatars.githubusercontent.com/u/46047812?v=4","primary_language":"Jupyter Notebook","stars":993,"forks":107,"topics":["bert","deeplearning","docker","fine-tuning","linux","llama","llm","lora","nlp","python","pytorch","qwen","rnn","tensorrt","transformer","tutorial"],"archived":false,"github_pushed_at":"2026-06-26T16:37:02+00:00","maintenance_label":"Steady","stars_delta_30d":75,"url":"https://www.graphcanon.com/tools/datawhalechina-base-llm","markdown_url":"https://www.graphcanon.com/tools/datawhalechina-base-llm.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/datawhalechina-base-llm","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=datawhalechina-base-llm","description":"从 NLP 到 LLM 的算法全栈教程，在线阅读地址：https://datawhalechina.github.io/base-llm/","homepage_url":"https://datawhalechina.github.io/base-llm/","license":null,"open_issues":0,"watchers":3,"ai_summary":"A comprehensive tutorial for algorithms from NLP to Large Language Models (LLMs) available online.","readme_excerpt":"<div align=\"center\">\n  <h1>Base LLM | 从 NLP 到 LLM 的算法全栈教程</h1>\n</div>\n\n<div align='center'>\n  <img src=\"./logo.svg\" alt=\"base-llm Logo\" width=\"70%\">\n</div>\n\n<div align=\"center\">\n  <h2>大模型前世今生</h2>\n  <p><em>Base LLM is all you need</em></p>\n</div>\n\n<div align=\"center\">\n  <img src=\"https://img.shields.io/github/stars/datawhalechina/base-llm?style=for-the-badge&logo=github&color=ff6b6b\" alt=\"GitHub stars\"/>\n  <img src=\"https://img.shields.io/github/forks/datawhalechina/base-llm?style=for-the-badge&logo=github&color=4ecdc4\" alt=\"GitHub forks\"/>\n  <img src=\"https://img.shields.io/badge/Python-3.10+-blue?style=for-the-badge&logo=python&logoColor=white\" alt=\"Python\"/>\n</div>\n\n<div align=\"center\">\n  <a href=\"https://github.com/datawhalechina/base-llm/releases\">\n    <img src=\"https://img.shields.io/github/v/release/datawhalechina/base-llm?style=for-the-badge&logo=github&color=brightgreen\" alt=\"GitHub release\"/>\n  </a>\n  <a href=\"https://datawhalechina.github.io/base-llm/\">\n    <img src=\"https://img.shields.io/badge/📖_在线阅读-立即开始-success?style=for-the-badge&logoColor=white\" alt=\"在线阅读\"/>\n  </a>\n  <a href=\"https://github.com/datawhalechina\">\n    <img src=\"https://img.shields.io/badge/💬_讨论交流-加入我们-purple?style=for-the-badge&logoColor=white\" alt=\"讨论交流\"/>\n  </a>\n</div>\n\n> **注意：**\n> - **关于 Pull Request**：本项目目前主要接受 `Extra-chapter` 的共建，提交 PR 前请参阅 [Extra-chapter/README.md](./Extra-chapter/README.md)。\n> - **问题反馈**：如果您对主教程有任何建议或发现任何问题，欢迎通过 [Issue](https://github.com/datawhalechina/base-llm/issues) 进行反馈。\n\n## 📖 项目简介\n\n本项目是一个**从传统自然语言处理（NLP）到大语言模型（LLM）的全栈式学习教程**，旨在为开发者提供一条从理论入门到工程实战的清晰路径。\n\n在 LLM 爆发的今天，许多开发者直接上手调用 API 或微调大模型，却往往忽视了底层的自然语言处理（NLP）基础。本项目主张 **“Base LLM is all you need”**，通过系统性地回顾 NLP 发展历程中的核心技术——从早期的词向量、循环神经网络（RNN），到变革性的 Transformer 架构，再到如今的 BERT、GPT 及 Llama 系列大模型——帮助读者构建坚实的技术护城河。\n\n**核心内容覆盖：**\n\n1.  **NLP 理论基石**：深入浅出地讲解分词、词向量（Word2Vec）、RNN/LSTM 等经典算法。\n2.  **Transformer 架构**：剖析 Attention 机制，详解 Encoder-Decoder 架构，奠定大模型认知基础。\n3.  **预训练语言模型**：全面覆盖 BERT、GPT、T5 等里程碑式模型的设计与应用。\n4.  **大模型进阶实战**：从零手搓 Llama2 模型，掌握参数高效微调（PEFT/LoRA）、RLHF 等前沿技术。\n5.  **工程化落地**：涵盖模型量化、推理加速、Docker 容器化及服务部署的全流程实战。\n6.  **大模型安全与多模态**：探索模型安全挑战、伦理问题，以及图文多模态模型的前沿技术。\n\n## 🌟 项目意义\n\n随着人工智能技术的飞速发展，掌握大语言模型已成为 AI 工程师的必备技能。然而，市面上的教程往往存在断层。要么过于偏重学术理论，晦涩难懂；要么仅停留在 API 调用的应用层，缺乏底层原理的支撑。\n\n本项目致力于填补这一空白，通过**理论与代码并重**的方式，帮助开发者：\n\n*   **打通知识脉络**：理解技术演进的内在逻辑（如：为什么从 RNN 发展到 Transformer？）。\n*   **掌握核心原理**：不仅会用，更懂其“所以然”，具备排查复杂问题和优化模型结构的能力。\n*   **学习代码演进**：采用“提出问题-迭代重构”的教学模式，展示从简易脚本到工业级框架的演变过程，培养真正的工程化思维。\n*   **提升工程能力**：通过 NER、文本分类及 LLM 微调部署等实战项目，积累生产环境下的开发经验。\n*   **拓宽技术视野**：探索大模型安全、多模态等前沿领域，紧跟 AI 技术发展的最新趋势。\n\n## 🎯 项目受众\n\n**本项目适合以下人群学习：**\n\n*   🎓 **在校学生**：希望系统学习 NLP 知识，为科研或求职打下基础。\n*   💻 **AI 算法工程师**：需要从传统机器学习/深度学习转型到大模型领域的开发者。\n*   🤔 **LLM 爱好者**：对大模型底层原理感兴趣，希望深入理解大模型架构运行机制的极客。\n*   🔬 **研究人员**：需要快速回顾 NLP 经典算法或寻找基线代码实现的学者。\n\n**前置要求：**\n\n*   🟢 **Python 基础**：熟练掌握 Python 语法及常用数据结构。\n*   🔵 **PyTorch 框架**：具备基本的 PyTorch 深度学习框架使用经验。\n*   🟠 **深度学习基础**：理解神经网络基本原理、反向传播机制及模型训练的基础流程。\n*   🟡 **数学基础**：了解基本的线性代数、概率论及梯度下降等深度学习概念。\n\n## ✨ 项目亮点\n\n1.  **体系化进阶路径**：从基础的文本表示到 RLHF 和量化技术，内容层层递进。\n2.  **手写核心代码**：拒绝\"调包侠\"，带领读者手写 Llama2、Transformer 等核心架构代码。\n3.  **实战导向**：包含文本分类、命名实体识别（NER）、私有数据微调 Qwen2.5 等多个完整项目。\n4.  **全流程覆盖**：不仅教你怎么训练，还教你怎么用 Docker 和 FastAPI 将模型部署成服务。\n5.  **图文并茂**：配合大量图解，将抽象的算法原理可视化，降低学习门槛。\n6.  **直观易懂**：尽量弱化复杂的数学公式推导，让数学基础薄弱的读者也能轻松掌握算法原理。\n\n## 内容大纲\n\n### 第一部分：理论篇\n- **第 1 章：NLP 简介**\n    - [x] [NLP 概述](./docs/chapter1/01_nlp_intro.md)\n    - [x] [环境准备](./docs/chapter1/02_preparation.md)\n- **第 2 章：文本表示与词向量**\n    - [x] [初级分词技术](./docs/chapter2/03_tokenization.md)\n    - [x] [词向量表示](./docs/chapter2/04_word_vector.md)\n    - [x] [从主题模型到 Word2Vec](./docs/chapter2/05_Word2Vec.md)\n    - [x] [基于 Gensim 的词向量实战](./docs/chapter2/06_gensim.md)\n- **第 3 章：循环神经网络**\n    - [x] [循环神经网络](./docs/chapter3/08_RNN.md)\n    - [x] [LSTM 与 GRU](./docs/chapter3/09_LSTM&GRU.md)\n- **第 4 章：注意力机制与Transformer**\n    - [x] [Seq2Seq 架构](./docs/chapter4/10_seq2seq.md)\n    - [x] [注意力机制](./docs/chapter4/11_attention.md)\n    - [x] [深入解析 Transformer](./docs/chapter4/12","github_created_at":"2025-08-19T03:48:20+00:00","created_at":"2026-07-11T11:39:40.507826+00:00","updated_at":"2026-08-24T06:00:57.422171+00:00","categories":[{"slug":"llm-frameworks","name":"LLM Frameworks","url":"https://www.graphcanon.com/categories/llm-frameworks","markdown_url":"https://www.graphcanon.com/categories/llm-frameworks.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/llm-frameworks"},{"slug":"model-training","name":"Model Training","url":"https://www.graphcanon.com/categories/model-training","markdown_url":"https://www.graphcanon.com/categories/model-training.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/model-training"}],"tags":[{"slug":"bert","name":"bert"},{"slug":"deeplearning","name":"deeplearning"},{"slug":"docker","name":"docker"},{"slug":"fine-tuning","name":"fine-tuning"},{"slug":"llama","name":"llama"},{"slug":"llm","name":"llm"},{"slug":"lora","name":"lora"},{"slug":"nlp","name":"nlp"}],"trust":{"provenance":{"is_fork":false,"github_id":1040481901,"owner_type":"Organization","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-08-24T06:00:56.690Z","maintenance":{"label":"Steady","score":60,"methodology":"github_public_v1","releases_90d":0,"days_since_push":58,"last_release_at":"2026-03-08T18:01:28Z","stars_delta_30d":75,"open_issues_delta_30d":0},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-11T11:39:41.708Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-08-24T06:00:57.128Z"},"languages":{"value":["jupyter notebook"],"source":"github.language","observed_at":"2026-08-24T06:00:57.128Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":null,"constraints":null,"when_to_use":["You need detailed, step-by-step tutorials on transitioning from NLP to LLM algorithms","Preferring hands-on learning with Python and PyTorch environments"],"when_not_to_use":["Seeking real-time collaboration features; lacks built-in support for multi-user interaction","Prioritizing proprietary frameworks; focuses heavily on open-source tools like PyTorch and Docker"],"source":"enrich:decision_facts","observed_at":"2026-07-12T14:50:53.111Z"},"constraint_facets":null,"decision_summary":[{"label":"Adopt for","value":"Comprehensive algos from NLP to LLMs in Jupyter Notebooks"}]}}