Skip to main content
QUICK REVIEW

[Paper 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 Science167 citations
TL;DR

LLaMA-Adapter freezes LLaMA and learns 1.2M adapters with zero-initialized attention to achieve instruction-following performance comparable to Alpaca, with ~1 hour of fine-tuning on 8 A100 GPUs and support for multi-modal tasks.

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.

Motivation & Objective

  • Aim to efficiently fine-tune LLaMA into an instruction-following model without full parameter updates.
  • Leverage a small set of learnable adaption prompts inserted at higher transformer layers.
  • Ensure stable training by using zero-initialized attention with learnable gating to preserve pre-trained knowledge.
  • Demonstrate extensibility to multi-modal instructions and other model families.

Proposed method

  • Insert learnable adaption prompts at the topmost L transformer layers of LLaMA.
  • Prepend prompts [P_l] to input tokens at each target layer as [P_l; T_l].
  • Replace standard attention with zero-initialized attention and a per-head gating factor g_l to control adaptation influence.
  • Use separate softmax paths for adaption prompts and word tokens to stabilize learning.
  • Extend the approach to multi-modal inputs by incorporating an image token I_p into the prompts for visual conditioning.
  • Show generalization by applying zero-initialized attention to ViT and RoBERTa fine-tuning tasks.

Experimental results

Research questions

  • RQ1Can lightweight adapters with zero-initialized attention match full-model fine-tuning performance on instruction-following tasks?
  • RQ2How does freezing the base model with small adapters affect training efficiency and resource usage?
  • RQ3Does the method generalize to multi-modal and other modalities beyond text?
  • RQ4Is zero-initialized attention critical for stability and final performance during fine-tuning?

Key findings

  • 1.2M learnable parameters are sufficient to achieve instruction-following performance close to fully fine-tuned 7B Alpaca.
  • Training costs less than one hour on 8 A100 GPUs.
  • LLaMA-Adapter can handle multi-modal instructions, achieving competitive results on ScienceQA and COCO Caption.
  • Zero-initialized attention with gating substantially improves stability and final performance (large gain vs rand-init).
  • The approach also yields strong generalization when applied to ViT (VTAB-1k) and RoBERTa (SQuAD) tasks.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.