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
| Field | Value |
|---|---|
| Paper | Taming Transformers for High-Resolution Image Synthesis |
| Authors | Patrick Esser, Robin Rombach, Bjorn Ommer |
| Year | 2020 preprint; 2021 conference |
| Venue | CVPR 2021 |
| arXiv | 2012.09841 |
| Project | CompVis project page |
| Code | CompVis/taming-transformers |
| Status | verified |
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:
- learn a discrete image codebook with a convolutional VQGAN;
- 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
| Item | Contract |
|---|---|
| Input image | |
| Encoder | maps image to latent grid |
| Quantizer | maps latent vectors to codebook indices |
| Codebook | learned visual vocabulary |
| Decoder | reconstructs image from quantized codes |
| Prior | autoregressive Transformer over discrete image codes |
| Conditioning | class label, segmentation, depth, edge, or other context |
| Output | high-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:
| Attention | Cost | Bias |
|---|---|---|
| full causal attention | global but expensive | long-range dependency |
| sliding causal attention | cheaper | local 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:
| Paper | Latent Representation | Generative Prior |
|---|---|---|
| VQ-VAE | discrete codebook | learned prior over codes |
| Taming Transformers | VQGAN codebook | autoregressive Transformer |
| Latent Diffusion Models | continuous/perceptual autoencoder latent | diffusion denoiser |
Evidence
| Evidence Type | What It Supports |
|---|---|
| high-resolution image synthesis | codebook + Transformer can scale beyond pixel-level AR modeling |
| conditional synthesis | discrete latent prior can incorporate spatial and non-spatial conditions |
| ImageNet autoregressive results | compressed 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.