Book Deep Read · Generative AI System Design Interview · Ch 9

Text-to-Image: the hard part is not looking good, it is obeying

Generative AI System Design Interview · Ch 9 · Ali Aminian, Hao Sheng & Alex Xu · 2024

中文 →

What is this chapter about?

You type "a shiba inu wearing an astronaut helmet, watercolour" into your phone, and seconds later an image appears. That pipeline is this chapter. But its subject is not how to make the picture look good — the previous chapter already settled that. From start to finish it chases one question: how do you make that sentence actually govern that picture?

Here is the strange part

A model that paints beautifully and a model that obeys are two different things. You say "wearing a helmet" and it hands you a gorgeous shiba with no helmet. What makes this failure nasty is that it does not throw an error and it does not leave a blank — it quietly drops half of what you asked for. Worse, the automatic scoring tools will still rate it highly, because the picture really does look like a real photograph.

How it listens

The trick is that the sentence is not mentioned once at the start and then forgotten. The model paints by wiping and redoing the canvas over and over, and every time it redoes a small patch, it goes back and rereads that sentence — like a cook who keeps glancing at the order slip. Working on the dog's head, it asks "anything specified about the head?"; working on the background, it asks "what style again?". That is why "helmet" lands where it belongs instead of smearing across the whole canvas.

The main move: paint it twice

That alone is still not obedient enough. The move that actually works is slightly counterintuitive: in the same step, have the model paint twice — once reading your request, once ignoring it completely. The difference between the two is the direction your sentence pulls the picture in. And then the system is not content with that much difference: it keeps pushing further along that same direction. Want it more obedient? Turn up how far it pushes.

That multiplier is a dial you can turn in real time, and it is the most valuable design on the whole pipeline: without retraining anything, you can slide between well-behaved and wild.

How far to turn it

Turn it down and the picture is lovely but freewheeling — your details go in one ear and out the other. Turn it up and it follows you to the letter, but the image stiffens, the colours go garish, the compositions all start to rhyme: obedient to the point of lifeless. Most products settle somewhere in the middle and expose a slider for the rest.

There is also a cheap by-product. Since one of the two passes ignores your request anyway, you may as well point that pass at the things you don't want ("blurry, extra fingers, watermark") — and the push becomes "get away from these". That is the "negative prompt" in drawing tools. It is not folklore, it is the same move seen from behind.

The cost is blunt: painting twice per step doubles the compute and the electricity bill.

One line to remember

The real engineering problem in text-to-image is not fidelity, it is obedience: rereading the sentence at every brushstroke puts each requirement in the right place, and painting twice and then over-shooting along the difference turns obedience into a dial you can turn live — tighter means more faithful, but also stiffer, and it costs double.

Want the mechanisms, notation and diagrams? → Switch to the deep read