LoRA: Definition and Examples
LoRA (Low-Rank Adaptation) is an efficient fine-tuning technique that allows adapting a large language model or image generation model to a specific task by modifying only a tiny fraction of its parameters.
Full definition
LoRA, short for Low-Rank Adaptation, is a method for adapting artificial intelligence models developed by Microsoft researchers in 2021. Instead of retraining all billions of parameters of a model, LoRA injects small low-rank matrices into the neural network layers. This achieves results comparable to full fine-tuning while drastically reducing required resources (GPU memory, computation time, storage).
The principle is based on a mathematical observation: during fine-tuning, the modifications to model weights actually occupy a low-dimensional space. LoRA exploits this property by decomposing weight updates into two small matrices (A and B) whose product approximates the full update. Concretely, instead of modifying a weight matrix of size 10,000 × 10,000 (100 million parameters), two matrices of size 10,000 × 8 and 8 × 10,000 (160,000 parameters) are used, a reduction of over 99%.
In image generation, LoRA has become extremely popular with Stable Diffusion. Users create and share LoRAs trained on artistic styles, characters, or specific concepts. A LoRA file typically weighs only a few dozen megabytes, compared to several gigabytes for a full model, facilitating sharing and combination of multiple adaptations.
For language models (LLMs), LoRA enables companies and researchers to adapt models like LLaMA or Mistral to specific business domains (legal, medical, technical) without requiring expensive GPU servers. This democratization of fine-tuning has significantly accelerated the adoption of generative AI in various professional contexts.
Etymology
LoRA is an acronym for "Low-Rank Adaptation of Large Language Models," introduced in a research paper published by Edward Hu et al. at Microsoft Research in June 2021. The term "low-rank" refers to a linear algebra concept describing matrices that can be decomposed into products of smaller matrices.
Concrete examples
Fine-tuning an image generation model to reproduce a specific artistic style
a portrait of a woman in the style of lora:impressionist_style:0.8, oil painting, soft brushstrokes, natural lighting
Adapting an LLM to respond in a specialized legal domain
As a legal assistant specialized in French labor law, analyze the following non-compete clause and identify points of non-compliance with recent case law.
Combining multiple LoRAs for precise results in image generation
photo of a cyberpunk city at night lora:cyberpunk_architecture:0.7 lora:neon_lighting:0.5, 8k, detailed, cinematic composition
Practical usage
In prompt engineering, understanding LoRA allows leveraging specialized models for more accurate results without modifying prompts in complex ways. When a LoRA is active, it often suffices to use the associated activation keywords to trigger the learned style or behavior. For image generation, the LoRA weight (typically between 0.5 and 1.0) can be adjusted directly in the prompt to control the intensity of its effect.
Related concepts
FAQ
What is the difference between LoRA and classic fine-tuning?
Can multiple LoRAs be used at the same time?
Do you need technical skills to use a LoRA?
See also
How to use this prompt
- Copy the prompt with the button above.
- Paste it into ChatGPT, Claude or your favorite AI assistant.
- Replace the bracketed variables with your details, then refine the result.
About Prompt Guide
Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.
More definitions
MCP Model Context Protocol: Definition and Examples
The Model Context Protocol (MCP) is an open standard that allows AI models to connect to external data sources, tools, and services.
Million Token Context: Definition and Examples
Capacity of a language model to process up to a million tokens in a single request, enabling analysis of very large documents, codebases
Model Card: Definition and Examples
A model card is a standardized document that accompanies an AI model to describe its performance, limitations, potential biases, and conditions of use
Model Registry: Definition and Examples
A Model Registry is a centralized system for storing, versioning, and managing machine learning models throughout their lifecycle, from training to production deployment.
Multimodal RAG: Definition and Examples
Multimodal RAG is an extension of Retrieval-Augmented Generation that allows an AI model to search and leverage information from sources
Needle In Haystack: Definition and Examples
The Needle In a Haystack (NIAH) test is an evaluation method that measures a language model's ability to retrieve a specific piece of information buried in a long context.
Get new prompts every week
Join our newsletter.