【ChatGLM】大模型之 ChatGLM 微调

目录

1. 微调方法

2. 全量参数微调

3. P-tuning v2

4. LoRA


1. 微调方法

  • 全参数微调

对模型全量参数进行训练。

  • P-tunning v2 

前缀微调,在模型每一层都增加前缀,只训练这部分的参数,训练量明显小于全量微调。

  • LoRA

基于矩阵分解的微调,假设原权重喂 W_0,我们新增一个和 W_0 一摸一样形状的矩阵 W_delta,并且对 W_delta 分解为 A 和 B,在训练过程中只训练 A 和 B 的参数,最后的权重 W = W_0 + W_delta

2. 全量参数微调

代码下载见:

扫描二维码关注公众号,回复: 16869484 查看本文章

【ChatGLM】大模型之 ChatGLM 部署

### full parameter finetuning ### (need enough GPU, at least 4 A100) 
cd ptuning
sh ds_train_finetune.sh  

3. P-tuning v2

代码下载见:

【ChatGLM】大模型之 ChatGLM 部署

### p-tuning v2 ###
# dataset
cd ptuning
wget https://cloud.tsinghua.edu.cn/seafhttp/files/802c9912-2742-47c9-a0d3-18ee08d83438/AdvertiseGen.tar.gz
tar -xvf AdvertiseGen.tar.gz

# modify model path and other parameter
sh train.sh

4. LoRA

### LoRA ###
git clone https://github.com/yuanzhoulvpi2017/zero_nlp.git
git clone https://huggingface.co/yuanzhoulvpi/chatglm6b-dddd

cd zero_nlp/simple_thu_chatglm6b
# execute jupyter notebook
# load model and lora need 24G, training need 17G
code02_训练模型全部流程.ipynb

执行 Juputer Notebook 后

猜你喜欢

转载自blog.csdn.net/u014147522/article/details/132166642