Autoregressive Model Beats Diffusion: Llama for Scalable Image Generation

Peize Sun, Yi Jiang, Shoufa Chen, Shilong Zhang, Bingyue Peng, Ping Luo, Zehuan YuanarXiv 2024

Abstract

We introduce LlamaGen, a new family of image generation models that apply the original "next-token prediction" paradigm of large language models to the visual generation domain. It provides an affirmative answer to whether vanilla autoregressive models, such as Llama, without inductive biases on visual signals can achieve state-of-the-art image generation performance if scaled properly. We reexamine the design spaces of image tokenizers, scalability properties of image generation models, and their training data quality. The outcome of this exploration consists of: (1) An image tokenizer with a downsample ratio of 16, reconstruction quality of 0.94 rFID, and codebook usage of 97% on the ImageNet benchmark. (2) A series of class-conditional image generation models ranging from 111M to 3.1B parameters, achieving 2.18 FID on ImageNet 256x256 benchmarks, outperforming popular diffusion models such as LDM and DiT. (3) A text-conditional image generation model with 775M parameters, trained in two stages on LAION-COCO and high-aesthetic quality images, demonstrating competitive performance in visual quality and text alignment. (4) Verification of the effectiveness of LLM serving frameworks in optimizing inference speed, achieving a 326% - 414% speedup. We release all models and codes to facilitate the open-source community of visual generation and multimodal foundation models.

Introduction

In recent years, Diffusion Models (e.g., Stable Diffusion, DiT) have become the dominant paradigm for image generation, while Autoregressive (AR) models were often considered less scalable or requiring specific visual inductive biases. LlamaGen challenges this assumption by applying the "vanilla" Llama architecture—the same next-token prediction framework used in Large Language Models—to visual data. The central question addressed is whether a standard LLM backbone can achieve state-of-the-art performance simply through optimized tokenization and scaling.

Methods

The LlamaGen framework follows a two-stage paradigm:

Image Tokenization

The researchers re-examined Vector Quantized (VQ) tokenizers to address "codebook collapse." By employing $\ell_2$-normalization of codebook vectors and utilizing a large codebook size of 16,384, they achieved 97% codebook usage. This resulted in a tokenizer with a 16x downsample ratio that maintains high reconstruction quality (0.94 rFID).

Autoregressive Generation

The model adopts the exact Llama architecture, including RMSNorm, SwiGLU, and Rotary Positional Embeddings, without using Adaptive Layer Norm (AdaLN). Images are flattened into 1D sequences via raster scanning, and the model predicts the next visual token conditioned on class labels or text embeddings.

A collage showcasing the diverse image generation capabilities of LlamaGen across various classes and prompts.

Serving Optimization

By maintaining the standard Llama architecture, LlamaGen can be integrated directly into high-performance LLM serving frameworks like vLLM. This enables the use of PagedAttention and KV-caching to mitigate the typical latency issues of AR models.

Results

LlamaGen demonstrates superior performance and scalability across multiple benchmarks.

State-of-the-Art Performance

The 3.1B parameter LlamaGen model achieved a 2.18 FID on ImageNet 256x256, outperforming popular diffusion models like LDM (3.60) and DiT-XL/2 (2.27). This confirms that discrete representations are not a bottleneck for high-fidelity synthesis.

Inference Speedup

Utilizing the vLLM framework resulted in a massive 326% to 414% speedup in inference time compared to baseline AR implementations, making AR generation competitive with diffusion in terms of throughput.

A high-quality text-to-image generation of an anthropomorphic otter, illustrating the model's aesthetic fine-tuning.

Scaling Laws

The study observed clear scaling properties: increasing the model size from 111M to 3.1B parameters consistently improved FID scores, suggesting that further scaling could yield even better results.

Discussion and Conclusion

LlamaGen proves that vanilla autoregressive models can beat diffusion models when scaled correctly. By leveraging the existing LLM ecosystem, vision researchers can benefit from significant engineering optimizations. While the current 775M text-conditional model shows promise, future work will focus on scaling to 7B+ parameters and improving text alignment for complex spatial reasoning and object counting. The results underscore that architectural simplicity, combined with high-quality tokenization and data, is a powerful path forward for multimodal foundation models.

Summary updated

BibTeX
@misc{sun2024autoregressive,
  author = {Peize Sun and Yi Jiang and Shoufa Chen and Shilong Zhang and Bingyue Peng and Ping Luo and Zehuan Yuan},
  title = {{Autoregressive Model Beats Diffusion: Llama for Scalable Image Generation}},
  year = {2024},
  eprint = {2406.06525},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.06525},
}
Figure