Archive of AI

Source Snapshot / 2021-06-17-microsoft-lora-peft-3

LoRA: Low-Rank Adaptation of Large Language Models - Microsoft Research

Linked event: 2021-06-17 · Microsoft Research Proposes and Open-Sources LoRA, Establishing the Standard for Low-Cost Large Model Fine-Tuning

Publisher
Microsoft Research
Archived
2026-11-23
Capture Method
Direct page capture
HTTP / SHA-256
200 / c7975b3b7e2763c2
Original URL
Open source ↗
Wayback Backup
Not archived
This page preserves a plain-text static snapshot against link rot. When citing figures, tables, or full legal terms, verify against the original URL and Wayback Machine archive.

Publications

Code, datasets and models

Artificial intelligence

Audio & acoustics

Computer vision

Graphics & multimedia

Human-computer interaction

Human language technologies

Search & information retrieval

Data platforms and analytics

Hardware & devices

Programming languages & software engineering

Quantum computing

Security, privacy & cryptography

Systems & networking

Ecology & environment

Medical, health & genomics

Social sciences

Technology for emerging markets

Academic programs

Events & academic conferences

Microsoft Research Forum

Microsoft Research Blog

Microsoft Research Podcast

Microsoft Research Stories

About Microsoft Research

Careers & internships

News & awards

AI for Science

Asia-Pacific

Catalyst Lab

New York City

Register: Research Forum

Microsoft Security

Dynamics 365

Microsoft 365

Microsoft Teams

Microsoft AI

Mixed reality

Microsoft HoloLens

Microsoft Viva

Sustainability

Financial services

Manufacturing

Find a partner

Become a partner

Partner Network

Microsoft Marketplace

Software companies

Microsoft Advertising

Developer Center

Documentation

Microsoft Learn

Microsoft Research

View Sitemap

LoRA: Low-Rank Adaptation of Large Language Models

Edward J. Hu

Phillip Wallis

Zeyuan Allen-Zhu

| April 2022

Download BibTex

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 a factor of 10,000 and the GPU memory requirement by a factor of 3. 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 on GitHub (opens in new tab).

Opens in a new tab

Related Tools

April 22, 2022

This repo contains the source code of the Python package loralib and several examples of how to integrate it with PyTorch models, such as those in HuggingFace. We only support PyTorch for now. See our paper for a detailed description of LoRA.

Video playback requires cookie consent

Getting Modular with Language Models: Building, Reusing a Library of Experts for Task Generalization

Presented by Alessandro Sordoni at Microsoft Research Forum, Season 1, Episode 2

Alessandro Sordoni shared recent efforts on building and re-using large collections of expert language models to improve zero-shot and few-shot generalization to unseen tasks.

All Research Forum sessions

Register for the series

Getting modular with language models: Building and reusing a library of experts for task generalization

Hi, everyone. My name is Alessandro. I’m from Montréal. I’m going to share with you a vision for building, sort of, modular language models.

So we have witnessed basically the wide adoption of large language models, such as GPT-4, that have very broad capabilities and can be used to solve a variety of tasks. But they are, kind of, expensive to serve, and somehow, we can actually think and ask ourselves, are they really necessary for most tasks that users for Microsoft, for example, might need?

This has basically boosted the development of small language models—for example, the mighty and very powerful Phi-2—that can be adapted to user tasks, right. Either with full fine-tuning, which means we change all the parameters of the model, or with parameter-efficient adaptation, for example, by training LoRAs, which only change a small amount of the parameters of the model. And basically, if we can see these experts, basically these model adapters, as experts at their own tasks, right … and this is great because we have now a cost-effective model that can solve the tasks very effectively. But the problem now is that we have only very narrow capabilities. So the question that we ask here is that now that we have all these experts models for each user, for each task, can we actually reuse the experts models for either building small models that have broader capability or for adapting to new users and tasks more efficiently?

Let me show you how this system could work. So we start from a base model, which is Phi-2, and we adapt this base model for every user or for a set of tasks, and we group these, sort of, adapters into a library. And now we, kind of, come up with a, sort of, orchestration mechanism that chooses which adapters to use based on a new user query to produce a system response. The system has, sort of, some desirable properties. One is that it enhances the base language model capabilities via such an expert composition, and this resembles, a little bit, how mixture of experts work, right. But there is a big difference here. It’s that these experts are not trained with the base model itself, but they are trained a posteriori. This leads us to the second point, which is basically a, sort of, decentralized training of these LoRA experts, and this is good because somehow users … for example, this preserves privacy in the sense that we do not need—we do not require—all the data to be shared at once and to always retrain the base model from scratch. And second, energy efficiency. These LoRA experts are very energy efficient. And so basically, we can train it very quickly. The third point is interpretability because these experts are basically associated with the task, usually, that they can solve. And so upon seeing a new user query, we can actually inspect which expert has been activated for that user query, and we can get a little bit of a sense of which actually capabilities are required.

[...内容已截断,完整版请查看原文或 Wayback 快照]