TheFocus.AI TheFocus.AI
01 lora eyes open Lesson 1

Chapter 01: Why Images First

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.

TUTOR WITH THEFOCUS.AI

Agent Integration

Copy this prompt into Claude, ChatGPT, or any external AI assistant. It points the assistant to the course instructions and links it to your student profile to track your progress and customize observations.

Please tutor me in this lesson using the following context. First, read the instructions at: https://courses.thefocus.ai/llms.txt My Student ID is: <none> The lesson markdown source is at: https://courses.thefocus.ai/fine-tune-local-agent/01-lora-eyes-open/01-why-images-first.md

You are not enrolled yet. Enroll to generate a Student ID to track lesson completions and store learning notes.

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:

KnobWhat it controls
RankCapacity of the adapter. Higher = more expressive, more prone to memorizing
AlphaScaling of the adapter’s contribution
Target modulesWhich layers get adapters (attention only? all linear layers?)
StepsHow long you train. The underfit → learned → memorized axis
Dataset sizeHow much signal you’re distilling into the adapter
Adapter scaleAt 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

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 · Next: Chapter 02 →

Lesson 1 of 16 Next