In an image generator, boilerplate chat tokens end up carrying what to draw
A 2026 preprint traces how the Qwen-Image diffusion transformer stores object identity in formatting tokens, then turns that finding into a rule for skipping attention heads.

When you type a prompt into a modern text-to-image system, the words rarely travel alone. Several recent image generators use a large language model as their text encoder, and that encoder wraps the prompt in a chat template: fixed formatting tokens, such as role markers and an end-of-message marker, that tell a chatbot where a turn begins and ends. These tokens say nothing about apples, cats or sunsets. A 2026 preprint posted to arXiv by thirteen researchers at Nanjing University, Alibaba Group and Zhejiang University argues that inside the Qwen-Image generator these boilerplate tokens become the main internal carriers of which object the model is drawing. The authors call them implicit semantic registers, meaning slots that hold and pass along information about what to draw, somewhat like a scratchpad.
The finding matters for two reasons. First, it challenges a widely held picture of how such models work, in which the image being generated keeps consulting the prompt words directly at every layer. The authors say this picture has not been causally established, and their experiments suggest the route is more indirect. Second, the paper shows the basic toolkit this series will keep returning to. It measures where attention goes, then intervenes inside the network to see which pathways actually change the output. The authors also use what they learn to make the model cheaper to run, which shows that this kind of mechanistic insight can have a practical payoff.
How it works
Qwen-Image is a diffusion transformer, or DiT: an image generator that starts from random noise and removes it step by step, using a transformer network at its core. Specifically, it is an MMDiT, a design in which text tokens and image tokens sit in one combined sequence and attend to each other directly in every block, an arrangement called joint attention. Its text encoder is the Qwen2.5-VL model. The authors split the text conditioning into two parts. The semantic span, S, holds the tokens from the user's actual words. The template span, R, holds the five trailing chat-template tokens, including the end-of-message marker <|im_end|>.
The first tool is bookkeeping. The researchers measure image-to-text attention, the share of attention that image tokens give to text tokens and the main route by which text can shape the picture. They record how much of it lands on S and how much on R, then average over blocks, attention heads and denoising steps. Next they ask whether R carries prompt content when it leaves the encoder. To test this, they swap template tokens between prompts and replace R with a single template averaged over 100 prompts. They then judge whether the object changes using DINOv3, an image-representation model whose summary vectors can be compared for similarity.
The causal experiments are the heart of the paper. In a head transplant, the authors run the model on the prompt 'An apple' and on 'A banana'. They then copy the internal query, key and value computations of selected attention heads from the banana run into the apple run, progressively, across all 1,440 heads in the model. The heads are ordered by how strongly each one attends to the prompt words, and the order is then reversed. In a second experiment, attention masking, they block the template tokens from looking either at the prompt tokens or at the image tokens, cumulatively over the first few blocks, to see where R gets its content. These causal tests use a publicly released two-step distilled adapter for Qwen-Image-2512, run for a single denoising step so that the noise level stays fixed.
Finally, the authors turn the analysis into a training-free pruning rule, a way of making the model cheaper by skipping some of its parts without retraining. They rank heads by how much attention image tokens send to the prompt words, then skip the top K heads during the last 80% of denoising steps.
What the evidence shows
The attention statistics are striking. For the two-word prompt 'An apple', image tokens on Qwen-Image send on average 0.23 of their attention mass to the template span and 0.020 to the prompt content. That is an 11-fold gap overall, or 4.6-fold per token. The template outweighs the prompt at 98% of the sites measured, and <|im_end|> alone absorbs 13% of all image attention at the highest noise level, more than six times the share going to the word 'apple'. The pattern holds at scale. On GenEval, a benchmark of 553 short prompts that checks whether images contain the right objects, counts, colours and positions, 76% of image-to-text attention lands on the template span, and a template token is the single most-attended text token at 91% of sites. With long prompts the overall balance tips toward the prompt words. On DPG-Bench, whose prompts average 82 content tokens, the template wins at only 12% of sites. Per token, however, the template's pull grows stronger, at 7.2 times. A Chinese-language benchmark gives similar per-token ratios, and the Qwen-Image-2512 checkpoint behaves almost identically.
Heavy attention alone does not prove that the template carries meaning, and at the encoder output it largely does not. When the authors replace each prompt's template with one averaged across 100 other prompts, then test on 40 held-out prompts, the median image similarity to the original is 0.99. Inside the network, things change. In the head transplant, copying the heads that read the prompt most heavily, in order, fails to turn the apple into a banana, and the image drifts toward the model's default output of a human portrait. Copying in reverse order, starting from the heads that barely look at the prompt, flips apple to banana after about 18% of heads. The masking experiment suggests why. Blocking the template from reading the prompt leaves the object essentially unchanged, while blocking it from reading the image collapses the object within the first two blocks. The authors' reading is that prompt information flows into the image latents in the first block, and the template tokens then pick it up from the image in the second.
The pruning experiments are scored on a benchmark. On Qwen-Image-2512, skipping 360 heads, a quarter of the total, cuts joint-attention floating-point operations by 20% and lowers GenEval accuracy from 76.1 to 74.7. The choice of heads matters a great deal. At a budget of 288 heads, the proposed ranking scores 75.5, ranking by template attention instead scores 69.6, and random selection falls to 51.3. HPSv3, a score that predicts human preference, follows the same pattern.
What it does not show
The mechanistic core rests on a narrow base. The head transplant, the masking and the depth analysis are demonstrated on one prompt pair, apple and banana. They use a distilled model run for a single step, and the results appear mainly as image sequences rather than scores aggregated over many prompts. Whether the same pathway operates across the full multi-step denoising schedule is not tested directly in these experiments. The main-text results also concern only the Qwen-Image family, with other models left to an appendix. The authors note that models conditioned on CLIP or T5 encoders, such as FLUX, SD3 and SDXL, have no counterpart to these chat-template tokens.
The template tokens are also not entirely content-free. Some held-out prompts with the averaged template changed object, count or attributes, sometimes drastically. Classifier-free guidance, a sampling technique that pushes the generator toward the prompt by contrasting prompted and unprompted predictions, largely suppressed these failures. The authors attribute the portrait default to the abundance of people in photo-caption training data, but they present this as a presumption, not a tested claim. They also describe the split between heads that act as registers and heads that render image detail as not absolute.
The pruning gains are modest and narrowly measured. The savings count joint-attention operations only, with no wall-clock timings or whole-model figures, and the first 20% of steps are left untouched because they are sensitive. Evaluation covers GenEval on one checkpoint. Perceptual quality drops faster than accuracy: at 360 heads, HPSv3 falls from 9.56 to 8.76. For that reason the authors themselves favour a lighter setting of 216 heads, which saves 12%. The rule is compared with random and template-ranked selection, but not with other published acceleration methods.
Where it fits
The paper builds on earlier analyses of MMDiT models that decompose joint attention into image-to-text, image-to-image, text-to-text and text-to-image parts, and that treat image-to-text as the main cross-modal channel. It also draws on work on attention sinks, a few token positions that soak up a disproportionate share of attention while appearing to carry nothing meaningful. The authors' twist is to argue that in this kind of model the sinks are not empty at all, and instead act as semantic registers.
The study also takes aim at what the authors call the conventional semantic-head view, the assumption that the heads which read the prompt most are the ones that carry the object. The transplant results point the other way, and the pruning results agree: the heaviest prompt readers turn out to be among the most dispensable. When the authors localise roughly 270 identity-driving heads across the model's 60 blocks, they find identity is committed early, carried through the middle and refined late. Early heads alone flip the object cleanly, while middle heads alone barely change it. The authors note that this mirrors depth patterns reported for large language models. As the opening story in this series, the paper sets out the basic method: measure where attention goes, then intervene to see what actually matters.
- Paper
- Text Template Tokens Are Implicit Semantic Registers in Diffusion Transformers
- Authors
- Maohua Li, Qirui Li, Yanke Zhou, Yiduo Li, Zhaosheng Chi, Chao Xu, Cuifeng Shen, Yixuan Xu, Hanlin Tang, Kan Liu, Tao Lan, Lin Qu et al.
- Venue
- arXiv preprint — not yet peer reviewed · 21 July 2026
- Link
- arxiv.org/abs/2607.19139
- Index
- stacks.braintank.ai
- Code
- github.com/Met4physics/DiT-Interpretability
- Cite


