TL;DR
Transfusion is a training recipe for one transformer that handles text and images together. Text is split into discrete tokens and learned with the next-token loss; images stay as continuous latent vectors and are learned with the diffusion loss. The two losses are added and the same network learns both. The authors pretrained models up to 7B parameters on a mixture of text and images, reaching image quality close to similar-size diffusion models and text ability close to Llama.
Builds on: Autoregressive Model, Diffusion Model, Variational Autoencoder, Vision Transformer (ViT) · Leads to: Flow Matching (the paper names it as a replacement for the diffusion loss it did not try)
Why it mattered
Before Transfusion, the open route to a model that generates both text and images was to turn images into discrete tokens and then train an ordinary language model over the mixed token sequence. Chameleon, released in 2024, followed this route. Other systems attached a pretrained image generator to a language model, or grafted a diffusion model onto one. Transfusion showed that a single transformer can be trained with both objectives from scratch, with no discrete image tokens and no separate generator.
The clearest number is the 7B model trained on 2T tokens: 1T text tokens and about 3.5B image-caption pairs. It scored 0.63 on GenEval, above SDXL at 0.55 and close to DeepFloyd at 0.61, and it matched Llama 1 on text benchmarks at 66.1 average accuracy.
The problem
Two things were true at once. Next-token prediction, the objective of language models, dominates discrete data such as text and code. Diffusion, which learns to reverse a noising process, is the state of the art for continuous data such as images. Neither objective is good at the other's data type.
Existing ways to combine them each had a cost. Quantizing images with a VQ-VAE gives discrete tokens that a language model can read, but the quantization step throws away information about the image. Attaching a separate diffusion model to a language model keeps each piece strong but splits the system into parts that are trained apart. The paper asks whether images can stay continuous, with no information loss, while the same model still learns from text with next-token prediction.
How it works
Take one tiny mixed sequence: the text "Hi", then an image of four patches.
- Turn the text into integers. "Hi" becomes two integers from a fixed vocabulary, for example 17 and 42. Check: text is discrete, so each token is one integer.
- Turn the image into patch vectors. A VAE compresses the image into a small latent grid. Each latent cell is a vector, and the paper cuts the grid into patches, read left to right and top to bottom. Here the image gives four patch vectors, to , each a list of numbers. Check: the image is now continuous vectors, with no rounding to a codebook.
- Put markers around the image. The sequence becomes [17, 42, BOI, , , , , EOI]. BOI and EOI are special tokens that mark where the image starts and ends. Check: one sequence now holds both kinds of element.
- Set who may see whom. Each text token and the BOI marker attend causally, looking only at earlier positions. Inside the image, the patches attend bidirectionally to each other. So can see , but "Hi" cannot see any patch. Check: information flows forward through the sequence, and freely within each image.
- Score the text. At each text position the model predicts the next integer, and the loss is the cross-entropy of that prediction against the true next token. Check: the text loss is computed per token, and no loss is computed at image positions for text.
- Score the image. The whole image is noised at one random time step and then passed through the transformer, which tries to predict the noise that was added. The loss is the mean squared error between the true and predicted noise, computed once per image. Check: one diffusion loss per image, even though the image spans many patches.
- Add the two losses. The total is the text loss plus times the image loss, with in the paper. Check: the same network gets gradients from both, so one set of weights learns both.
- Generate. Sampling starts in text mode, one token at a time. When the model samples BOI, the decoder appends pure noise patches and denoises them over several steps, overwriting the noisy patches each time. Then it appends EOI and returns to text mode. Check: any mix of text and images can come out of one loop.
flowchart LR T["Text tokens (integers)"] --> S["One transformer"] I["Image latent patches (vectors)"] --> S S --> L1["Next-token loss on text"] S --> L2["Diffusion loss on each image"] L1 --> L["Total = LM loss + 5 x diffusion loss"] L2 --> L
The math
Step 5 in symbols: the text loss
Here is the probability the model gives the true token after the earlier tokens . The negative log is small when that probability is high.
Step 6 in symbols: the image loss
Diffusion adds noise in a closed form. With the cumulative signal level at time ,
The paper uses the cosine schedule, where with some adjustments. The network sees the noisy latent , the time and any context , and the loss is
For the diffusion background, see Diffusion Model; the noise prediction form follows DDPM.
Step 7 in symbols: the combined loss
The paper set after preliminary experiments and says it leaves further tuning to future work.
Step 4 in symbols: the attention mask
The mask is a matrix with entry when position may attend to position . For positions in different images or in text, only when . Inside one image, for every pair of patches, whatever their order. The paper reports that this intra-image bidirectional attention matters a great deal for image quality.
Worked examples
The model gives the true next text token probability 0.5. Find the text loss at that position, using natural logarithms.
- Write the loss: .
- Substitute : .
- Use , so the loss is .
- Interpretation: a probability of one half gives a loss of about 0.69. If the probability had been one, the loss would have been zero.
Take and . Use the paper's cosine approximation to find the signal and noise weights, then noise a latent value with noise .
- Compute the angle: , which is .
- Signal weight: .
- Noise weight: . Check: .
- Scale the signal: .
- Scale the noise: .
- Add: .
- Interpretation: the latent is still mostly signal at this step. The model has to predict from and .
Table 3 of the paper gives a parity FLOP ratio of 0.029 for image generation FID: Transfusion needs 2.9 percent of Chameleon's compute to match Chameleon's FID.
- Read the ratio: .
- Invert it to get how many times less compute: .
- Interpretation: Transfusion matches Chameleon's FID with about 34 times less compute. The paper gives the ratio 0.029 in Table 3, and this 34 is just its inverse.
- Compare with the Llama accuracy row of the same table: its ratio is , so Transfusion needs 60 percent of Chameleon's compute to match that accuracy.
- Try it: what is the number of times less compute for the Llama accuracy match, ? Work it out before reading on.
Answer: , so about 1.7 times less compute, which is the same fact as needing 60 percent of the compute.
Common mistakes and tradeoffs
It is tempting to think Transfusion is just a language model with an image generator bolted on. In fact there is one set of transformer weights, one sequence and one optimiser; only the small patch encoders and decoders are specific to each modality.
It is tempting to think the diffusion loss is computed per patch. In fact the image gets one noise level and one loss, even though it spans many patches. Noise is added to the whole latent before patchification.
It is tempting to think a continuous representation is always better than discrete tokens. In fact the paper reports that Transfusion beats the token approach at matched compute on the benchmarks it tested, but the comparison is on one controlled setup with models up to 7B.
It is tempting to think bidirectional attention can be used everywhere. In fact the mask stays causal across the sequence and is only bidirectional within an image, so the text stays a left-to-right model.
Use Transfusion's recipe when one model must both read and produce text and images at scale and the images can be kept as latents. Do not expect it to beat specialised image generators on image quality alone: the paper's own table shows SD 3 above it on GenEval. For image-only work, a plain latent diffusion model is simpler; for text-only work, a standard Autoregressive Model is enough. The alternatives are the token approach of Chameleon, which keeps one loss but loses information, and grafting a pretrained generator onto a language model, which keeps each part strong but trains them apart.
History
Next-token prediction and diffusion were developed in separate communities. Diffusion models for images came into wide use after denoising diffusion probabilistic models in 2020, and latent diffusion made them efficient by working in a compressed latent space in 2022. Language models trained with next-token prediction scaled up through the late 2010s and early 2020s. Through 2023 and 2024, several groups built mixed-modal systems, most by combining existing parts or by quantizing images. Chameleon, in 2024, was the open baseline that discretised images and trained one language model over both. Transfusion, posted to arXiv in August 2024, asked whether the discretisation step was needed at all. It caught on because it showed a clean controlled comparison at matched compute, and because it gave a single recipe that both loss families could share.
Results
The paper compares a 7B Transfusion model with a 7B Chameleon model trained on the same 0.5T tokens, with the same data, compute and architecture except the image representation.
| Metric (direction) | Transfusion 7B | Chameleon 7B | Parity FLOP ratio |
|---|---|---|---|
| C4 perplexity (lower is better) | 7.72 | 8.41 | 0.489 |
| Wikipedia perplexity (lower is better) | 4.28 | 4.69 | 0.526 |
| Llama accuracy (higher is better) | 61.5 | 59.1 | 0.600 |
| MS-COCO CIDEr (higher is better) | 27.2 | 18.0 | 0.218 |
| MS-COCO FID (lower is better) | 16.8 | 29.6 | 0.029 |
| MS-COCO CLIP (higher is better) | 25.5 | 24.3 | 0.319 |
Table 3 of the paper, with the parity FLOP ratio defined as the Transfusion FLOPs needed to match the Chameleon 7B result.
The larger 7B model with U-Net patch encoding, trained on 2T tokens, is compared with other image generators on GenEval, a benchmark for how faithfully a model depicts a prompt.
| Model | Image training | GenEval (higher is better) |
|---|---|---|
| DALL-E 2 | 2.6B images | 0.52 |
| SDXL | 1.6B images | 0.55 |
| DeepFloyd | 7.5B images | 0.61 |
| Transfusion 7B | 3.5B images, 1.0T text tokens | 0.63 |
| SD 3 | 2.0B images | 0.68 |
The paper also reports that Transfusion's Llama accuracy is 66.1, the same as Llama 1 on that suite, and that its COCO FID is 6.78. The U-Net encoder and decoder add 0.27B parameters, or 3.8 percent of the 7B model.
Ablations give the other main findings. Intra-image bidirectional attention lowers FID from 61.3 to 20.3 with linear patch encoding. With U-Net layers, an image can be compressed to 16 patches of 8×8 latent pixels, with FID 16.1 and CLIP 25.2, against FID 16.0 and CLIP 25.7 at 64 patches. Limiting diffusion noise to on the 20 percent of samples where the image comes first raises CIDEr from 33.7 to 35.2 at 7B.
Limits. Most controlled comparisons use 0.5T tokens and models up to 7B. The FLOP ratio uses the approximation as a proxy for compute. Chameleon's architecture changes for stability confound some of the text comparison, which the paper acknowledges. The image editing result is a fine-tuning test on 8k examples, judged by manual inspection, and the paper calls it a limited experiment. The paper also notes that SD 3 was trained with synthetic captions, which boosts its GenEval score.
Reading guide
- Abstract and Section 1 (Introduction): the question and the claims; read with Autoregressive Model and Diffusion Model in mind.
- Section 2.1 (Language Modeling): the next-token loss; see Cross-Entropy Loss and Language Model.
- Section 2.2 (Diffusion): forward and reverse processes, the noise schedule and classifier-free guidance; see Diffusion Model, Cosine Noise Schedule and Classifier-Free Guidance.
- Section 2.3 (Latent Image Representation): VAEs and vector quantization; see Variational Autoencoder and Vector Quantization.
- Section 3 (Transfusion): data representation, architecture, attention mask, training objective and inference; see Transformer, Attention Mechanism and U-Net. The transformer uses the Llama block, see LLaMA: Open and Efficient Foundation Language Models and Rotary Position Embedding.
- Section 4 (Experiments): evaluation, controlled comparison, ablations, and the GenEval comparison; see Fréchet Inception Distance for FID and Latent Diffusion Model for the image pipeline.
- Appendix A (Autoencoder details): the VAE and VQ-VAE losses; read after Variational Autoencoder.
Check yourself
QuestionWhich loss is applied to text, which to images, and how are they combined?Show answer
QuestionA training step gives and . What is the total loss with the paper's ?Show answer
QuestionWhy does Transfusion use bidirectional attention between the patches of one image, but causal attention everywhere else?Show answer
QuestionA team quantizes each image into one of 16,384 codebook tokens and trains a standard language model. What information is lost, and what would Transfusion keep?Show answer
Sources
- Transfusion: Predict the Next Token and Diffuse Images with One Multi-Modal Model, arXiv: https://arxiv.org/abs/2408.11039
- Chameleon: Mixed-modal early-fusion foundation models, arXiv: https://arxiv.org/abs/2405.09818