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
Loss Function: Definition and Examples
A loss function is a mathematical formula that measures the gap between an AI model's predictions and the expected results. It guides
Machine Translation: Definition and Examples
Machine Translation refers to the use of software and artificial intelligence algorithms to automatically translate a text from one language to another, preserving meaning. This glossary entry explores its definition, history, examples, and practical use in prompt engineering.
Maieutic Prompting: Definition and Examples
Prompting technique inspired by Socratic maieutics, which consists of guiding a language model through a series of questions and sub-questions to
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.
Mega Prompt: Definition and Examples
A mega prompt is a long, structured instruction sent to an AI model, combining in a single message all necessary directives: context, r
Memory System: Definition and Examples
Mechanism allowing an AI model to retain, organize, and reuse information beyond a single conversation, simulating a form of persistent memory.
Get new prompts every week
Join our newsletter.