llm-action README

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

目录

LLM训练

LLM训练实战

下面汇总了我在大模型实践中训练相关的所有教程。从6B到65B,从全量微调到高效微调(LoRA,QLoRA,P-Tuning v2),再到RLHF(基于人工反馈的强化学习)。

LLM 预训练/SFT/RLHF... 参数 教程 代码
Alpaca full fine-turning 7B 从0到1复现斯坦福羊驼(Stanford Alpaca 7B) 配套代码
Alpaca(LLaMA) LoRA 7B~65B 1.足够惊艳,使用Alpaca-Lora基于LLaMA(7B)二十分钟完成微调,效果比肩斯坦福羊驼
2. 使用 LoRA 技术对 LLaMA 65B 大模型进行微调及推理
配套代码
BELLE(LLaMA/Bloom) full fine-turning 7B 1.基于LLaMA-7B/Bloomz-7B1-mt复现开源中文对话大模型BELLE及GPTQ量化
2. BELLE(LLaMA-7B/Bloomz-7B1-mt)大模型使用GPTQ量化后推理性能测试
N/A
ChatGLM LoRA 6B 从0到1基于ChatGLM-6B使用LoRA进行参数高效微调 配套代码
ChatGLM full fine-turning/P-Tuning v2 6B 使用DeepSpeed/P-Tuning v2对ChatGLM-6B进行微调 配套代码
Vicuna(LLaMA) full fine-turning 7B 大模型也内卷,Vicuna训练及推理指南,效果碾压斯坦福羊驼 N/A
OPT RLHF 0.1B~66B 1.一键式 RLHF 训练 DeepSpeed Chat(一):理论篇 
2. 一键式 RLHF 训练 DeepSpeed Chat(二):实践篇
配套代码
MiniGPT-4(LLaMA) full fine-turning 7B 大杀器,多模态大模型MiniGPT-4入坑指南 N/A
Chinese-LLaMA-Alpaca(LLaMA) LoRA(预训练+微调) 7B 中文LLaMA&Alpaca大语言模型词表扩充+预训练+指令精调 配套代码
LLaMA QLoRA 7B/65B 高效微调技术QLoRA实战,基于LLaMA-65B微调仅需48G显存,真香 配套代码
LLaMA GaLore 60M/7B 突破内存瓶颈,使用 GaLore 一张4090消费级显卡也能预训练LLaMA-7B 配套代码

⬆ 一键返回目录

LLM微调技术原理

对于普通大众来说,进行大模型的预训练或者全量微调遥不可及。由此,催生了各种参数高效微调技术,让科研人员或者普通开发者有机会尝试微调大模型。

因此,该技术值得我们进行深入分析其背后的机理,本系列大体分七篇文章进行讲解。

peft方法

LLM微调实战

下面给大家分享大模型参数高效微调技术实战,该系列主要针对 HuggingFace PEFT 框架支持的一些高效微调技术进行讲解。

教程 代码 框架
大模型参数高效微调技术实战(一)-PEFT概述及环境搭建 N/A HuggingFace PEFT
大模型参数高效微调技术实战(二)-Prompt Tuning 配套代码 HuggingFace PEFT
大模型参数高效微调技术实战(三)-P-Tuning 配套代码 HuggingFace PEFT
大模型参数高效微调技术实战(四)-Prefix Tuning / P-Tuning v2 配套代码 HuggingFace PEFT
大模型参数高效微调技术实战(五)-LoRA 配套代码 HuggingFace PEFT
大模型参数高效微调技术实战(六)-IA3 配套代码 HuggingFace PEFT
大模型微调实战(七)-基于LoRA微调多模态大模型 配套代码 HuggingFace PEFT
大模型微调实战(八)-使用INT8/FP4/NF4微调大模型 配套代码 PEFT、bitsandbytes

⬆ 一键返回目录

LLM分布式训练并行技术

近年来,随着Transformer、MOE架构的提出,使得深度学习模型轻松突破上万亿规模参数,传统的单机单卡模式已经无法满足超大模型进行训练的要求。因此,我们需要基于单机多卡、甚至是多机多卡进行分布式大模型的训练。

而利用AI集群,使深度学习算法更好地从大量数据中高效地训练出性能优良的大模型是分布式机器学习的首要目标。为了实现该目标,一般需要根据硬件资源与数据/模型规模的匹配情况,考虑对计算任务、训练数据和模型进行划分,从而进行分布式训练。因此,分布式训练相关技术值得我们进行深入分析其背后的机理。

下面主要对大模型进行分布式训练的并行技术进行讲解,本系列大体分九篇文章进行讲解。

⬆ 一键返回目录

分布式AI框架

分布式训练网络通信

待更新...

LLM训练优化技术

LLM对齐技术

⬆ 一键返回目录

LLM推理

推理引擎

迷你LLM推理引擎(非常适合源码学习):

生产级LLM推理引擎:

其他推理引擎:

推理服务

LLM推理优化技术

MoE 模型:

LLM压缩

近年来,随着Transformer、MOE架构的提出,使得深度学习模型轻松突破上万亿规模参数,从而导致模型变得越来越大,因此,我们需要一些大模型压缩技术来降低模型部署的成本,并提升模型的推理性能。 模型压缩主要分为如下几类:

LLM量化

本系列将针对一些常见大模型量化方案(GPTQ、LLM.int8()、SmoothQuant、AWQ等)进行讲述。

LLM稀疏化

目前,大多数针对大模型模型的压缩技术都专注于模型量化领域,即降低单个权重的数值表示的精度。另一种模型压缩方法模型剪枝的研究相对较少,即删除网络元素,包括从单个权重(非结构化剪枝)到更高粒度的组件,如权重矩阵的整行/列(结构化剪枝)。

本系列将针对一些常见大模型稀疏化方案(LLM-Pruner、SliceGPT、SparseGPT、Wanda等)进行讲述。

结构化剪枝:

非结构化剪枝:

LLM知识蒸馏

Standard KD:

使学生模型学习教师模型(LLM)所拥有的常见知识,如输出分布和特征信息,这种方法类似于传统的KD。

EA-based KD:

不仅仅是将LLM的常见知识转移到学生模型中,还涵盖了蒸馏它们独特的涌现能力。具体来说,EA-based KD又分为了上下文学习(ICL)、思维链(CoT)和指令跟随(IF)。

In-Context Learning:

Chain-of-Thought:

Instruction Following:

低秩分解

低秩分解旨在通过将给定的权重矩阵分解成两个或多个较小维度的矩阵,从而对其进行近似。低秩分解背后的核心思想是找到一个大的权重矩阵W的分解,得到两个矩阵U和V,使得W≈U V,其中U是一个m×k矩阵,V是一个k×n矩阵,其中k远小于m和n。U和V的乘积近似于原始的权重矩阵,从而大幅减少了参数数量和计算开销。

在LLM研究的模型压缩领域,研究人员通常将多种技术与低秩分解相结合,包括修剪、量化等。

LLM测评

LLM效果评测

测评集

Coding:

Agent:

Storage:

测评工具

LLM推理性能压测

指标 描述 Aggregations
Time to First Token Time between when a request is sent and when its first response is received, one value per request in benchmark Avg, min, max, p99, p90, p75
Time to Second Token Time between when the first streaming response is received and when the second streaming response is received, one value per request in benchmark Avg, min, max, p99, p90, p75
Inter Token Latency Time between intermediate responses for a single request divided by the number of generated tokens of the latter response, one value per response per request in benchmark Avg, min, max, p99, p90, p75
Request Latency Time between when a request is sent and when its final response is received, one value per request in benchmark Avg, min, max, p99, p90, p75
Output Sequence Length Total number of output tokens of a request, one value per request in benchmark Avg, min, max, p99, p90, p75
Input Sequence Length Total number of input tokens of a request, one value per request in benchmark Avg, min, max, p99, p90, p75
Output Token Throughput Total number of output tokens from benchmark divided by benchmark duration None–one value per benchmark
Request Throughput Number of final responses from benchmark divided by benchmark duration None–one value per benchmark

LLM数据工程

LLM Data Engineering

预训练语料处理技术

llm-pretrain-pipeline

LLM微调高效数据筛选技术

提示工程

LLM算法架构

llm-famliy

llm-famliy

MoE 模型:

模型 总参数 每 Token 激活 激活率 专家配置 注意力方案
Qwen3 (30B-A3B) 30B ~3B ~10% 128 选 8,无共享 全层 GQA
Gemma 4 (26B-A4B) 26B ~4B ~15% 128 选 8 + 1 共享 滑窗(1024) + 少量全局,5:1
MiniMax M3 428B ~23B ~5.4% 128 选 4 + 1 共享 MSA(索引分支 + 主分支)
GLM-5 744B 40B - - -
GLM-5.2 744B 40B ~5.4% 256 选 8 + 1 共享 DSA + IndexShare(4 层复用索引)
GLM-5.3-Flash 320B 18B - - -
Xiaomi MiMo-V2.5-Pro 1.02T ~40B ~3.9% 384 选 8 10 全局 + 60 滑窗(128),1:6
DeepSeek-V4-Pro 1.6T 49B ~3.1% 384 选 6 + 1 共享 CSA + HCA
DeepSeek-V4-Flash 284B 13B - - -
Kimi K2.6 1T 32B - - -
Kimi K3 2.8T 104B ~3.7% 896 选 16 + 2 共享 69 KDA + 24 Gated MLA,3:1
Qwen3.8-2.4T-A95B 2.4T 95B - 512 选 10 + 1 共享 -
Qwen3.8-Flash-Next 125B 6B ~4.8% 512 选 10 + 1 共享 3 GDN + 1 QSA,3:1

LLM应用开发

大模型是基座,要想让其变成一款产品,我们还需要一些其他相关的技术,比如:向量数据库(Pinecone、Milvus、Vespa、Weaviate),LangChain等。

Agent应用

Harness:

AI Assistant:

Code Agent:

LLM国产化适配

随着 ChatGPT 的现象级走红,引领了AI大模型时代的变革,从而导致 AI 算力日益紧缺。与此同时,中美贸易战以及美国对华进行AI芯片相关的制裁导致 AI 算力的国产化适配势在必行。本系列将对一些国产化 AI 加速卡进行讲解。

⬆ 一键返回目录

AI编译器

AI编译器是指将机器学习算法从开发阶段,通过变换和优化算法,使其变成部署状态。

框架:

AI基础设施

AI加速卡

AI集群

待更新...

AI集群网络通信

待更新...

LLMOps

LLM生态相关技术

LLM性能分析

LLM面试题

正在收集中...

⬆ 一键返回目录

服务器基础环境安装及常用工具

基础环境安装:

常用工具:

LLM学习交流群

我创建了大模型相关的学习交流群,供大家一起学习交流大模型相关的最新技术,目前已有5个群,每个群都有上百人的规模,可加我微信进群(加微信请备注来意,如:进大模型学习交流群+GitHub,进大模型推理加速交流群+GitHub、进大模型应用开发交流群+GitHub、进大模型校招交流群+GitHub等)。一定要备注哟,否则不予通过。

PS:成都有个本地大模型交流群,想进可以另外单独备注下。

微信公众号

微信公众号:吃果冻不吐果冻皮,该公众号主要分享AI工程化(大模型、MLOps等)相关实践经验,免费电子书籍、论文等。

⬆ 一键返回目录

Star History

Star History Chart

AI工程化课程推荐

如今人工智能的发展可谓是如火如荼,ChatGPT、Sora、文心一言等AI大模型如雨后春笋般纷纷涌现。AI大模型优势在于它能处理复杂性问题;因此,越来越多的企业需要具备AI算法设计、AI应用开发、模型推理加速及模型压缩等AI工程化落地的能力。这就导致行业内的工程师,需要快速提升自身的技术栈,以便于在行业内站稳脚跟。我在llm-resource 和 ai-system梳理了一些大模型和AI工程化相关资料。

llm-action (liguodongiot/llm-action)

Searching Database…

What is this?It is a Chinese-language hub of in-depth tutorials on large language model engineering: training, fine-tuning, distributed training, inference, compression, evaluation, data engineering, LLMOps and AI infrastructure, organized as a big index linking the author's article series, many with companion code.
Is this a library or tool I can install, or something else?Neither - it is a curated reading index, not software. The content is Chinese markdown articles plus links to companion code repos for each experiment; there is nothing to install or run from this repo itself.
Where should someone new to LLM engineering start here?Start with the table of contents at the top of the README. A natural path is the 7-article parameter-efficient fine-tuning series (BitFit, P-Tuning, LoRA, QLoRA and more), then the 9-article distributed-training parallelism series, then inference and serving.
Which frameworks and tools do the tutorials build on?The hands-on fine-tuning series is built on HuggingFace PEFT (plus bitsandbytes for INT8/FP4/NF4); training tutorials use PyTorch, Megatron-LM and DeepSpeed; the inference side covers vLLM, SGLang, TensorRT-LLM and the Triton serving framework.
Is the collection complete, or still being filled in?It is a living document and still growing: the distributed-training network-communication section is explicitly marked 'to be updated' (待更新), so not every item promised in the table of contents is filled in yet.
Is it aimed at researchers, or can a regular developer benefit too?Both. The author notes parameter-efficient fine-tuning exists precisely so ordinary researchers and developers can fine-tune large models, so beginners can start with PEFT, while the distributed-training and serving material serves advanced practitioners.
Do I need a big GPU setup to follow along?Only for the hands-on parts, and not always a cluster: QLoRA fine-tuning of LLaMA-65B fits in 48GB of VRAM and GaLore can pretrain LLaMA-7B on a single RTX 4090, while the distributed-training series targets multi-GPU and multi-node setups.
Which inference engines does it cover for production serving?It treats vLLM and SGLang as production-grade engines and also covers LMDeploy, LightLLM, MNN-LLM and the on-device multimodal engine mllm, plus step-by-step TensorRT-LLM tutorials and a three-part guide to the Triton serving framework.
Is there material for learning how inference engines work internally?Yes - it links Nano-vLLM, an annotated lightweight vLLM reimplementation, and Mini-SGLang, a compact SGLang implementation, both described as very suitable for source-code study.
Does it help with LLM job interview preparation?Yes - there is a dedicated LLM interview questions section, alongside a server environment setup guide and a WeChat study group for discussing LLM engineering.
Does it cover running LLMs on domestic Chinese AI hardware?Yes - the index includes sections on LLM adaptation to domestic hardware, AI accelerator cards, AI compilers, AI infrastructure and AI cluster networking.
What are similar projects?peft, halo, ms-swift, decider, Soup, InfraTech, Model-Optimizer, verl
Size
24.9 MB
Stars
25.3K
Updated
CommitOct 14
Age
3y
Commits · 90 Days