Unifying Contrastive and Generative Objectives for Visual Understanding and Text-to-Image Generation
Samples from DREAM-G (2.4B), trained on CC12M.
One model to understand and generate images.
Vision systems typically train separate models for the two tasks. DREAM unifies them in a single encoder–decoder trained end to end, surpassing CLIP on representations and a generation-only baseline on text‑to‑image generation. The two objectives reinforce each other, a step toward foundation models built on one shared visual representation.
Text-image contrastive learning and masked generative modeling are typically trained in separate models. Unifying them in a single end‑to‑end model runs into a fundamental conflict over the masking ratio.
Image-text alignment degrades as the masking ratio grows. Heavy masking starves the encoder of the global semantics that contrastive learning depends on.
Generative models such as MAR train on masking ratios well above 50%. Lightly masked inputs provide too weak a reconstruction signal.
Rather than committing to one regime, DREAM samples masking ratios from a broad distribution whose mean moves from fully visible to fully masked over training. Low and high ratios coexist at every step. This co-exposure stabilizes joint optimization and lets one encoder serve both objectives. By contrast, a fixed high masking ratio collapses ImageNet linear probing to 4.6%.
As training progresses, the distribution slides from fully visible to fully masked but stays wide, so every batch mixes lightly and heavily masked images. Lightly masked samples (≤ 75%) train the contrastive loss, and heavily masked samples (> 50%) train the diffusion loss. Details: truncated Gaussian with σ = 0.45, whose mean rises linearly over the first 200K steps.
Hover over a step to see how that stage is built up.
Images are encoded into continuous latents by the Stable Diffusion VAE. Tokens are masked at ratios drawn from the Masking Warmup schedule, and masked positions are dropped.
A MAR-style ViT encoder processes only the visible tokens (plus learnable buffer tokens). Its mean-pooled embedding is aligned with a CLIP text encoder through a symmetric InfoNCE loss.
A FLUID-style decoder cross-attends to frozen T5-XXL embeddings and predicts the masked latents with a per-token MLP diffusion head. Text conditioning is confined to the decoder, so the encoder cannot rely on language shortcuts.
Joint optimization enables an inference-time capability that decoupled models cannot replicate. Because the text encoder is trained against visual embeddings across the full range of masking ratios, it can reliably score partially decoded images.
Semantically Aligned Decoding spawns K candidate trajectories, decodes each to an intermediate step, scores their sparse visual embeddings against the prompt, and completes only the top-ranked candidate. External CLIP rerankers are trained only on fully visible images, so they must generate every candidate to completion before selecting one.
Hover over a step to see how that stage is built up.
The decoder runs K candidate trajectories for the same prompt in parallel and halts each at an intermediate step, with as little as 12.5% of tokens decoded.
DREAM's vision encoder embeds each candidate from its decoded tokens alone. Cosine similarity with the prompt's CLIP-style text embedding yields an alignment score.
Only the top-scoring trajectory is decoded to completion, conditioned on T5-XXL, and detokenized by the VAE. The remaining K−1 are discarded before incurring full decoding cost.
w/o SD
w/ SD"Watercolor dog portrait"
Fewer artifacts
w/o SD
w/ SD"Sunset over ocean waves"
More defined waves
w/o SD
w/ SD"Busy market street in sunlight"
Cleaner details, less blur
Qualitative comparison of DREAM samples with and without Semantically Aligned Decoding (SD) for identical prompts.
Joint training improves both understanding and generation over single-objective baselines.
In a controlled comparison on CC12M, where all models share the same encoder–decoder architecture and differ only in objective, DREAM (yellow) outperforms CLIP, MAR, FLUID and REPA on every axis: linear probing, fine-tuning, few-shot transfer, semantic segmentation, FID and CLIP Score.
The representation gains extend to dense prediction, with +1.9% on ADE20K segmentation and +6.25% on NYU depth estimation over CLIP.
The encoder's gains are not confined to ImageNet. In the same controlled setting, DREAM outperforms every baseline on few-shot transfer and on robustness after fine-tuning, and matches or beats them on dense prediction with a frozen backbone. Each chart cycles through the baselines, and you can also pick one.
Because it is trained across the full range of masking ratios, DREAM's encoder still recognizes images when most of the input is missing. Understanding and generation also improve together as the model grows.
Zero-shot accuracy (%) as the input is increasingly masked
Zero-shot accuracy versus masking ratio. At 80% masking, DREAM achieves 6.2× the accuracy of CLIP (21.6% vs. 3.5%). DREAM also outperforms CLIP trained with the same schedule (CLIP-M) at every masking level, which points to the locally grounded representations learned through diffusion reconstruction.
ImageNet linear probing (%) ↑
CC12M FID ↓
Both metrics improve consistently from DREAM-B to DREAM-G (σ = 0.45). DREAM overtakes CLIP on linear probing from the L scale onward, and FLUID stays far below both (40.7–50.2%). With Semantically Aligned Decoding, FID improves from 5.56 to 3.62, the best result at every model size.
Samples from DREAM at three model scales, trained on CC12M. The prompts are identical across scales, so switching between them shows how generation quality improves with model size. Prompts are CC12M captions (abbreviated). CFG = 5.0.












Unifying text-image contrastive learning and text-to-image (T2I) generation in a single end-to-end model is challenging because the two objectives demand opposing masking regimes: contrastive alignment needs near-complete visible tokens, while masked generative modeling needs heavy corruption. We introduce DREAM, a unified framework that resolves this conflict through Masking Warmup, a schedule that shifts the center of the masking distribution over training, so low and high masking ratios coexist at every step. This co-exposure lets a single jointly-trained encoder serve both objectives. The resulting stable optimization unlocks Semantically Aligned Decoding at inference: the text encoder, trained against visual embeddings at all masking ratios, can score partially generated images and select the best trajectory with as little as 12.5% of the image decoded, improving both FID and throughput. DREAM outperforms its single-objective baselines, CLIP and FLUID: on ImageNet linear-probing (+1.1%), 5-shot transfer (+4.1%), ADE20K segmentation (+1.9%), and NYU depth estimation (+6.25%) over CLIP, and on CC12M FID (+6.2%) over FLUID while maintaining CLIP Score. Together, these gains show that text-image contrastive and generative objectives, when properly unified, are synergistic rather than competing.
@misc{li2026unifyingcontrastivegenerativeobjectives,
title = {Unifying Contrastive and Generative Objectives for
Visual Understanding and Text-to-Image Generation},
author = {Chao Li and Tianhong Li and Sai Vidyaranya Nuthalapati and
Hong-You Chen and Satya Narayan Shukla and Jianpeng Cheng and
Yonghuan Yang and Jun Xiao and Xiangjun Fan and Aashu Singh and
Dina Katabi and Shlok Kumar Mishra},
year = {2026},
eprint = {2603.02667},
archivePrefix = {arXiv},
primaryClass = {cs.CV},
url = {https://arxiv.org/abs/2603.02667}
}