AI State of the Art
SOTA/Multimodal AI/43 min
Section 164

Text-to-Image Generation

Listen as a podcast →

The Question This Page Answers

A diffusion model knows how to denoise an image. That mechanism is described in Diffusion Models: DDPM, DDIM, CFG, and in itself it has nothing to do with text: you hand it a noisy image, it hands back the same image slightly less noisy.

So how does an English sentence turn into a picture? The answer comes in two moves:

  1. The text is turned into a sequence of number vectors by a text encoder.
  2. At every denoising step, the network consults those vectors through a cross-attention mechanism, and its noise prediction changes as a result.

In other words, the text does not build the image. It steers each of the few dozen noise subtractions. That is the whole content of this page.

Two Worlds, Then a Third

On one side, the proprietary services: Midjourney, Google's Imagen, ByteDance's Seedream, and for a long time OpenAI's DALL-E 3. Closed weights, access by subscription or API.

On the other, the open-weight models: Stable Diffusion, SDXL, Flux, and since 2025 Alibaba's Qwen-Image. The weights are downloadable, which let a community modify them, thousands of adaptations, called LoRAs, in circulation. One caveat, though: "open weights" does not mean "free". Each model comes with its own licence, and they differ a great deal, including inside a single family.

Since March 2025 a third world has joined them: images made by the chat assistant itself, GPT-4o in ChatGPT, then Nano Banana in Gemini. That is the subject of the section "The 2025 Shift", further down.

How Text Gets Into the Network

Step 1: Text Becomes Vectors

The sentence is first cut into tokens, pieces of words, the unit these models handle. Then a text encoder turns that sequence of tokens into a sequence of vectors, one per token. A vector is simply a list of numbers; the encoder is trained so that words of similar meaning give similar lists.

Stable Diffusion 1.x uses the text encoder of CLIP, Contrastive Language-Image Pre-training, described in CLIP. The choice is not incidental: CLIP was trained on image/caption pairs, so its vectors already lean toward what is visible.

One detail worth knowing, because it explains a common frustration: CLIP's encoder takes a fixed length of 77 tokens. A longer prompt is truncated or handled in chunks, which is why the tail end of a very long prompt sometimes seems ignored.

Step 2: Cross-Attention, at Every Step

This is the crux. The denoising network contains, at several of its stages, a cross-attention block. "Cross" means the two sides of the computation do not come from the same source:

  • The queries, written QQ, are computed from the image being denoised. Each region of the image asks a question: "what in the prompt concerns me?"
  • The keys and values, written KK and VV, are computed from the text vectors. Keys answer "I concern you"; values carry the content to pass along.

The mechanism itself is identical to the one described in Self-Attention: Query, Key, Value in Detail; the only difference is this crossed provenance.

Learned or Computed: Do Not Confuse Them

QQ, KK and VV are results, recomputed at every denoising step and for every prompt. They are stored nowhere in the model file.

What the model file does contain is the weight matrices WQW_Q, WKW_K and WVW_V used to compute them. Those are learned during training and then frozen.

The practical consequence is sharp: two different prompts give different KK and VV with exactly the same weights. Text does not train the model, it changes its activations.

Since there is such a block at several stages of the network, and the network is called at every step, the prompt is re-read at every step and at every scale. It is not consulted once at the start. That is what lets text influence both the overall composition, in the low-resolution stages, and the textures, in the high-resolution ones.

Step 3: Classifier-Free Guidance Amplifies the Text's Effect

Cross-attention is enough to let the text in, but its effect is modest. Classifier-free guidance, abbreviated CFG, amplifies it deliberately.

Classifier-Free Diffusion Guidance (Ho and Salimans, 2022)

The principle is to call the network twice at each step: once with the prompt, once with an empty prompt. The difference between the two predictions isolates exactly what the text contributes, and that difference is exaggerated.

εguided=εuncond+w×(εcond−εuncond)\varepsilon_{\text{guided}} = \varepsilon_{\text{uncond}} + w \times (\varepsilon_{\text{cond}} - \varepsilon_{\text{uncond}})

  • ε\varepsilon (the Greek letter epsilon) denotes a predicted noise, the amount to remove from the image at this step.
  • εuncond\varepsilon_{\text{uncond}}: the prediction obtained with an empty prompt (unconditional).
  • εcond\varepsilon_{\text{cond}}: the prediction obtained with the prompt (conditional).
  • εcond−εuncond\varepsilon_{\text{cond}} - \varepsilon_{\text{uncond}}: the text's own contribution, and nothing else.
  • ww: the amplification factor, called the guidance scale in user interfaces.
  • εguided\varepsilon_{\text{guided}}: the noise finally removed.

In one sentence: measure what the text changes, then exaggerate it by a factor ww.

Two consequences to remember. First, this doubles the cost of generation: two network calls per step. Second, with this way of writing it, w=1w = 1 means no amplification, not w=0w = 0, which would delete the prompt. The original paper uses a convention shifted by 1, which makes comparing values across sources treacherous.

Guidance Values Are Conventions of Use, Not Results

You will read ranges everywhere along the lines of "7 to 15 for Stable Diffusion, 3.5 for Flux". Those numbers come out of no published measurement: they are community habits, anchored on the defaults written into the software, the Diffusers library ships its Stable Diffusion pipeline with 7.5.

The two things one can assert without a source, because they are visible to the eye: too low and the image ignores the prompt; too high and colours saturate and patterns repeat. The useful range varies from model to model, notably because recent models are sometimes trained with the guidance distilled in, which changes the meaning of the setting entirely. The only method is to start from the default of the model you are using.

Stable Diffusion: The Model That Opened the Ecosystem

High-Resolution Image Synthesis with Latent Diffusion Models (Rombach et al., 2021)

The Four Pieces

Stable Diffusion is a latent diffusion model: it denoises not pixels but a compressed version of the image, 48 times smaller in number of values (the arithmetic is laid out in Diffusion Models). Four pieces work together:

  1. The VAE encoder (variational autoencoder) compresses the image from 512×512×3 down to 64×64×4.
  2. The U-Net denoises inside that compressed space. Its name comes from its shape: resolutions shrink and then grow back, like a U, with shortcuts between stages of equal resolution.
  3. The text encoder turns the prompt into vectors, as described above.
  4. The VAE decoder rebuilds the visible image at the end.

Generation, Step by Step

  1. Draw random noise in the compressed space, at 64×64×4.
  2. The U-Net predicts the noise to remove, consulting the text vectors by cross-attention. With classifier-free guidance, it does so twice.
  3. Remove that noise.
  4. Repeat a few dozen times. The whole image sharpens on each pass; nothing is produced and then frozen.
  5. The VAE decoder renders the image in pixels.

The Versions, and What the Numbers Refer To

The sizes below are those of the denoising network alone, as given in Table 1 of the SDXL paper. A complete model also carries its text encoders and its VAE, so the file on disk is bigger than that number suggests.

VersionDenoising networkNative resolutionText encoder(s)
SD 1.4 / 1.5 (2022)860 million parameters512×512CLIP ViT-L
SD 2.0 / 2.1 (2022)865 million512×512, then 768×768OpenCLIP ViT-H
SDXL (2023)2.6 billion1024×1024CLIP ViT-L + OpenCLIP ViT-bigG
SD 3 (2024)Diffusion transformer, size depending on the variant1024×1024CLIP ViT-L + OpenCLIP ViT-bigG + T5-XXL
SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis (Podell et al., 2023)

Three useful clarifications:

  • SD 1.5 is the most widely adapted version by the community, which is not the same as the best. Its popularity comes from being early and light, which enabled thousands of fine-tunes.
  • SD 2.1 was poorly received despite its newer text encoder. That reception is a social fact, documented by usage; no published measurement establishes that it is broadly inferior to SD 1.5. This is exactly the kind of judgement to handle with the caveats set out in How to Read a Benchmark Score.
  • The "6.6 billion" often attributed to SDXL does not refer to the denoising model. The paper says SDXL's U-Net is "three times larger" than the previous one, that is 2.6 billion parameters, plus 817 million for the two text encoders. The larger figure in circulation adds up the base model and the refiner, described below.
Two-part diagram. Part (a), overview: a Caption box feeds three text encoders, CLIP-G/14, CLIP-L/14 and T5 XXL; the CLIP outputs give a Pooled vector that goes through an MLP and combines with the sinusoidal encoding of the Timestep to form the vector y, while the 77 plus 77 CLIP tokens are concatenated with the T5 output over 4096 channels and go through a Linear to form c. In parallel, the Noised Latent box goes through Patching, Linear and the addition of a Positional Embedding to form x. The vectors y, c and x enter a stack of MM-DiT blocks numbered 1 to d, followed by Modulation, Linear, Unpatching and Output. Part (b), one MM-DiT block: two symmetric branches, c on the left and x on the right, each with Layernorm, a modulation by the alpha and beta parameters derived from y, then a Linear; the two branches meet in the centre at a single Attention box marked Q K V, before splitting again into Linear layers, MLPs and residual connections.
The SD 3 architecture, showing the three text encoders mentioned above. The important detail is on the right: inside an MM-DiT block, the text tokens (branch c) and the image tokens (branch x) run in parallel but share one single Attention box. Text and image look at each other, instead of a one-way cross-attention.Source : Stable Diffusion 3 paper (Esser et al.), via the From U-Nets to DiTs blog

That diagram shows an important shift. In SD 1.x and SDXL, text is a guest: it enters through one-way cross-attention blocks, and the image never answers back. In SD 3, text and image travel side by side and share the same attention block: each looks at the other. That is what the acronym MM-DiT means, for multimodal diffusion transformer.

SDXL

Four changes relative to SD 1.5, all described in the paper:

  • Native 1024×1024 resolution against 512×512, that is four times the pixels.
  • Two text encoders instead of one: CLIP ViT-L and OpenCLIP ViT-bigG, whose outputs are placed side by side.
  • A two-stage architecture: a base model that lays out the composition, then an optional refiner that picks up the result to improve detail.
  • Enriched conditioning: the model is also told the original image size and the crop used during training. The paper explains why: without it, images too small would have had to be thrown out of the training set, 39% of the data, according to its figure 2. Conditioning lets them be kept while telling the model they are small.
Linear diagram of the SDXL chain. A yellow Prompt box on the left sends an arrow into a first blue U-shaped block outlined with dashes and labelled Base. Its output is a purple Latent box marked 128 x 128. That feeds a second green U-shaped block outlined with dashes and labelled Refiner, whose output is a red Image box marked 1024 x 1024. An arrow leaving the Prompt box passes below the Base block and goes directly into the Refiner block.
The two stages of SDXL described above. The Base model lays out the composition in a 128 by 128 latent, then the Refiner picks up that same latent to add fine detail before decoding at 1024 by 1024. Note that the prompt is fed to both stages, not just the first.Source : Stability AI, Stable Diffusion XL model card on Hugging Face
Why SDXL Stayed the Sweet Compromise for So Long

It is not a matter of peak quality but of balance: good enough, fast enough, light enough to run on a consumer graphics card, and above all surrounded by an ecosystem of adaptations that newer models have only slowly caught up with. A model you can specialise in a few hours with a LoRA is often worth more, in practice, than a stronger model you cannot touch.

Flux

Flux is developed by Black Forest Labs, a company founded by several authors of the Latent Diffusion paper. Four choices set it apart from earlier Stable Diffusions:

  • A diffusion transformer (DiT) replaces the U-Net. The compressed image is cut into squares, each square becomes a token, and the whole is handled as a sequence, exactly as a Transformer handles text.
  • Flow matching replaces DDPM as the training method. See Diffusion Models for what that changes; the gist is that large strides become possible, hence very-few-step generation.
  • T5-XXL as text encoder, alongside CLIP. T5 is a language model trained on text alone, without images; it captures the structure of a long sentence better than CLIP, whose training centres on short captions.
  • Joint attention between text tokens and image tokens, rather than one-way cross-attention, the same shift as in SD 3.
Four-panel diagram. Left panel, Latent Diffusion Transformer: a Noised Latent box of size 32 x 32 x 4 goes through Patchify, while the Timestep t and the Label y go through Embed; both enter a DiT block repeated N times, followed by Layer Norm then Linear and Reshape, producing two 32 x 32 x 4 outputs, the predicted noise and the variance. Second panel, DiT Block with adaLN-Zero: the Input Tokens pass through Layer Norm, a Scale Shift modulation driven by gamma1 and beta1, a Multi-Head Self-Attention, a Scale by alpha1, a residual connection, then Layer Norm, Scale Shift with gamma2 and beta2, Pointwise Feedforward, Scale by alpha2 and a second residual connection; all these parameters come from an MLP fed by the Conditioning box. Third panel, DiT Block with Cross-Attention: the same structure but the conditioning enters through a Multi-Head Cross-Attention box inserted between the self-attention and the feedforward. Fourth panel, DiT Block with In-Context Conditioning: the conditioning is simply concatenated to the input tokens along the sequence dimension.
The DiT block that replaces the U-Net. On the left, the overall structure: the noisy latent is cut into patches (Patchify) and handled as a sequence of tokens, exactly the way a Transformer handles text. The three panels on the right show the three possible ways of injecting the conditioning, including the cross-attention used by Stable Diffusion (third panel), now just one option among several.Source : Scalable Diffusion Models with Transformers paper (Peebles and Xie), authors site

Three Variants, Three Licences

The point that matters most is here, and it depends on no benchmark:

  • Flux.1 [pro]: weights not distributed, access by API only.
  • Flux.1 [dev]: weights downloadable, under a publisher-specific licence that forbids commercial use. This is not a free model.
  • Flux.1 [schnell]: weights under the Apache 2.0 licence, so genuinely free, commercially included. Schnell is German for "fast": this variant is distilled to generate in very few steps.

What Flux Improves, and With What Caution

The advertised gains are on diffusion's historically weak points: counting objects, attaching attributes to the right object, legible text inside the image, hand anatomy, scenes with several characters.

But beware the shortcut "you get exactly what you asked for". Counting and attribute binding remain fragile in all models of this kind, and no publicly verifiable measurement supports the claim that the problem is solved. These capabilities are assessed on test sets built for the purpose, and reading such a score requires the caveats set out in How to Read a Benchmark Score.

FLUX.1 Kontext and FLUX.2: Editing, and Reading the Prompt With a Real Language Model

FLUX.1 Kontext (May 2025) addresses a need that pure generation left aside: changing an existing image on instruction ("give her a hat", "replace the text on the shop sign") without redrawing everything. The trick is easy to state: the starting image is cut into tokens and placed in the same sequence as the image to be produced, so the Transformer "sees" it at every step and copies over whatever it was not asked to change. The same device keeps a character recognisable from one image to the next. The [dev] variant was released with open weights, under a non-commercial licence.

FLUX.1 Kontext: Flow Matching for In-Context Image Generation and Editing in Latent Space (Black Forest Labs, 2025)

FLUX.2 (25 November 2025) takes the logic further. Up to 10 reference images can be supplied at once, output goes up to 4 megapixels, and above all the text encoder changes in kind: it is no longer CLIP or T5 but a full vision-language model from Mistral AI, with 24 billion parameters, coupled with a 32-billion-parameter Transformer in the [dev] variant. A smaller family, [klein], came out in January 2026, its smallest variant under the Apache 2.0 licence.

That change of encoder sums up a deep trend, visible in the table above: CLIP, trained on short captions; then T5, which understands long sentences; then an entire language model, which understands a complicated prompt, a layout, a text to be written word for word. Qwen-Image makes the same choice with its own house vision-language model, Qwen2.5-VL.

The 2025 Shift: Images Made by the Assistant

GPT-4o, March 2025

On 25 March 2025, OpenAI replaced DALL-E 3 in ChatGPT with GPT-4o's native image generation. Until then, when you asked ChatGPT for a picture, the chat model wrote a prompt and passed it to a separate diffusion model (the tool-call test described in Unified Multimodal Models). Now the same model converses and produces the image; OpenAI describes it as autoregressive, building the image piece by piece the way it writes text, without publishing further detail.

The effect was immediate and massive: the wave of "Studio Ghibli style" images swamped OpenAI's servers for days. In substance, three things changed:

  • Text inside the image becomes legible: shop signs, menus, comic strips with speech bubbles, where diffusion models used to produce pseudo-letters.
  • Complex prompts are followed better: a dozen objects with their attributes, a precise layout. The model "reading" the prompt is a large language model, not a 77-token encoder.
  • You edit in conversation: "keep everything, but make it night". The model has the previous image in its context.

Nano Banana and Its Successors

Google answered in August 2025 with Gemini 2.5 Flash Image, tested anonymously on a voting arena under the codename "Nano Banana", which stuck. Its strength is editing: changing a setting, an outfit or an angle while keeping the face recognisable, exactly where earlier models failed most visibly. Then came Nano Banana Pro (November 2025, on Gemini 3 Pro), more precise with text and diagrams, and Nano Banana 2 (February 2026), a fast, free version.

OpenAI hit back on 21 April 2026 with GPT Image 2 (presented as ChatGPT Images 2.0), which can "think" before drawing: the model plans the composition, and may even look something up on the web, before producing the image.

What Is Known, and What Is Not

Neither OpenAI nor Google has published the architecture of these models. In particular, nobody outside knows whether the final output goes through a diffusion decoder, which is likely but unconfirmed. The one established point is the one that matters to the user: the prompt is understood by a large language model, and the image is produced inside the same system as the conversation. The open models that do the same, and the tokens-versus-diffusion debate, are covered in Unified Multimodal Models.

The Other Families, 2025-2026

  • Midjourney: version 7 (April 2025) became the default; a version 8 has been in testing since March 2026. Still with no published weights or technical paper, and still, for many users, the reference for aesthetic rendering, which remains a preference.
  • Seedream (ByteDance): version 3.0 (April 2025), then 4.0 (September 2025), which merges generation and editing into one model and goes up to 4K, with public technical reports; versions 4.5 and 5 followed.
  • Qwen-Image (Alibaba, August 2025): a 20-billion-parameter diffusion transformer under the Apache 2.0 licence, noted for its text rendering, in Chinese as well as English. It is one of the largest image models released under a permissive licence.
Seedream 4.0: Toward Next-generation Multimodal Image Generation (ByteDance Seed, 2025) Qwen-Image Technical Report (Qwen Team, 2025)

Sampling Methods

The sampling method (the sampler in user interfaces) is the rule that decides how you move from one step to the next. It is chosen after training, without touching the weights, which is why it shows up in a dropdown menu.

  • DDPM: follows the original recipe, with a share of randomness at every step. The paper's reference step count is 1,000.
  • DDIM: makes the path deterministic, which allows steps to be skipped. The paper measures 10 to 50 times faster than DDPM at comparable quality.
  • Euler, DPM++ 2M Karras: finer numerical solvers of the same path, aiming at a good image in a few dozen steps. The second is the most widespread default for Stable Diffusion, again a convention of use, not a ranking.
  • Flow matching (Flux, SD 3): the path is learned as a more direct route, which allows the step count to go very low.

Step count is the second setting to know, after guidance. There is no correct value: each model family has its useful range, stated by its publisher.

LoRA: Specialising Without Retraining

LoRA stands for Low-Rank Adaptation. It is a small file added on top of a base model to specialise it, without touching the original weights. The mechanism is detailed in LoRA.

The three common uses in image generation:

  • Style LoRA: impose a visual manner, watercolour, pixel art, cartoon.
  • Character LoRA: get the same face back from one image to the next.
  • Concept LoRA: learn an object or creature absent from the original data.

Their appeal is that they are small by construction (that is what "low rank" means) hence quick to train, easy to share and combinable. This explains the size of the ecosystem around Stable Diffusion.

Legal and Ethical Questions

Image generation raises at least four distinct questions, best not conflated: misleading imagery of real people; reproducing a living artist's manner, including via a LoRA trained on their work; the status of the training data; and ownership of the output. The answers differ by jurisdiction and are moving fast.

On the technical side, the answers put forward are output filtering and marking, invisible digital watermarking, such as Google's SynthID, and provenance metadata standardised by the C2PA coalition. The "Ghibli" wave of March 2025 put the second question back in the spotlight: imitating a style is not copying a work, but public debate does not stop at that distinction. For what courts have said about training, see What the Courts Have Said About Training.

The Ecosystem

  • ComfyUI: a node-graph interface, the most flexible for assembling processing chains.
  • Automatic1111: a classic web interface, long the most widespread for getting started, whose development has slowed markedly since 2024.
  • Diffusers (Hugging Face): a Python library, for integration into a program.
  • CivitAI: a sharing platform for models and LoRAs.

Where the Field Is Going (November 2026)

  • Architecture has shifted from convolutional networks, the U-Net among them, to diffusion transformers.
  • Training has shifted from DDPM to flow matching.
  • Step count is falling, through distillation, toward a handful of steps.
  • The text encoder has become an entire language model, and at both OpenAI and Google the image is produced by the assistant itself. The blind-vote leaderboards of 2026 put GPT Image 2, the Nano Banana family, Seedream and FLUX at the top, in an order that changes from one release to the next.
  • Control has changed shape: ControlNet, IP-Adapter and inpainting (regenerating only one region) remain useful in open pipelines, but editing by natural-language instruction and multiple reference images have become the usual way to steer a model.
  • The historical weak points (text in the image, counting, hands) have shrunk markedly in the best models without disappearing: the caution of the Flux section still applies.
Check your understanding0 / 6

1. How does the text prompt influence the image in Stable Diffusion?

2. Where are the cross-attention matrices Q, K and V stored in the model file?

3. A Stable Diffusion 1.5 user notices the tail end of a very long prompt seems ignored. What explanation does the page give?

4. Your company wants to run a Flux model on its own servers inside a commercial product. Which variant should it pick?

5. SD 1.5 is the version most widely adapted by the community. What does that tell you about its quality?

6. Since March 2025, ChatGPT finally writes legible text in images and follows ten-object prompts. What changed?