AIToday
Large Language ModelsImage GenerationZenn AI/MLPublished: Oct 26, 2026, 01:00 JST

CFG and cross-attention: how text steers AI image generation

Send on LINE
CFG and cross-attention: how text steers AI image generation

3 Key Points

  1. What happened

    The explainer lays out text guidance in three steps — CLIP or T5 encodes the prompt, cross-attention injects it, and CFG amplifies it — with SD3/Flux combining CLIP×2 and T5-XXL.

  2. Why it matters

    It corrects the common misconception that T5 draws detailed images; the encoders only supply meaning vectors, and the denoiser produces the picture.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

Context & Analysis

The explainer is built as a follow-up to an earlier introduction to diffusion models, which described text-to-image as "text conditioning plus CFG" in one line; this piece opens that box. Its central division of labour is between understanding and drawing: CLIP's encoder, trained contrastively on roughly 400 million image-text pairs, is grounded in images but shallow as language, while T5's bidirectional encoder is a pure language model that never sees images. SD3/Flux use both — CLIP×2 plus T5-XXL — so their weaknesses offset each other.

The piece traces the denoiser's evolution from a CNN-based U-Net with inserted Transformer blocks toward DiT and MMDiT, which join text and image tokens in a single attention.

The final stage frames CFG as an answer to a specific problem: plain conditional diffusion follows prompts only weakly. Unlike classifier guidance, which needs a separately trained classifier and is limited to class labels, CFG drops the condition during training so one network handles both conditional and unconditional prediction, then amplifies their difference at generation. Negative prompts occupy the same unconditional slot, steering away from unwanted terms.

FAQ
What is the difference between CLIP and T5 in this pipeline?
CLIP's text encoder is trained on about 400 million image-text pairs with contrastive learning, so it is grounded in images. T5's encoder is trained only on text, so its language understanding is deeper.
Why does the denoising network run twice under CFG?
Training sometimes drops the condition so one network can predict both conditional and unconditional outputs. At generation it runs both, and CFG amplifies the difference by a factor w.
What does the guidance scale w control?
Raising w increases prompt fidelity, with w=1 being ordinary conditional generation. Too high a value causes oversaturation and reduced diversity, and 7–8 is the common practical range.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleAI wearables roundup: Bee, Friend, Muse Charm and more