low-rank adaptation (LoRA)
Low-rank adaptation (LoRA) is a parameter-efficient fine-tuning method that adapts a large model to a new task without retraining all of its weights. LoRA freezes those pretrained weights and learns each update as a pair of small matrices injected into the layers of the transformer architecture.
Rather than rewriting a full weight matrix, LoRA represents the change to it as the product of two thin matrices whose shared inner dimension is the rank, typically a small value such as eight or sixteen. The number of trainable parameters drops by orders of magnitude, and the adapters usually attach only to the self-attention projections. Trying different ranks on a single 1024 by 1024 projection shows how steeply the trainable count falls.
Introduced in 2021 by Hu and colleagues at Microsoft, LoRA reduced the trainable parameters of GPT-3 175B by ten thousand times against full fine-tuning with the Adam optimizer, and its GPU memory requirement by three times. It doesn’t add inference latency, because the trained matrices can be merged back into the frozen weights.
Each adapter is a small file, so one base model can host many of them, one per task. Hugging Face PEFT is a common implementation, and QLoRA extends the method by quantizing the frozen base to 4-bit precision.
Related Resources
Tutorial
Hugging Face Transformers: Leverage Open-Source AI in Python
As the AI boom continues, the Hugging Face platform stands out as the leading open-source model hub. In this tutorial, you'll get hands-on experience with Hugging Face and the Transformers library in Python.
For additional information on related topics, take a look at the following resources:
- Python AI: How to Build a Neural Network & Make Predictions (Tutorial)
- PyTorch vs TensorFlow for Your Python Deep Learning Project (Tutorial)
- How to Use Ollama to Run Large Language Models Locally (Tutorial)
- Build an LLM RAG Chatbot With LangChain (Tutorial)
- Building a Neural Network & Making Predictions With Python AI (Course)
- Hugging Face Transformers (Quiz)
- Python Deep Learning: PyTorch vs Tensorflow (Course)
- How to Use Ollama to Run Large Language Models Locally (Quiz)
- First Steps With LangChain (Course)
- Build an LLM RAG Chatbot With LangChain (Quiz)
By Martin Breuss • Updated Aug. 21, 2026