输入“/”快速插入内容

CHATGLM2-6B大模型进行LoRA 微调

2023年9月1日修改
https://github.com/shuxueslpi/chatGLM-6B-QLoRA
https://github.com/hiyouga/ChatGLM-Efficient-Tuning
前言
CHATGLM2-6B是清华智普开源的大语言模型,Huggingface 开源的 PEFT 大模型高效微调工具包,本文主要介绍对CHATGLM2-6B大模型进行 LoRA 微调,只要你有训练数据,然后本地下载好大模型的checkpoint,就可以最少只需 1 行代码就可以微调你自己的 LLM
1.1 硬件需求
注:r 为LoRA 维数大小,p 为前缀词表大小,l 为微调层数,ex/s 为每秒训练的样本数。gradient_accumulation_steps 参数设置为 1。上述结果均来自于单个 Tesla V100 GPU,仅供参考。
1.2 微调方法
目前我们实现了针对以下高效微调方法的支持:
LoRA:仅微调低秩适应器。
P-Tuning V2:仅微调前缀编码器
Freeze :仅微调后几层的全连接层。
1.3 软件依赖
Python 3.8+, PyTorch 2.0.0
Transformers, Datasets, Accelerate, TRL, PEFT(最低需要 0.3.0.dev0)
protobuf, cpm_kernels, sentencepiece
jieba, rouge_chinese, nltk(用于评估)
gradio, mdtex2html(用于网页端交互)
代码块
GPU平台:featurize.cn
RTX 3060 / 3090
一、环境配置
代码块
#更新git-lfs:
apt-get update
apt-get install git-lfs
#初始化git:
git init
git lfs install
借助ChatGLM-Efficient-Tuning进行微调。这里面使用了peft框架。
代码块
git clone https://github.com/hiyouga/ChatGLM-Efficient-Tuning.git
conda create -n chatglm_etuning python=3.10
conda activate chatglm_etuning
cd ChatGLM-Efficient-Tuning
pip install -r requirements.txt
三、资源准备
3.1 数据来源介绍
部分预置数据集简介: