Taming Transformers for High-Resolution Image Synthesis

The paper introduced a VQGAN-style image tokenizer and used an autoregressive Transformer to model high-level image composition.

Metadata

FieldValue
PaperTaming Transformers for High-Resolution Image Synthesis
AuthorsPatrick Esser, Robin Rombach, Bjorn Ommer
Year2020 preprint; 2021 conference
VenueCVPR 2021
arXiv2012.09841
ProjectCompVis project page
CodeCompVis/taming-transformers
Statusverified

Question

Autoregressive Transformers can model long-range dependencies, but pixel-level image sequences are too long:

The paper asks:

The answer is:

Main Claim

Taming Transformers separates high-resolution synthesis into two stages:

  1. learn a discrete image codebook with a convolutional VQGAN;
  2. train a Transformer prior over the code sequence.

The durable architecture claim is:

This paper sits between VQ-VAE, autoregressive Transformers, and Latent Diffusion Models.

Architecture Contract

ItemContract
Input image
Encodermaps image to latent grid
Quantizermaps latent vectors to codebook indices
Codebooklearned visual vocabulary
Decoderreconstructs image from quantized codes
Priorautoregressive Transformer over discrete image codes
Conditioningclass label, segmentation, depth, edge, or other context
Outputhigh-resolution image synthesis

VQGAN Tokenizer

The encoder maps an image to a latent grid:

Each latent vector is replaced by the nearest codebook vector:

This turns the image into discrete indices:

The decoder reconstructs:

The important difference from pixel tokens is:

Reconstruction and Codebook Training

The tokenizer is trained to make quantized codes reconstruct the image:

VQ-style training also uses codebook and commitment terms:

Taming Transformers adds perceptual and adversarial pressure so that compressed codes preserve visually meaningful structure:

This is why the learned codes are more useful for high-resolution synthesis than a purely pixel-level representation.

Autoregressive Transformer Prior

After tokenization, image generation becomes sequence modeling:

The Transformer learns:

where is optional conditioning.

The generated index sequence is decoded:

Sliding Attention for Large Images

Even after compression, high-resolution images can produce long code sequences. The paper uses a sliding attention window so each prediction attends to a local context window rather than every previous token:

This is an efficiency tradeoff:

AttentionCostBias
full causal attentionglobal but expensivelong-range dependency
sliding causal attentioncheaperlocal composition window

The codebook handles local perceptual content. The Transformer handles composition among tokens.

Why It Matters

Taming Transformers is important because it creates a reusable pattern:

That pattern appears later in latent diffusion:

PaperLatent RepresentationGenerative Prior
VQ-VAEdiscrete codebooklearned prior over codes
Taming TransformersVQGAN codebookautoregressive Transformer
Latent Diffusion Modelscontinuous/perceptual autoencoder latentdiffusion denoiser

Evidence

Evidence TypeWhat It Supports
high-resolution image synthesiscodebook + Transformer can scale beyond pixel-level AR modeling
conditional synthesisdiscrete latent prior can incorporate spatial and non-spatial conditions
ImageNet autoregressive resultscompressed visual tokens improve AR image modeling practicality

Limits

  • Autoregressive sampling over image codes is still sequential.
  • Codebook quality bounds final image quality.
  • Sliding attention introduces locality assumptions that may miss some global dependencies.
  • Later latent diffusion models replace the autoregressive prior with iterative denoising for a different quality/compute tradeoff.

Concepts