Skip to main content
QUICK REVIEW

[论文解读] LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attention

Renrui Zhang, Jiaming Han|arXiv (Cornell University)|Mar 28, 2023
Multimodal Machine Learning ApplicationsComputer Science被引用 167
一句话总结

LLaMA-Adapter 在冻结 LLaMA 的情况下,学习 1.2M 个适配器,采用零初始化的注意力,以实现与 Alpaca 相当的指令遵循性能,约在 8 个 A100 GPU 上进行一小时左右的微调,并支持多模态任务。

ABSTRACT

We present LLaMA-Adapter, a lightweight adaption method to efficiently fine-tune LLaMA into an instruction-following model. Using 52K self-instruct demonstrations, LLaMA-Adapter only introduces 1.2M learnable parameters upon the frozen LLaMA 7B model, and costs less than one hour for fine-tuning on 8 A100 GPUs. Specifically, we adopt a set of learnable adaption prompts, and prepend them to the word tokens at higher transformer layers. Then, a zero-initialized attention mechanism with zero gating is proposed, which adaptively injects the new instructional cues into LLaMA, while effectively preserves its pre-trained knowledge. With our efficient training, LLaMA-Adapter can generate high-quality responses, comparable to Alpaca with fully fine-tuned 7B parameters. Besides language commands, our approach can be simply extended to multi-modal instructions for learning image-conditioned LLaMA model, which achieves superior reasoning performance on ScienceQA and COCO Caption benchmarks. Furthermore, we also evaluate the zero-initialized attention mechanism for fine-tuning other pre-trained models (ViT, RoBERTa) on traditional vision and language tasks, demonstrating the superior generalization capacity of our approach. Code is released at https://github.com/OpenGVLab/LLaMA-Adapter.

研究动机与目标

  • 旨在在不进行全部参数更新的情况下高效微调 LLaMA,使其成为一个指令遵循模型。
  • 利用少量可学习的自适应提示,插入到较高的 Transformer 层。
  • 通过使用零初始化的注意力并带可学习门控来确保训练稳定性,以保留预训练知识。
  • 展示对多模态指令和其他模型族的可扩展性。

提出的方法

  • 在 LLaMA 的最顶层 L 个 transformer 层插入可学习的自适应提示。
  • 在每个目标层将提示 [P_l] 前置到输入标记中,表示为 [P_l; T_l]。
  • 用零初始化的注意力和逐头门控因子 g_l 来替代标准注意力,以控制自适应的影响。
  • 为自适应提示和词标记使用分离的 softmax 路径以稳定学习。
  • 通过在提示中加入图像标记 I_p 以进行视觉条件, 将该方法扩展到多模态输入。
  • 通过将零初始化的注意力应用于 ViT(VTAB-1k)和 RoBERTa(SQuAD)微调任务来展示泛化能力。

实验结果

研究问题

  • RQ1轻量级适配器配合零初始化注意力是否能在指令遵循任务上与全模型微调的性能相匹配?
  • RQ2用小型适配器冻结基础模型如何影响训练效率和资源使用?
  • RQ3该方法是否能推广到文本以外的多模态和其他模态?
  • RQ4在微调过程中,零初始化注意力对稳定性和最终性能是否至关重要?

主要发现

  • 1.2M 可学习参数足以实现接近于对 7B Alpaca 完全微调的指令遵循性能。
  • 在 8 个 A100 GPU 上的训练成本不到一个小时。
  • LLaMA-Adapter 能处理多模态指令,在 ScienceQA 和 COCO Caption 上取得具竞争力的结果。
  • 零初始化注意力结合门控显著提升稳定性和最终性能(相比随机初始化有大幅提升)。
  • 在 ViT(VTAB-1k)和 RoBERTa(SQuAD)任务上的应用也显示出强泛化能力。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。