---
title: "Chapter 01: Why Images First"
description: "LoRA's knobs are identical in image and text training — but in images, you can see when it goes wrong. Set up mflux and read the source."
type: lesson
order: 1
chapter: "01-lora-eyes-open"
---

# Chapter 01: Why Images First

## Objective

Build calibrated intuition for what LoRA hyperparameters actually do, using a modality where the failure modes are visible rather than inferred from a loss curve.

## What LoRA Actually Is

Freeze the base transformer. Inject low-rank A·B matrices into the attention projections. Train only those.

That's the whole trick. Instead of updating billions of parameters, you train a small delta — the adapter — that steers the frozen base model. The adapter is a few megabytes. You can attach it, detach it, scale it, or merge it into the base weights.

The knobs you'll be turning for the rest of this course:

| Knob | What it controls |
|---|---|
| **Rank** | Capacity of the adapter. Higher = more expressive, more prone to memorizing |
| **Alpha** | Scaling of the adapter's contribution |
| **Target modules** | Which layers get adapters (attention only? all linear layers?) |
| **Steps** | How long you train. The underfit → learned → memorized axis |
| **Dataset size** | How much signal you're distilling into the adapter |
| **Adapter scale** | At inference: adapters are *dials*, not switches |

## Why This Is First

Rank, alpha, target modules, steps, dataset size, overfitting, adapter-vs-merged — these are *the same knobs* in image and text LoRA. The math is identical. What differs is the loss function (denoising over latents vs. next-token prediction) and the data shape.

The difference that matters pedagogically: **when an image LoRA overfits, you *see* it.** Every generation returns the same photo. When a text LoRA overfits, you get plausible-looking sentences and a slightly-off eval number three hours later.

So we build the intuition where feedback is instant and visual, then carry it to text where it isn't.

## Setup

```bash
uv venv && source .venv/bin/activate
uv pip install mflux
```

mflux is a line-by-line MLX port of FLUX from the HuggingFace Diffusers implementation. It's intentionally minimal — architectures are hardcoded, there are no config abstractions except tokenizers.

## Homework: Read the Source

Read the mflux source. It's short enough to read in an evening, and it is one of the clearest expositions of a diffusion transformer available. You'll be waiting on training runs anyway — this is what to do during them.

This module is deliberately throwaway. The artifact is in your head.

---

[← Part 1 Index](/fine-tune-local-agent/01-lora-eyes-open/) · [Next: Chapter 02 →](/fine-tune-local-agent/01-lora-eyes-open/02-train-an-adapter/)
