请遵循下面内容，总结下面的内容；然后生成transfusion 的训练代码和推理代码，要求1，必须体现论文的所有创新内容；2，代码必须完整且能够直接运行
Transfusion: Predict the Next Token and Diffuse Images with One Multi-Modal Model
Chunting Zhouμ∗ Lili Yuμ∗ Arun Babuδ† Kushal Tirumalaμ Michihiro Yasunagaμ Leonid Shamisμ Jacob Kahnμ Xuezhe Maσ Luke Zettlemoyerμ Omer Levy†
μ Meta δ Waymo σ University of Southern California
Abstract
We introduce Transfusion, a recipe for training a multi-modal model over discrete and continuous data. Transfusion combines the language modeling loss function (next token prediction) with diffusion to train a single transformer over mixed- modality sequences. We pretrain multiple Transfusion models up to 7B parameters from scratch on a mixture of text and image data, establishing scaling laws with respect to a variety of uni- and cross-modal benchmarks. Our experiments show that Transfusion scales significantly better than quantizing images and training a language model over discrete image tokens. By introducing modality-specific en- coding and decoding layers, we can further improve the performance of Transfusion models, and even compress each image to just 16 patches. We further demonstrate that scaling our Transfusion recipe to 7B parameters and 2T multi-modal tokens produces a model that can generate images and text on a par with similar scale diffusion models and language models, reaping the benefits of both worlds.
1 Introduction
Multi-modal generative models need to be able to perceive, process, and produce both discrete elements (such as text or code) and continuous elements (e.g. image, audio, and video data). While language models trained on the next token prediction objective dominate discrete modalities [OpenAI et al., 2024, Dubey et al., 2024], diffusion models [Ho et al., 2020, Rombach et al., 2022a] and their generalizations [Lipman et al., 2022] are the state of the art for generating continuous modalities [Dai et al., 2023, Esser et al., 2024b, Bar-Tal et al., 2024]. Many efforts have been made to combine these approaches, including extending a language model to use a diffusion model as a tool, either explicitly [Liu et al., 2023] or by grafting a pretrained diffusion model onto the language model [Dong et al., 2023, Koh et al., 2024]. Alternatively, one can quantize the continuous modalities [Van Den Oord et al., 2017] and train a standard language model over discrete tokens [Ramesh et al., 2021, Yu et al., 2022, 2023], simplifying the model’s architecture at the cost of losing information. In this work, we show it is possible to fully integrate both modalities, with no information loss, by training a single model to both predict discrete text tokens and diffuse continuous images.
We introduce Transfusion, a recipe for training a model that can seamlessly generate discrete and continuous modalities. We demonstrate Transfusion by pretraining a transformer model on 50% text and 50% image data using a different objective for each modality: next token prediction for text and diffusion for images. The model is exposed to both modalities and loss functions at each training step. Standard embedding layers convert text tokens to vectors, while patchification layers represent cute cat . <BOI> What color is its nose ?
Transformer
A cute cat . <BOI> <EOI> What color is its nose
Figure 1: A high-level illustration of Transfusion. A single transformer perceives, processes, and produces data of every modality. Discrete (text) tokens are processed autoregressively and trained on the next token prediction objective. Continuous (image) vectors are processed together in parallel and trained on the diffusion objective. Marker BOI and EOI tokens separate the modalities.
each image as a sequence of patch vectors. We apply causal attention for text tokens and bidirectional attention for image patches. For inference, we introduce a decoding algorithm that combines the standard practices of text generation from language models and image generation from diffusion models. Figure 1 illustrates Transfusion.
In a controlled comparison with Chameleon’s discretization approach [Chameleon Team, 2024], we show that Transfusion models scale better in every combination of modalities. In text-to-image generation, we find that Transfusion exceeds the Chameleon approach at less than a third of the compute, as measured by both FID and CLIP scores. When controlling for FLOPs, Transfusion achieves approximately 2× lower FID scores than Chameleon models. We observe a similar trend in image-to-text generation, where Transfusion matches Chameleon at 21.8% of the FLOPs. Surprisingly, Transfusion is also more efficient at learning text-to-text prediction, achieving perplexity parity on text tasks around 50% to 60% of Chameleon’s FLOPs.
Ablation experiments reveal critical components and potential improvements for Transfusion. We observe that the intra-image bidirectional attention is important, and that replacing it with causal attention hurts text-to-image generation. We also find that adding U-Net down and up blocks to encode and decode images enables Transfusion to compress larger image patches with relatively small loss to performance, potentially decreasing the serving costs by up to 64×.
Finally, we demonstrate that Transfusion can generate images at similar quality to other diffusion models. We train from scratch a 7B transformer enhanced with U-Net down/up layers (0.27B parameters) over 2T tokens: 1T text tokens, and approximately 5 epochs of 692M images and their captions, amounting to another 1T patches/tokens. Figure 2 shows some generated images sampled from the model. On the GenEval [Ghosh et al., 2023] benchmark, our model outperforms other popular models such as DALL-E 2 and SDXL; unlike those image generation models, it can generate text, reaching the same level of performance as Llama 1 on text benchmarks. Our experiments thus show that Transfusion is a promising approach for training truly multi-modal models.
2 Background
Transfusion is a single model trained with two objectives: language modeling and diffusion. Each of these objectives represents the state of the art in discrete and continuous data modeling, respectively. This section briefly defines these objectives, as well as background on latent image representations.
2.1 Language Modeling
Given a sequence of discrete tokens y = y1, ..., yn from a closed vocabulary V , a language model predicts the probability of the sequence P (y). Standard language models decompose P (y) into a product of conditional probabilities Qni=1 Pθ(yi|y<i). This creates an autoregressive classification task, where the probability distribution of each token yi is predicted conditioned on the prefix of a sequence y<i using a single distribution Pθ parameterized by θ. The model can be optimized by minimizing the cross-entropy between Pθ and the empirical distribution of the data, yielding the standard next-token prediction objective, colloquially referred to as LM loss:
L =E−logP(y|y) (1)
Once trained, language models can also be used to generate text by sampling token by token from the model distribution Pθ, typically using temperature and top-p truncation.
2.2 Diffusion
Denoising diffusion probabilistic models (a.k.a. DDPM or diffusion models) operate on the principle of learning to reverse a gradual noise-addition process [Ho et al., 2020]. Unlike language models that typically work with discrete tokens (y), diffusion models operate over continuous vectors (x), making them particularly suited for tasks involving continuous data like images. The diffusion framework involves two processes: a forward process that describes how the original data is turned into noise, and a reverse process of denoising that the model learns to perform.
Forward Process From a mathematical perspective, the forward process defines how the noised data
(which serves as the model input) is created. Given a data point x0, Ho et al. [2020] define a Markov
chain that gradually adds Gaussian noise over T steps, creating a sequence of increasingly noisy ver-
Here, α ̄t = Qts=1(1 − βs), providing a useful abstraction over the original Markov chain. In fact, both the training objective and the noise scheduler are eventually expressed (and implemented) in these terms.
Reverse Process The diffusion model is trained to perform the reverse process pθ(xt−1|xt), learning to denoise the data step by step. There are several ways to do so; in this work, we follow the approach of Ho et al. [2020] and model the Gaussian noise ε in Equation 2 as a proxy for the cumulative noise at step t. Specifically, a model εθ(·) with parameters θ is trained to estimate the noise ε given the noised data xt and timestep t. In practice, the model often conditions on additional contextual information c, such as a caption when generating an image. The parameters of the noise prediction model are thus optimized by minimizing the mean squared error loss:
LDDPM =Ex0,t,ε||ε−εθ(xt,t,c)||2 (3)
Noise Schedule When creating a noised example xt (Equation 2), α ̄t determines the variance of the noise for timestep t. In this work, we adopt the commonly used cosine scheduler Nichol and Dhariwal [2021], which largely follows √α ̄t ≈ cos(Tt · π2 ) with some adjustments.
Inference Decoding is done iteratively, pealing away some of the noise at each step. Starting with pure Gaussian noise at xT , the model εθ(xt, t, c) predicts the noise accumulated at timestep t. The predicted noise is then scaled according to the noise schedule, and the proportional amount of predicted noise is removed from xt to produce xt−1. In practice, inference is done over fewer timesteps than training. Classifier-free guidance (CFG) [Ho and Salimans, 2022] is often used to improve generation by contrasting the prediction of the model conditioned on the context c with the unconditioned prediction, at the cost of doubling the computation.
2.3 Latent Image Representation
Early diffusion models worked directly in pixel space [Ho et al., 2020], but this proved computation- ally expensive. Variational autoencoders (VAEs) [Kingma and Welling, 2013] can save compute by encoding images into a lower-dimensional latent space. Implemented as deep CNNs, modern VAEs are trained on a combination of reconstruction and regularization losses [Esser et al., 2021], allowing downstream models like latent diffusion models (LDMs) [Rombach et al., 2022a] to operate efficiently on compact image patch embeddings; e.g. represent every 8×8 pixel patch as an 8-dimensional vector. For autoregressive language modeling approaches [Ramesh et al., 2021, Yu et al., 2022], images must be discretized. Discrete autoencoders, such as vector-quantized VAEs (VQ-VAE) [Van Den Oord et al., 2017], achieve this by introducing a quantization layer (and related regularization losses) that maps continuous latent embeddings to discrete tokens.
√√ xt= α ̄tx0+ 1−α ̄tε (2)
√
sions x1, x2, ..., xT . Each step of this process is defined by q(xt|xt−1) = N (xt; where βt increases over time according to a predefined noise schedule (see below). This process can be reparameterized in a way that allows us to directly sample xt from x0 using a single sample of Gaussian noise ε ∼ N (0, I):
1 − βtxt−1, βtI),
4
VAE Decoder
Linear or
U-Net Up
A cute cat <BOI> <EOI> What
A cute cat
<BOI>
<EOI> What
or U-Net Down Noising
VAE Encoder
Figure 3: We convert images to and from la- tent representations using a pretrained VAE, and then into patch representations with either a sim- ple linear layer or U-Net down blocks.
3 Transfusion
Linear
Transfusion is a method for training a single unified model to understand and generate both discrete and continuous modalities. Our main innovation is demonstrating that we can use separate losses for different modalities – language modeling for text, diffusion for images – over shared data and parameters. Figure 1 illustrates Transfusion.
Data Representation We experiment with data spanning two modalities: discrete text and continu- ous images. Each text string is tokenized into a sequence of discrete tokens from a fixed vocabulary, where each token is represented as an integer. Each image is encoded as latent patches using a VAE (see §2.3), where each patch is represented as a continuous vector; the patches are sequenced left-to-right top-to-bottom to create a sequence of patch vectors from each image.3 For mixed-modal examples, we surround each image sequence with special beginning of image (BOI) and end of image (EOI) tokens before inserting it to the text sequence; thus, we arrive at a single sequence potentially containing both discrete elements (integers representing text tokens) and continuous elements (vectors representing image patches).
Model Architecture The vast majority of the model’s parameters belong to a single transformer, which processes every sequence, regardless of modality.45 The transformer takes a sequence of high-dimensional vectors in Rd as input, and produces similar vectors as output. To convert our data into this space, we use lightweight modality-specific components with unshared parameters. For text, these are the embedding matrices, converting each input integer to vector space and each output vector into a discrete distribution over the vocabulary. For images, we experiment with two alternatives for compressing local windows of k × k patch vectors into a single transformer vector
(and vice versa): (1) a simple linear layer,6 and (2) up and down blocks of a U-Net [Nichol and Dhariwal, 2021, Saharia et al., 2022].7 Figure 3 illustrates the overall architecture.
Transfusion Attention Language models typically use causal masking to efficiently compute the loss and gradients over an entire sequence in a single forward-backward pass without leaking information from future tokens. While text is naturally sequential, images are not, and are usually modeled with unrestricted (bidirectional) attention. Transfusion combines both attention patterns by applying causal attention to every element in the sequence, and bidirectional attention within the elements of each individual image. This allows every image patch to attend to every other patch within the same image, but only attend to text or patches of other images that appeared previously in the sequence. We find that enabling intra-image attention significantly boosts model performance (see §4.3). Figure 4 shows an example Transfusion attention mask.
Training Objective To train our model, we apply the language modeling objective LLM to pre- dictions of text tokens and the diffusion objective LDDPM to predictions of image patches. LM loss is computed per token,8 while diffusion loss is computed per image, which may span multiple elements (image patches) in the sequence. Specifically, we add noise ε to each input latent image x0 according to the diffusion process to produce xt before patchification, and then compute the image-level diffusion loss.9 We combine the two losses by simply adding the losses computed over each modality with a balancing coefficient λ:
LTransfusion = LLM + λ · LDDPM (4)
This formulation is a specific instantiation of a broader idea: combining a discrete distribution loss with a continuous distribution loss to optimize the same model. We leave further exploration of this space, such as replacing diffusion with flow matching [Lipman et al., 2022]), to future work.
Inference Reflecting the training objective, our decoding algorithm also switches between two modes: LM and diffusion. In LM mode, we follow the standard practice of sampling token by token from the predicted distribution. When we sample a BOI token, the decoding algorithm switches to diffusion mode, where we follow the standard procedure of decoding from diffusion models. Specifically, we append a pure noise xT in the form of n image patches to the input sequence (depending on the desired image size), and denoise over T steps. At each step t, we take the noise prediction and use it to produce xt−1, which then overwrites xt in the sequence; i.e. the model always conditions on the last timestep of the noised image and cannot attend to previous timesteps. Once the diffusion process has ended, we append an EOI token to the predicted image, and switch back to LM mode. This algorithm enables the generation of any mixture of text and image modalities.
4 Experiments
We demonstrate in a series of controlled experiments that Transfusion is a viable, scalable method for training a unified multi-modal model.
4.1 Setup
Evaluation We evaluate model performance on a collection of standard uni-modal and cross- modal benchmarks (Table 1). For text-to-text, we measure perplexity on 20M held-out tokens from Wikipedia and the C4 corpus [Raffel et al., 2019], as well as accuracy on the pretraining evaluation suiteofLlama2[Touvronetal.,2023b].10 Fortext-to-image,weusetheMS-COCObenchmark [Lin et al., 2014], where we generate images on randomly selected 30k prompts from validation set and measure their photo-realism using zero-shot Frechet Inception Distance (FID) [Heusel et al.,Metric
Perplexity (↓) Perplexity (↓) Accuracy (↑)
CIDEr (↑) FID (↓), CLIP (↑)
GenEval score (↑) Table 1: An overview of the evaluation suite used in this
work.
Text Text
Wikipedia C4 Llama 2 Eval Suite
MS-COCO 5k
Size Layers
0.16B 16 0.37B 24 0.76B 24 1.4B 24 7B 32
Emb Dim
     768
    1024
    1536
    2048
    4096
Att Heads
12 16 24 16 32
Image Text Text Image
MS-COCO 30k GenEval
2017] as well as their alignment with the prompts using CLIP score [Radford et al., 2021].11 We also evaluate the model’s ability to generate image captions; we report CIDEr [Vedantam et al., 2015] scores on the Karpathy test split of MS-COCO [Lin et al., 2014]. These evaluations provide signal for investigation scaling laws (§4.2) and ablations (§4.3). To compare with recent literature in diffusion models, we evaluate our largest scale model (§4.4) also on GenEval [Ghosh et al., 2023], a benchmark that examines a model’s ability to generate an accurate depiction of the prompt.
Baseline At the time of writing, the prominent open-science method for training a single mixed- modal model that can generate both text and images is to quantize images into discrete tokens, and then model the entire token sequence with a standard language model [Ramesh et al., 2021, Yu et al., 2022, 2023]. We follow the recipe of Chameleon [Chameleon Team, 2024] to train a family of data- and compute-controlled baseline models, which we can directly compare to our Transfusion models. The key difference between Chameleon and Transfusion is that while Chameleon discretizes images and processes them as tokens, Transfusion keeps images in continuous space, removing the quantization information bottleneck. To further minimize any confounding variables, we train the VAEs for Chameleon and Transfusion using exactly the same data, compute, and architecture, with the only differentiator being the quantization layer and codebook loss of Chameleon’s VQ-VAE (see details below). Chameleon also deviates from the Llama transformer architecture, adding query-key normalization, post-normalization, denominator loss, and a lower learning rate of 1e-4 to manage training instability, which incur an efficiency cost (see §4.2).12
Data For almost all of our experiments, we sample 0.5T tokens (patches) from two datasets at a 1:1 token ratio. For text, we use the Llama 2 tokenizer and corpus [Touvron et al., 2023b], containing 2T tokens across a diverse distribution of domains. For images, we use a collection of 380M licensed Shutterstock images and captions. Each image is center-cropped and resized to produce a 256×256 pixel image.13 We randomly order the image and captions, ordering the caption first 80% of the time.
In one experiment (4.4) we scale up the total training data to 2T tokens (1T text tokens and about 3.5B caption-image pairs at 256 patches per image). To diversify, we add 220M publicly available images with captions, prefiltered to not contain people. To rebalance the distribution, we upsample 80M Shutterstock images containing people. We also add data from Conceptual 12M (CC12M) [Changpinyo et al., 2021], reaching a total mixture of 692M image-caption pairs per epoch. Finally, we upweight the portion of high-aesthetic images in the last 1% of the training schedule.
Latent Image Representation We train a 86M parameter VAE following Esser et al. [2021]. We use a CNN encoder and decoder, and latent dimension 8. The training objective is combines reconstruction and regularization losses.14 Our implementation reduces an image of 256×256 pixels to a 32×32×8 tensor, where each latent 8-dimensional latent pixel represents (conceptually) an 8×8 pixel patch in the original image, and trains for 1M steps. For VQ-VAE training, we follow the same setup described for VAE training, except we replace LKL with the standard codebook commitment loss with β = 0.25 [Van Den Oord et al., 2017]. We use a codebook of 16,384 token types.
Model Configuration To investigate scaling trends, we train models at five different sizes – 0.16B, 0.37B, 0.76B, 1.4B, and 7B parameters – following the standard settings from Llama [Touvron et al., 2023a]. Table 2 describes each setting in detail. In configurations that use linear patch encoding (§4.2 and §4.3), the number of additional parameters is insignificant, accounting for fewer than 0.5% of total parameters in every configuration. When using U-Net patch encoding (§4.3 and §4.4), these parameters add up to 0.27B additional parameters across all configurations; while this is a substantial addition of parameters to smaller models, these layers amount to only a 3.8% increase of the 7B configuration, almost identical to the number of parameters in the embedding layers.
Optimization We randomly initialize all model parameters, and optimize them using AdamW (β1 =0.9, β2 =0.95, ε =1e-8) with a learning rate of 3e-4, warmed up for 4000 steps and decaying to 1.5e-5 using a cosine scheduler. We train on sequences of 4096 tokens in batches of 2M tokens for 250k steps, reaching 0.5T tokens in total. In our large-scale experiment (§4.4), we train with a batch size of 4M tokens over 500k steps, totalling 2T tokens. We regularize with weight decay of 0.1 and clip gradients by norm (1.0). We set the λ coefficient in the Transfusion objective (Equation 4) to 5 following preliminary experiments; we leave further tuning of λ to future work.
Inference In text mode, we use greedy decoding for generating text. Ranked classification is used for the Llama evaluation suite. For image generation, we follow the standard of 250 diffusion steps (the model is trained on 1,000 timesteps). We follow Chameleon and use CFG with a coefficient of 5 in the controlled comparison experiments (§4.2). This value is suboptimal for Transfusion, and so we use a CFG coefficient of 3 throughout the ablation experiments (§4.3), and follow the standard practice of tuning the coefficient for each benchmark in our large scale experiment (§4.4).
4.2 Controlled Comparison with Chameleon
We run a series of controlled experiments to compare Transfusion with Chameleon at different model sizes (N) and token counts (D), using the combination of both as a proxy for FLOPs (6ND).15 For simplicity and parameter control, the Transfusion variant in these experiments uses simple linear image encoder/decoder with patch size 2×2, as well as bidirectional attention. For each benchmark, weplotallresultsonalog-metricoverlog-FLOPscurveandregresslineartrendlines.16 Wealso estimate relative compute efficiency by measuring the parity FLOP ratio: the ratio between the number of FLOPs required by Transfusion and Chameleon to reach the same level of performance.
Figure 5 visualizes the scaling trends, and Table 3 shows the results of the largest models in this controlled setting and their estimated parity FLOP ratio. In every benchmark, Transfusion consistently exhibits better scaling laws than Chameleon. While the lines are close to parallel, there is a significant gap in Transfusion’s favor. The difference in compute efficiency is particularly striking in image generation, where FID Transfusion achieves parity with Chameleon using 34× less compute.
Surprisingly, text-only benchmarks also reveal better performance with Transfusion, even though both Transfusion and Chameleon model text in the same way. We investigate this phenomenon by ablating the various changes leading up to Transfusion and Chameleon from the original Llama 2 recipe. Table 4 shows that while Transfusion does come at a non-zero cost to text performance, the Chameleon recipe suffers from both the stability modifications made to the architecture and from the introduction of image tokens. Training on quantized image tokens degrades text performance more than diffusion on all three benchmarks. One hypothesis is that this stems from the competition between text and image tokens in the output distribution; alternatively, it is possible that diffusion is more efficient at image generation and requires fewer parameters, allowing Transfusion models to use more capacity than Chameleon to model text. We leave further investigation of this phenomenon to future research.
4.3 Architecture Ablations
Now that we have established that Transfusion is a viable, scalable approach to multi-modal modeling in a controlled environment, we can explore improvements and extensions that are applicable to Transfusion alone.
4.3.1 Attention Masking
We first examine the necessity of intra-image bidirectional attention. Table 5 shows that enabling this attention pattern beyond the standard causal attention is advantageous throughout all benchmarks, and using both image encoding/decoding architectures. In particular, we notice a significant improvement in FID when using linear encoding layers (61.3→20.3). In the causal-only version of this architecture, there is no flow of information from patches that appear later in the sequence to those before; since U-Net blocks contain bidirectional attention within, independent of the transformer’s attention mask, this gap is less pronounced when they are applied.
4.3.2 Patch Size
Transfusion models can be defined over different sizes of latent pixel patches. Larger patch sizes allow the model to pack more images in each training batch and dramatically reduce inference compute, but may come at a performance cost. Table 6 sheds light on these performance trade-offs. While performance does decrease consistently as each image is represented by fewer patches with linear encoding, models with U-Net encoding benefit from larger patches on tasks involving the image modality. We posit that this is due to the greater amount of total images (and diffusion noise) seen during training. We also observe that text performance deteriorates with larger patches, perhaps because transfusion needs to exert more resources (i.e. parameters) to learn how to process images with fewer patches and thus less inference compute.
4.3.3 Patch Encoding/Decoding Architecture
Our experiments so far indicate an advantage to using the U-Net up and down blocks instead of a simple linear layer. One possible reason is that the model benefits from the inductive biases of the U-Net architecure; an alternative hypothesis is that this advantage stems from the significant increase in overall model parameters introduced by the U-Net layers. To decouple these two confounders, we scale up the core transformer to 7B parameters, while keeping the amount of U-Net parameters
(almost) constant;17 in this setting, the additional encoder/decoder parameters account for only a 3.8% increase of total model parameters, equivalent to the amount of token embedding parameters.
Table 7 shows that even though the relative benefit of U-Net layers shrinks as the transformer grows, it does not diminish. In image generation, for example, the U-Net encoder/decoder allows much smaller models to obtain better FID scores than the 7B model with linear patchification layers. We observe a similar trend in image captioning, where adding U-Net layers boosts the CIDEr score of a 1.4B transformer (1.67B combined) beyond the performance of the linear 7B model. Overall, it appears that there are indeed inductive bias benefits to U-Net encoding and decoding of images beyond the mere addition of parameters.
4.3.4 Image Noising
Our experiments order 80% of image-caption pairs with the caption first, and the image conditioning on the caption, following the intuition that image generation may be a more data-hungry task than image understanding. The remaining 20% of the pairs condition the caption on the image. However, these images are noised as part of the diffusion objective. We thus measure the effect of limiting the diffusion noise to a maximum of t = 500 (half of the noise schedule) in the 20% of cases where images appear before their captions. Table 8 shows that noise limiting significantly improves image captioning, as measure by CIDEr, while having a relatively small effect (less than 1%) on other benchmarks.
4.4 Comparison with Image Generation Literature
Our experiments thus far have covered controlled comparisons with Chameleon and Llama, but we have yet to compare Transfusion’s image generation capabilities to those of state-of-the-art image generation models. To that end, we train a 7B parameter model with U-Net encoding/decoding layers (2×2 latent pixel patches) over the equivalent of 2T tokens, comprising of 1T text corpus tokens and 3.5B images and their captions. While the Transfusion variant in §4.2 favored simplicity and experimental control, the design choices and data mixture (§4.1) of this variant lean a bit more towards image generation. Figure 2 and Appendix B showcase generated images from this model.
We compare the performance of our model to reported results of other similar scale image generation models, as well as some publicly available text generating models for reference. Table 9 shows that Transfusion achieves similar performance to high-performing image generation models such as DeepFloyd [Stability AI, 2024], while surpassing previously published models including SDXL [Podell et al., 2023]. While Transfusion does lag behind SD 3 [Esser et al., 2024a], this model leveraged synthetic image captions through backtranslation [Betker et al., 2023], which enhances its GenEval performance by 6.5% absolute (0.433→0.498) at smaller scale; for simplicity, our experimental setup only included natural data. Finally, we note that our Transfusion model can also generate text, and performs on par with the Llama models, which were trained on the same text data distribution (§4.1).
4.5 Image Editing
Our Transfusion models, which have been pretrained on text-text, image-text, and text-image data, perform well across these modality pairings. Can these models extend their capabilities to generate images based on other images? To investigate, we fine-tuned our 7B model (§4.4) using a dataset of only 8k publicly available image editing examples, where each example consists of an input image, an edit prompt, and an output image. This approach, inspired by LIMA [Zhou et al., 2024], allows us to assess how well the model can generalize to image-to-image generation, a scenario not covered during pretraining.
Manual examination of random examples from the EmuEdit test set [Sheynin et al., 2024], shown in Figure 6 and Appendix 4.5, reveals that our fine-tuned Transfusion model performs image edits as instructed. Despite the limitations of this experiment, the findings suggest that Transfusion models can indeed adapt to and generalize across new modality combinations. We leave further exploration of this promising direction to future research.
5 Related Work
Most existing multi-modal models are built on the idea of attaching two or more modality-specific architectures together, often pretraining each component separately in advance. State-of-the-art image and video generation models, for instance, use large pretrained text encoders to represent their input prompts in latent space, which can then be used to condition diffusion models [Saharia et al., 2022]. In fact, recent work fuses representations from multiple off-the-shelf encoders to enhance performance [Podell et al., 2023, Esser et al., 2024b]. A similar pattern can be observed in the vision language model literature, where typically a pretrained language model is complemented by pretrained modality-specific encoders/decoders via projection layers to/from the pretrained text space. Examples include Flamingo [Alayrac et al., 2022] and LLaVA [Liu et al., 2024] for visual understanding, GILL [Koh et al., 2024] for visual generation, and DreamLLM [Dong et al., 2024] for both visual comprehension and generation. In contrast, Transfusion has one unified architecture learned end-to-end to generate both text and images.
Prior work on end-to-end multi-modal models includes examples such as Fuyu [Bavishi et al., 2023], which uses image patches as inputs for visual understanding, and Chameleon [Chameleon Team, 2024], which converts each image to a sequence of discretized tokens and then trains over the combined text-image token sequences. However, these approaches are either restricted to input-level multi-modal tasks, or lag behind state-of-the-art models (i.e. diffusion models) in continuous data generation. Transfusion provides a simple, end-to-end solution to multi-modal learning that understands and generates high-quality multi-modal data.
An interesting area of recent acrive research is the application diffusion models and their generaliza- tions to discrete text generation [Li et al., 2022, Gat et al., 2024]. However, this approach has yet to achieve the performance and scale of standard autoregressive language models. Future research in this direction may unlock new ways to fuse discrete and continuous modalities in a single model.
6 Conclusion
This work explores how to bridge the gap between the state of the art in discrete sequence modeling (next token prediction) and continuous media generation (diffusion). We propose a simple, yet previously unexplored solution: train a single joint model on two objectives, tying each modality to its preferred objective. Our experiments show that Transfusion scales efficiently, incurring little to no parameter sharing cost, while enabling the generation of any modality.