大模型参数高效微调面试题
《大模型参数高效微调面试题》共 4 页、0.2 万字,通篇围绕 微调、LoRA、prompt、预训练 展开,归在「模型架构与原理」这一层。
适合要跟模型团队对话、得听懂他们在说什么的人
目录骨架(2 节)
- 3.介绍一下 PEFT?
- Extra FFN and input
原 PDF 已逐页还原成图,共 4 页,这里先放前 3 页,其中 1 页识别出了标题。右侧文字由 OCR 按版面重排,可能有个别错字,以图为准;点图可全屏放大。

1.微调方法是啥?如何微调? fin…
1.微调方法是啥?如何微调? fine-tune,也叫全参微调,ber 微调模型一直用的这种方法,全部参数权重参与更新以适配领域数据,效果好。 prompt-tune,包括 p-tuning、lora、prompt-tuning、adaLoRA 等 delta tuning 方法,部分模型参数参与微调,训练 快,显存占用少,效果可能跟 FT (fine-tune)比会稍有效果损失,但一般效果能打平。
链家在 BELLE 的技术报告《 A Comparative Study between Full-Parameter and LoRA-based Fine-Tuning on Chinese Instruction Data for Instruction Following Large Language Model 》中实验显示:FT 效果稍好于 LORA。 Table 4: Main results. In this table, LLaMA-13B + LoRA (2M)represents a model trained on 2M instruc-
tion data using LLaMA-13B as base model and LoRA training method, and LLaMA-7B + FT (2M)rep- resents a model trained using full-parameters fine-tuning. LLaMA-7B + FT (2M)+ LoRA (math_0.25M) base model and LoRA training method, and LLaMA-7B + FT (2M)+ FT (math_0.25M)represents a model trained using incremental full-parameters fine-tuning. About the training time, all these experi- ments were conducted on 8 NVIDIA A100-40GB GPUs. Average Score Additional Param. Training Time (Hour/epoch)
Model LLaMA-13B + LoRA (2M) 0.648 0.624 LLaMA-7B + LoRA (4M)
17.9M
0.609 LLaMA-7B + LoRA (2M)
17.9M
0.589 LLaMA-7B + LoRA (0.6M) 0.710 LLaMA-7B + FT (2M) 0.686 LLaMA-7B + FT (0.6M) LLaMA-7B + FT (2M)+LoRA (math_0.25M) 0.729 0.738
peft 的论文《 ADAPTIVE BUDGET ALLOCATION FOR PARAMETER- EFFICIENT FINE-TUNING 》显示的结 果:AdaLoRA 效果稍好于 FT。 Table 1: Results with DeBERTaV3-base on GLUE development set. The best results on each dataset are shown bold. We report the average correlation for STS-B. Full FT, HAdaprer and PAdapter represent full fine-tuni
oulsby adapier, and Pfciffer adapter respectively. We report mean of 5 runs using different random sce
MNLI QQP # Params Method Acc/F1
Ave. Acc
m/mm
94.03 83.75 89.46 91.60 88.09 184M Full FT 89.90/90.12 95.63 69.19 92.40/89.80 91.35 86.02 92.24 88.41/84.95 87.75
66.96 BitFit 78.70 |90.13/90.17
95.53 HAdapter|
1.22M 88.12 68.64 91.48 84.48 91.91/89.27 89.95 94.11
1.18M 91.54 PAdapter 89.46 88.24 85.20 68.77 92.04/89.40
90.65/90.69 94.95 1.33M
91.99/89.38 85.20 93.87 LoRAr=8
91.60 69.82 89.95
90.76/90.79 96.10 1.27M AdaLoRA
92.23/89.74 90.69 91.84 89.31 88.09 71.45
|90.12/90.23 95.30 HAdapter 93.76 91.65/88.95 85.56 89.22 87.93 0.6IM
67.87 91.30
0.60M PAdapter 84.12 89.22 88.04 93.98 91.62/88.86 69.48
HAdapter 90.10/90.02 95.41
83.39 89.25 93.52 67.65 87.60 91.54/88.81 91.31
89.89/90.06 94.72 PAdapter
91.38 91.40/88.62 89.71 84.48 69.06
93.87 90.30/90.38 94.95 91.61/88.91 68.71 0.33M 88.15 94.03
91.68
0.32M AdaLoRA 90.66/90.70 95.80
91.78/89.16 70.04
2.为什么需要 PEFT? 在面对特定的下游任务时,如果进行 Full FineTuning (即对预训练模型中的所有参数都进行微调),太过低效; 而如果采用固定预训练模型的某些层,只微调接近下游任务的那几层参数,又难以达到较好的效果。
3.介绍一下 PEFT?

PEFT 技术旨在通过最小化微调参数…
PEFT 技术旨在通过最小化微调参数的数量和计算复杂度,来提高预训练模型在新任务上的性能,从而缓解大型 预训练模型的训练成本。这样一来,即使计算资源受限,也可以利用预训练模型的知识来迅速适应新任务,实现 高效的迁移学习。
4.PEFT 有什么优点? PEFT 技术可以在提高模型效果的同时,大大缩短模型训练时间和计算成本,让更多人能够参与到深度学习研究 中来。除此之外,FEFT 可以缓解全量微调带来灾难性遗忘的问题。
5.微调方法批处理大小模式 GPU 显存速度? 微调方法批处理大小模式 GPU 显存速度 LoRA (r=8)16 FP16 28GB 8ex/s LoRA (r=8)8 FP16 24GB 8ex/s
LoRA (r=8)4 INT8 10GB 8ex/s LoRA (r=8)4 INT4 8GB 8ex/s P-Tuning (p=16)4 FP16 20GB 8ex/s P-Tuning (p=16)4 INT8 16GB 8ex/s P-Tuning (p=16)4 INT4 12GB 8ex/s Freeze (1=3)4 FP16 24GB 8ex/s Freeze (1=3)4 INT8 12GB 8ex/s
- Peft 和全量微调区别? 所谓的 fune-tine 只能改变风格,不能改变知识,是因为我们的 fine-tune,像是 LoRA 本来就是低秩的,没办法对模 型产生决定性的改变.要是全量微调,还是可以改变知识的, 7. 多种不同的高效微调方法对比 像 P-Tuning v2、LoRA 等都是综合评估很不错的高效微调技术。如果显存资源有限可以考虑 QLoRA;如果只是解 决一些简单任务场景,可以考虑 P-Tuning、Prompt Tuning 也行。 下表从参数高效方法类型、是否存储高效和内存高效、以及在减少反向传播成本和推理开销的计算高效五个维度 比较了参数高效微调方法。

AAAA
Storage Memory Type Backprop | Inference overhead Extra FFN yes Extra FFN yes
yes Extra FFN
yes No overhead yes yes
No overhead yes yes No overhead yes No overhead yes No overhead Extra input yes yes Extra input yes yes
Extra input
yes yes
Extra FFN and input
yes yes
Extra FFN and input
yes yes
Extra FFN
yes yes No overhead R No overhead AR Extra FFN and input yes yes AR yes yes
Extra FFN yes
AR yes No overhead yes yes AR Extra linear layer yes
Extragating yes A
yes
Extra decoder A yes yes
yes Extra FFN yes yes yes Extra decoder yes S
maybe®
No overhead yes ARS Extra FFN and input yes
Evaluated on % Changed % Trainable
< 20B >20B parameters parameters yes yes yes 0.1-0.2 0.1-0.2 yes 2.0 2.0 yes 0.05-0.1 yes yes
0.5 yes 0.01-0.5 0.01-0.5 yes yes 0.1 0.1 yes yes 0.1-4.0 0.1-4.0 yes yes yes 0.5 0.5 0.5 0.5 ~0.1 or 100 yes yes 0.01-0.5 ~0.5 or ~30
yes
1.0 1.0 0.05-0.07 ~0.07 or ~0.1
0.2
0.07 ~0.07 or ~30.0 yes 0.02 0.02 7.5 7.5
yes 6.6-26.4 6.6-26.4 yes more than 0.5 0.5 yes
Adapters (Houlsby ct al.,2019) AdaMix (Wang ct al.,2022) SparseAdapter (He et al.,2022b) Cross-Attn tuning (Gheini et al.,2021)
Prompt Tuning (Lester et al.,2021) Prefix-Tuning (Li and Liang, 2021) Spot (Vu et al.,2021) IPT (Qin et al.,2021) MAM Adapter (He ct al.,2022a) Parallel Adapter (He et al.,2022a) Intrinsinc SAID (Aghajanyan et al.,2020) UniPELT (Mao et al.,2021) Compacter (Karimi Mahabadi ct al.,2021) PHM Adapter (Karimi Mahabadi et al.,2021) KronA (Edalati ct al.,2022)
Attention Fusion (Cao et al.,2022) Ladder Side-Tuning (Sung et al.,2022) S4-model (Chen et al.,2023) Comparing PEFT methods across storage cfficiency, memory cfficiency, and computational efficiency in
Ierms of reducing backpropagation costs and having inference overhead. Method wypes: A -&空魚产樂,
R - reparametrization-based.
下表展示了各种参数高效方法的参与训练的参数量、最终模型与原始模型的改变参数(delta 值)以及论文中参与 评估的模型的范围(<1B、<20B、>20B)。
Method
SparseAdapter (He et al.,2022b) DiffPruning (Guo et al.,2020) Fish-Mask (Sung ct al.,2021) Prompt Tuning (Lester et al.,2021) Prefix-Tuning (Li and Liang, 2021) IPT (Qin ct al.,2021) MAM Adapter (He ct al.,2022a) Parallel Adapter (He et al.,2022a) Intrinsinc SAID (Aghajanyan et al.,2020) LoRa (Hu ct al.,2021) Compacter (Karimi Mahabadi et al.,2021) PHM Adapter (Karimi Mahabadi ct al.,2021)
Ladder Side-Tuning (Sung et al.,2022) FAR (Vucetic et al.,2022) S4-model (Chen et al.,2023) What model sizes PEFlmethods have been evaluated on and their typical amount of trainable parameters used in the papers. By trainable parameter count we specifically mean the number parameters that are updated by a gradient optimization algorithm, not the delta between the original and final model which we denote "changed parameters". For reprametrization-based method we report parameters before and after reparametrization. Esti-
mating updated parameter count for S4 is complicated as the model uses different methods g 坚盟樂些 e
report the range at which the methods were cvaluated in the published literature. 从表中可以看到,Prompt Tuning、Prefix Tuning、LORA 等少部分微调技术针对不同参数规模的模型进行过评 估,同时,这几种方式也是目前应用比较多的高效微调方法。
