MarkovGen: Structured Prediction for Efficient Text-to-Image Generation

Sadeep Jayasumana, Daniel Glasner, Srikumar Ramalingam, Andreas Veit, Ayan Chakrabarti, Sanjiv Kumar

TL;DR

MarkovGen introduces a lightweight Markov Random Field (MRF) layer to "fast-forward" the final, computationally expensive sampling steps of iterative text-to-image models. By explicitly modeling spatial and label compatibility between image patches, it achieves a 1.5x speedup over the state-of-the-art Muse model while simultaneously improving image quality and reducing structural artifacts.

What Problem Does This Paper Address?

Modern text-to-image (T2I) models, whether based on diffusion or parallel decoding, are notoriously slow because they are iterative. To ensure that different regions of an image are compatible—for instance, ensuring that a cat’s left eye matches its right eye—these models must run a massive Transformer backbone multiple times.

While models like Muse have improved speed by predicting tokens in parallel, they still require many sampling steps to reach high fidelity. Simply stopping the process early ("early exiting") leads to "garbage" images filled with structural inconsistencies and artifacts. The challenge is to achieve global compatibility between image regions without the massive overhead of repeated Transformer passes.

MarkovGen improves speed and quality by replacing late-stage sampling steps with a lightweight MRF.

Methods

The authors propose MarkovGen, which integrates a probabilistic graphical model—a fully-connected Markov Random Field (MRF)—into the T2I pipeline.

  1. The Backbone: The system builds on Muse, which operates in a discrete VQGAN token space. Muse predicts a grid of tokens (e.g., 16x16) that are later decoded into an image.
  2. The MRF Layer: Instead of running the full Muse Transformer for the final steps, MarkovGen uses an MRF to jointly model the probability of all tokens. The MRF uses "unaries" (the initial predictions from the Transformer) and "pairwise potentials" that encode how likely two tokens are to appear together at specific spatial locations.
  3. Differentiable Inference: The authors use mean-field inference to solve the MRF. Crucially, they formulate this inference as a sequence of differentiable neural network layers. This allows the spatial and label compatibility parameters to be learned directly from data via backpropagation.
  4. Training: The MRF is trained in two stages: first, a self-supervised task to predict masked tokens, and second, a fine-tuning stage where the MRF learns to "imitate" the final output of a full, multi-step Muse run.
The MRF utilizes learned spatial and label compatibility to refine imperfect token grids.

Datasets

  • WebLI: A large-scale dataset used for training both the base Muse model and the MRF compatibility matrices.
  • MS-COCO: Used for quantitative evaluation of image quality via the Fréchet Inception Distance (FID) score.
  • Parti Prompts: A set of 1,633 prompts used for qualitative study and human preference evaluation.

Key Insights and Ideas

  • Long-Range Compatibility: Unlike traditional MRFs that only look at immediate neighbors, MarkovGen is "fully connected." This allows a token representing a giraffe's eye to influence the selection of a tail token far across the image, ensuring global consistency.
  • Computational Efficiency: The cost of MRF inference is negligible (~0.29ms) compared to a single Transformer sampling step (10.4ms to 24ms). By replacing the last few steps of Muse, the authors save significant time with almost no added latency.
  • Learning Compatibility: Rather than using handcrafted rules (like "nearby pixels should be similar"), the model learns complex relationships—such as which textures belong together—directly from the VQGAN token vocabulary.
Example of how a confident token (eye) influences neighbors (ears, nose) to ensure a consistent giraffe face.

Key Results

  • Speed: MarkovGen achieves a 1.5x speedup over the full Muse model, reducing total inference time from 442ms to 281ms on a TPUv4.
  • Quality (FID): On MS-COCO, MarkovGen achieved an FID of 12.28, outperforming both the full Muse model (13.13) and the early-exit Muse (14.37).
  • Human Preference: In side-by-side comparisons, human raters preferred MarkovGen images over full Muse outputs 85.6% of the time.
  • Artifact Reduction: Qualitative results show that the MRF effectively "fixes" structural issues, such as distorted faces or inconsistent background textures, that appear in the early stages of generation.
Human raters strongly prefer MarkovGen over both early-exit and full Muse models.

Limitations and Future Work

  • Text Conditioning: Currently, the MRF's compatibility matrices are static and do not change based on the text prompt; the prompt only influences the initial "unary" predictions. The authors suggest that making the MRF weights dependent on the text (turning it into a Conditional Random Field or CRF) is a promising next step.
  • Joint Training: The MRF and the Transformer backbone were trained separately. Future work could involve joint training to ensure the Transformer produces unaries that are specifically optimized for MRF-based refinement.
  • Expansion: While demonstrated on Muse, the authors believe this approach could be adapted to other token-based models like Parti or discrete-diffusion models.
Qualitative comparison showing how MarkovGen refines structural details across various prompts.

Summary updated

BibTeX
@inproceedings{jayasumana2024markovgen,
  author = {Sadeep Jayasumana and Daniel Glasner and Srikumar Ramalingam and Andreas Veit and Ayan Chakrabarti and Sanjiv Kumar},
  title = {{MarkovGen: Structured Prediction for Efficient Text-to-Image Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  doi = {10.1109/cvpr52733.2024.00890},
}
Figure