It is August 2022. Stable Diffusion has just made high-quality text-to-image generation something anyone can run on a personal GPU, but the model only knows what was in its training set. It can draw “a dog” in any style requested; it cannot draw your dog. Within three weeks, two research groups publish opposite answers to the same question: how do you teach a pretrained diffusion model one new, specific thing from only a handful of photographs?
Where We Were
By mid-2022 the pieces this book’s latent diffusion chapter covers were in place: a frozen text encoder produces a conditioning vector from a prompt, and a U-Net trained with the DDPM loss denoises a latent while attending to that conditioning through cross-attention. CLIP-style contrastive text-image pretraining gives the text encoder its shared vocabulary of visual concepts, and classifier-free guidance sharpens how strongly the output follows the prompt. All of this machinery generates classes of things — dogs, mugs, sunsets in a particular painter’s style — because those classes, described in natural language, were well represented across the model’s training data.
What none of it could do was reproduce one specific instance of a class that the model had never seen: a particular corgi, a particular person’s face, a specific ceramic mug from a specific studio. Asking for “a photo of my dog” produces a generic dog, because the text encoder has no token or embedding that refers to that one animal. The obvious fix — fine-tune the entire model on a few photos of the subject — runs into a problem familiar from other fine-tuning settings: with only three to five images and a model containing hundreds of millions of parameters, naive full fine-tuning overfits quickly, and it also tends to erode the model’s general vocabulary, a failure mode later work would name language drift — after a few hundred steps of retraining on photos of one dog, prompting for “a dog running” might start producing only that specific dog even when the prompt describes an unrelated scene.
Two questions therefore separated: could a new concept be taught without touching the network’s weights at all, working instead within the vocabulary the frozen model already understood? And if the weights had to move, could the update be shaped so that the model’s general knowledge survived alongside the new, narrow fact it was being asked to memorize?
The Breakthrough
Textual Inversion (Gal et al., 2022) answered the first question by refusing to touch the model at all. Every weight in the U-Net and the text encoder stays frozen. What changes is the input: the method introduces a new pseudo-word, written , and searches for a single embedding vector that this pseudo-word should map to, so that prompts containing reproduce the target concept. Because lives in exactly the same embedding space the text encoder already uses for every other word, it can be dropped into ordinary prompts — “a photo of wearing a hat” — and the frozen model composes it with the rest of its existing vocabulary. The paper trains this one vector on three to five images per concept, optimizing for roughly 5,000 steps on two V100 GPUs, a run the paper reports takes about two hours. The result is small by construction: the entire “fine-tune” is one new vector, nothing else in the model moves.
DreamBooth (Ruiz et al., 2022), submitted three weeks later out of Google Research and Boston University, took the opposite route: fine-tune the model’s weights directly, subject and all. A handful of photos — again three to five — are paired with a prompt containing a rare token the vocabulary rarely uses (selected so it carries little prior meaning of its own) plus the subject’s class noun, such as “a [V] dog.” Full fine-tuning on so few images would ordinarily overfit or drift, so DreamBooth adds a second loss term computed simultaneously: samples generated by the frozen model for the plain class prompt “a dog,” used as a regularization target so the fine-tuned model keeps producing generic dogs when asked for one, instead of collapsing every dog into the one subject it just learned. The rare token itself is not chosen at random from the whole vocabulary — the paper samples from a range of the T5-XXL tokenizer’s tokens corresponding to three or fewer Unicode characters with no spaces, then decodes that token back into text, on the reasoning that a token which rarely appears on its own carries little pre-existing meaning for the model to fight against. Training runs for roughly a thousand iterations and — for Stable Diffusion specifically — about five minutes on a single NVIDIA A100. Measured against Textual Inversion on subject fidelity, DreamBooth’s reported DINO similarity score is 0.668 versus 0.569, and in a human preference study, evaluators favored DreamBooth’s subject fidelity 68% of the time against 22% for Textual Inversion.
The two papers had traced the extremes of a spectrum: touch almost nothing and accept limited fidelity, or touch everything and pay for a full fine-tune per subject. LoRA (Hu et al., 2021) — designed a year earlier for large language models and covered in full in this book’s sister volume’s PEFT and LoRA chapter — offered a middle path once the diffusion community adapted it to the U-Net. Rather than optimizing a single embedding or retraining the whole network, LoRA freezes every original weight matrix and inserts a small, additive low-rank update next to a chosen subset of them, training only that update. Applied to diffusion, the natural target is the cross-attention layers that connect the U-Net to the text conditioning covered in the latent-diffusion chapter — the query, key, and value projections that let text tokens steer image denoising are exactly where a subject or a style needs to leave its mark. Because the update merges back into the frozen weight after training, it costs nothing at inference and, being low-rank, costs very little to store: Hugging Face’s diffusers integration of the method reported adapter files as small as a few megabytes, roughly a thousand times smaller than the U-Net they modify — Replicate’s own February 2023 comparison of the two workflows found LoRA training on Stable Diffusion completing in about eight minutes and producing files around 5 MB, against roughly twenty minutes and several gigabytes for a full DreamBooth run.
The Mathematics
Textual Inversion’s objective looks exactly like the ordinary diffusion training loss this book’s diffusion foundations chapter derives, with one crucial restriction on what is allowed to change:
| Symbol | Meaning |
|---|---|
| The learned embedding for the pseudo-word , the only trainable quantity | |
| Latent code of a training image, from the frozen autoencoder | |
| A text prompt containing the placeholder | |
| Noise added during the forward diffusion process | |
| The frozen U-Net’s noise-prediction network | |
| Conditioning vector produced by the frozen text encoder from | |
| Diffusion timestep |
DreamBooth optimizes the same kind of noise-prediction loss but over the full network, and adds a second term evaluated on the frozen model’s own outputs to hold the wider class steady:
| Symbol | Meaning |
|---|---|
| A ground-truth subject photo | |
| Text embedding of a subject prompt containing the rare-token identifier | |
| A class sample generated by the frozen model before fine-tuning | |
| Text embedding of the plain class prompt | |
| Independent noise draws for the subject and class terms | |
| Noise-schedule coefficients at timestep | |
| Independently sampled timesteps for the two terms | |
| Loss weighting at each timestep | |
| Strength of the prior-preservation term |
LoRA’s own decomposition — freezing a weight matrix and adding a trained low-rank update — is derived in full in the PEFT and LoRA chapter; this chapter only needs to say where that update lands inside a diffusion U-Net. Cross-attention conditions image generation on text through three projections — query, key, and value — and LoRA-for-diffusion attaches its own low-rank pair to each:
| Symbol | Meaning |
|---|---|
| The frozen cross-attention query, key, and value projection matrices | |
| The projections used at inference, after the trained low-rank update is merged in | |
| / / | The low-rank factor pair trained for each projection; shape, rank, and initialization are covered in the PEFT and LoRA chapter |
| The LoRA scaling constant and rank, defined once in the PEFT and LoRA chapter |
What It Enabled
| Method | Year | What moves | Typical training time | Typical artifact size |
|---|---|---|---|---|
| Full DreamBooth fine-tune | 2022 | Entire U-Net and text encoder | ~20 minutes (SD, single GPU) | Several gigabytes |
| Textual Inversion | 2022 | One embedding vector | ~2 hours (2×V100) | Kilobytes |
| LoRA-for-diffusion | adapted 2023 | Low-rank update to targeted weight matrices | ~8 minutes (SD, single GPU) | Around 5 MB |
The practical effect was to collapse “personalize a diffusion model” from a full-model retraining problem into something closer to downloading a small file. Because a LoRA adapter is additive and mergeable, the same frozen Stable Diffusion checkpoint can host any number of subject- or style-specific adapters, swapped in at load time rather than baked into separate multi-gigabyte checkpoints — the same serving pattern this book’s sister volume describes for inference engines multiplexing many fine-tuned variants against one base model. That portability is what let LoRA sharing become a community activity rather than a lab-scale exercise: by the time SDXL shipped in July 2023, LoRA had become the default way the open-source Stable Diffusion community distributed both character and style fine-tunes, alongside the spatial and reference-image conditioning methods this book covers next in control and the training-free approaches covered in editing. The same low-rank pattern carried forward into the rectified-flow transformer backbones this book covers in flow matching and transformer backbones, where FLUX and SD3-era models are fine-tuned with LoRA rather than full retraining as a matter of course.
Personalization and control solve related but distinct problems worth keeping separate: Textual Inversion, DreamBooth, and LoRA answer “how do I teach the model a new subject or style,” while ControlNet-style conditioning, covered next, answers “how do I specify the exact pose, depth, or layout of a generation.” A production pipeline built after 2023 routinely combines both — a LoRA for the client’s product, layered with spatial conditioning for the exact shot composition.
The rank of the low-rank update is the knob that trades cost against expressiveness, and the diffusion community treated it as a tunable rather than a constant: a low-rank adapter trained only on cross-attention captures a style or a simple subject cheaply, while a higher-rank adapter, or one extended to the U-Net’s convolutional layers and the text encoder as well, approaches DreamBooth-level subject fidelity at a proportionally larger — though still comparatively small — file size. Community LoRA-sharing platforms that emerged around Stable Diffusion formalized this as a spectrum of adapter types rather than one fixed recipe: style LoRAs trained on an artist’s body of work, character LoRAs trained on a specific fictional or real subject, and concept LoRAs trained on an object, pose, or clothing item, all using the identical mechanism with different training data and different rank choices.
Key Papers
| Paper | Authors | Year | Link | Why it matters |
|---|---|---|---|---|
| An Image is Worth One Word: Personalizing Text-to-Image Generation using Textual Inversion | Gal et al. | 2022 | arXiv:2208.01618 | Personalizes by learning one new embedding vector; frozen model, smallest possible footprint |
| DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation | Ruiz et al. | 2022 | arXiv:2208.12242 | Full-weight fine-tuning with class prior preservation; highest subject fidelity, highest cost |
| LoRA: Low-Rank Adaptation of Large Language Models | Hu et al. | 2021 | arXiv:2106.09685 | Low-rank additive update, later attached to diffusion cross-attention; DreamBooth-level fidelity at a fraction of the cost |
PM Lens
Papers referenced
- An Image is Worth One Word: Personalizing Text-to-Image Generation using Textual Inversion Gal et al. · 2022 · arXiv:2208.01618
- DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation Ruiz et al. · 2022 · arXiv:2208.12242
- LoRA: Low-Rank Adaptation of Large Language Models Hu et al. · 2021 · arXiv:2106.09685