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推理优化技术

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推理性能压测

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, InfraTech, Soup, Model-Optimizer, jeeves
Size
24.9 MB
Stars
25.2K
Updated
CommitOct 14
Age
3y
Commits · 90 Days