When generation controls are no longer enough
Lesson 8 changed prompts, seeds, masks, guidance, and structural inputs while the pretrained model stayed fixed. This lesson is different: training-time adaptation changes learned embeddings or learned parameter updates so the model can represent a subject, visual concept, or style it does not reliably produce through prompting alone.
Start with prompting and inference-time control because they require no training data or new weights. Adapt only when a repeated, well-defined gap remains—for example, a product with a distinctive shape must appear consistently across new scenes. Adaptation is not a substitute for clearer prompts, a better base model, or structural control.
Fine-Tuning Image Models in Simple Words
Imagine teaching a celebrity photographer your company’s unique new water bottle. You don't retrain their entire brain from scratch (which costs millions). Instead, with LoRA (Low-Rank Adaptation), you hand them a tiny, pocket-sized notebook describing only the new bottle’s contours. Their existing artistic genius remains intact, while they seamlessly integrate your brand with 99% less memory and tiny 15 MB file sizes!
Freeze Base
Keep 1B+ base parameters completely static
Low-Rank Matrices
Inject tiny trainable pairs: W = W₀ + (B × A)
Adapter Training
Optimize only ~0.2% of weights on few images
Modular Swap
Save lightweight 15MB adapter files to swap at will
The dataset teaches what the method will learn
Training images are data-supplied evidence. They should be sharp, lawful to use, varied enough to separate the intended concept from accidental backgrounds, and paired with captions that name what should vary and what should remain associated with the concept. If every product photograph uses the same white table, the model may learn “white table” as part of the product.
Validation prompts are developer-written prompts held outside the update loop. They combine the new concept with unseen settings, viewpoints, and attributes. Because no gradient update uses them, they reveal whether an adapter generalizes rather than merely reproducing training compositions.
Three adaptation methods solve different problems
| Method | What is learned | How much of the base changes | Relative cost and storage | Typical use | Important limitation |
|---|---|---|---|---|---|
| Textual Inversion | One or a few new token embeddings that point to a visual concept | Base model remains frozen | Usually the smallest artifact and lightest training | Associate a placeholder token with a subject or style concept | Limited capacity; complex identity or composition may be weak |
| DreamBooth | Model parameters adapted to bind a rare identifier to a subject | A larger part of the model may be updated; variants differ | Higher training and checkpoint cost | Personalize a model to a particular subject from a small image set | Can overfit, drift, or forget broader class knowledge without careful regularization |
| LoRA | Small low-rank update matrices attached to selected layers | Original weights stay frozen; adapters supply ΔW | Much smaller trainable state than a full checkpoint when rank is small | Portable subject, style, or domain adaptation | Rank, target layers, data, and scale still affect fidelity and overfitting |
Figure 1 — Textual Inversion, DreamBooth, and LoRA differ mainly in what training is allowed to change
All three begin with a pretrained generator. Textual Inversion learns a small token representation, DreamBooth adapts more model capacity in an implementation-dependent way, and LoRA learns compact low-rank side matrices while the original weight stays frozen.
A shared frozen pretrained model branches into three distinct adaptation diagrams. Textual Inversion adds one trainable row to a token embedding table while the base model remains frozen and saves a tiny embedding artifact. DreamBooth highlights several adaptable regions inside a larger model, notes that implementations vary and do not necessarily update every parameter, and saves a larger-capacity artifact. LoRA shows a frozen W matrix beside narrow trainable A and B matrices and saves a compact adapter. Capacity bars compare the relative amount of learned state conceptually rather than claiming universal file sizes.
How LoRA changes a frozen weight
Imagine a pretrained layer has a learned weight matrix W. Full fine-tuning would update every value in W. LoRA freezes W and learns two narrower matrices, A and B. Their product creates an update with the same shape as W.
- W is the pretrained matrix supplied by the base model and kept frozen.
- A and B are learned during adaptation; their narrow shared dimension is rank r.
- ΔW is calculated by matrix multiplication and has the same shape as W.
- scale is a developer-chosen multiplier controlling the adapter contribution.
- W′ is the effective adapted weight used by the layer.
Figure 2 — LoRA adds a narrow trainable path beside the frozen base weight
Toy shapes for teaching: W is 4 × 4, A is 1 × 4, and B is 4 × 1. Real layers are usually much larger. W stays fixed; A and B train; both paths are added to produce the adapted output.
Input x splits into two paths. The base path multiplies x by a frozen four by four matrix W to produce W x. The adapter path multiplies x by a trainable one by four matrix A, creating a rank-one representation, then by a trainable four by one matrix B to produce B A x. A chosen scale multiplies the adapter result. The frozen W x and scaled B A x meet at a plus operator and produce the adapted output W x plus scale times B A x. The narrow drawings of A and B show why the update is low rank.
Toy parameter-count example
This deliberately tiny 4 × 4 matrix is only for arithmetic; real diffusion layers are much larger. A full matrix contains 4 × 4 = 16 parameters. For rank 1, A has shape 1 × 4 and B has shape 4 × 1, so the adapter learns 4 + 4 = 8 parameters. For rank 2, A is 2 × 4 and B is 4 × 2, so it learns 8 + 8 = 16 parameters.
The output size m and input size n come from the existing layer. Rank r is a developer-chosen adapter capacity. LoRA saves trainable parameters when r(m + n) is smaller than mn. The toy rank-2 case has no count saving, which makes clear that “low rank” must be small relative to the real dimensions.
Check the toy parameter counts
This self-contained Python 3 program prints the exact counts discussed above. It does not fine-tune a model; it demonstrates why rank and matrix size matter.
# Runnable Python 3: compare full and LoRA parameter counts.
def counts(out_features, in_features, rank):
full = out_features * in_features
lora = rank * in_features + out_features * rank
return full, lora
for rank in (1, 2):
full, lora = counts(out_features=4, in_features=4, rank=rank)
print(f"4x4 full={full}, rank-{rank} LoRA={lora}")Separate training from using a trained adapter
This conceptual pseudocode shows where learning happens. Loading a previously trained LoRA for generation is inference, not fine-tuning.
# Conceptual pseudocode — an adaptation workflow, not a library API.
training_pairs = check_rights_and_prepare(image_caption_pairs)
validation_prompts = hold_out_prompts_not_used_for_updates(training_pairs)
freeze(base_diffusion_model)
adapter = attach_lora_layers(base_diffusion_model, chosen_rank)
for images, captions in training_pairs:
loss = diffusion_training_loss(base_diffusion_model, adapter, images, captions)
update_only(adapter.parameters, loss)
save(adapter)
compare_checkpoints_on(adapter, validation_prompts)A practical method-selection guide
| Situation | Try first | Reason | Validation question |
|---|---|---|---|
| Existing model already knows the concept | Prompting or Lesson 8 controls | No new training state is needed | Can seed and structure controls make it repeatable? |
| Small concept represented by a token | Textual Inversion | Minimal learned artifact | Does the concept work in unseen contexts? |
| Specific subject identity is central | DreamBooth or a subject-focused LoRA | More adaptation capacity | Is identity preserved without copying poses and backgrounds? |
| Portable style or domain adapter | LoRA | Compact, modular learned update | Does style strength remain controllable on held-out prompts? |
Fine-Tuning Method Resource Footprint vs Checkpoint Size
LoRA delivers over 85% of full fine-tuning flexibility with less than 0.5% of the checkpoint storage size!
Summary / Key Takeaways
- Fine-tuning is training-time adaptation: it changes learned embeddings or parameter updates, unlike prompts, masks, seeds, and other inference-time controls.
- Adapt only after a repeated, well-defined gap remains and prompting, a better base model, or structural control has been tested.
- Textual Inversion learns a small token embedding, DreamBooth adapts more model capacity for a subject, and LoRA learns compact low-rank updates beside frozen weights.
- LoRA uses ΔW = BA and W′ = W + scale × ΔW; its parameter saving depends on rank r being small relative to the original matrix dimensions.
- Training images and captions must separate the intended concept from accidental backgrounds, poses, or other correlations.
- Held-out prompts reveal whether an adapter generalizes instead of copying training compositions.
- Choose the least invasive method that closes the measured gap without memorization, leakage, catastrophic forgetting, or rights violations.