LoRA: Low-Rank Adaptation of Large Language Models

Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang and 2 more

Published
Lab
Microsoft
Code
GitHub
Citations
26,623

TL;DR

LoRA freezes a pre-trained model and trains small rank-decomposition matrices in each Transformer layer, so you can adapt a large model without updating all of its weights.

Read this as a

Why builders care

Editor's note

Hosting a full fine-tune of a 175B model for every task is expensive. LoRA cut trainable parameters by 10,000 times and GPU memory by 3 times versus Adam fine-tuning of GPT-3 175B, matched or beat full fine-tuning, and added no inference latency.

How to apply it

Editor's note
  1. 1For a new task or domain, attach LoRA adapters instead of fine-tuning every weight, especially when you would otherwise host one full copy per task.
  2. 2Expect no extra latency at inference, unlike some adapter methods. The paper reports on-par or better quality on RoBERTa, DeBERTa, GPT-2 and GPT-3.
  3. 3A PyTorch package, implementations and checkpoints are in the Microsoft LoRA repository linked from the abstract.

Code

Verified link

Practical notes

AI-generated
  • Freeze the pre-trained model weights and inject trainable rank decomposition matrices into each layer of the Transformer architecture.
  • Use the provided PyTorch package to facilitate the integration of LoRA with your models.

Key results

From the abstract
  1. 1

    Compared to GPT-3 175B fine-tuned with Adam, LoRA can reduce the number of trainable parameters by 10,000 times and the GPU memory requirement by 3 times.

  2. 2

    LoRA performs on-par or better than fine-tuning in model quality on RoBERTa, DeBERTa, GPT-2, and GPT-3, despite having fewer trainable parameters, a higher training throughput, and, unlike adapters, no additional inference latency.

  • An important paradigm of natural language processing consists of large-scale pre-training on general domain data and adaptation to particular tasks or domains.
  • As we pre-train larger models, full fine-tuning, which retrains all model parameters, becomes less feasible.
  • Using GPT-3 175B as an example -- deploying independent instances of fine-tuned models, each with 175B parameters, is prohibitively expensive.

  • We propose Low-Rank Adaptation, or LoRA, which freezes the pre-trained model weights and injects trainable rank decomposition matrices into each layer of the Transformer architecture, greatly reducing the number of trainable parameters for downstream tasks.
  • We also provide an empirical investigation into rank-deficiency in language model adaptation, which sheds light on the efficacy of LoRA.

An important paradigm of natural language processing consists of large-scale pre-training on general domain data and adaptation to particular tasks or domains. As we pre-train larger models, full fine-tuning, which retrains all model parameters, becomes less feasible. Using GPT-3 175B as an example -- deploying independent instances of fine-tuned models, each with 175B parameters, is prohibitively expensive. We propose Low-Rank Adaptation, or LoRA, which freezes the pre-trained model weights and injects trainable rank decomposition matrices into each layer of the Transformer architecture, greatly reducing the number of trainable parameters for downstream tasks. Compared to GPT-3 175B fine-tuned with Adam, LoRA can reduce the number of trainable parameters by 10,000 times and the GPU memory requirement by 3 times. LoRA performs on-par or better than fine-tuning in model quality on RoBERTa, DeBERTa, GPT-2, and GPT-3, despite having fewer trainable parameters, a higher training throughput, and, unlike adapters, no additional inference latency. We also provide an empirical investigation into rank-deficiency in language model adaptation, which sheds light on the efficacy of LoRA. We release a package that facilitates the integration of LoRA with PyTorch models and provide our implementations and model checkpoints for RoBERTa, DeBERTa, and GPT-2 at https://github.com/microsoft/LoRA.

Everything on this page is written from this abstract. For methods and full results, read the paper PDF.

Ask the paper

Answers come from the paper summary and abstract.

Ask anything about “LoRA: Low-Rank Adaptation of Large Language Models”, or start with one of these:

Closest matches across the feed and every collection, by shared words in titles, topics and abstracts.