AdaNAT: Exploring Adaptive Policy for Token-Based Image Generation

Zanlin Ni, Yulin Wang, Renping Zhou, Rui Lu, Jiayi Guo, Jinyi Hu, Zhiyuan Liu, Yuan Yao, Gao Huang · DOI

Abstract

Non-Autoregressive Transformers (NATs) provide a fast alternative to diffusion models for image generation by predicting multiple tokens simultaneously. However, existing NATs rely on rigid, manually-tuned scheduling functions that are often sub-optimal and non-adaptive to image complexity. We propose AdaNAT, a framework that replaces these fixed rules with a learnable policy network. By framing the generation process as a Markov Decision Process (MDP) and utilizing Reinforcement Learning (RL) with an adversarial reward system, AdaNAT dynamically adjusts hyperparameters—such as masking ratios, sampling temperatures, and guidance scales—on the fly for each specific image. AdaNAT achieves a state-of-the-art FID of 2.86 on ImageNet-256 in just 8 sampling steps, while adding negligible computational overhead.

Introduction

In the landscape of generative AI, Diffusion Models have become the standard for high-quality image synthesis. However, Token-Based Generation using Non-Autoregressive Transformers (NATs) offers a compelling alternative due to its superior inference speed. NATs, such as MaskGIT and Muse, generate images by iteratively unmasking tokens on a discrete grid.

Despite their speed, traditional NATs are limited by "hand-me-down" logic: manually designed scheduling functions that dictate how many tokens to refine at each step. These static rules are typically sub-optimal and fail to account for varying image complexity; a simple sky requires less refinement than a detailed cityscape. AdaNAT addresses these limitations by introducing a learnable, adaptive policy that optimizes the generation strategy for every individual sample.

Methods

AdaNAT reformulates the image generation process as a Markov Decision Process (MDP). Instead of following a fixed mathematical formula, a lightweight Policy Network acts as an agent to guide the generation.

Overview of the AdaNAT framework

The RL Agent and Policy

At each generation step $t$, the policy network observes the current state (the partially decoded visual tokens) and outputs optimal hyperparameters for the next step, including the masking ratio, sampling temperature, and Classifier-Free Guidance (CFG) scale. This allows the model to "think" and adjust its effort based on the visual content already generated.

Adversarial Reward Modeling

The policy is trained using Proximal Policy Optimization (PPO). To ensure high visual quality and diversity, the researchers implemented an Adversarial Reward Model. Unlike static metrics (e.g., FID) which can lead to "reward hacking" and distorted images, a discriminator is trained alongside the policy. This discriminator provides a dynamic reward, forcing the policy to produce images that are indistinguishable from the real data distribution.

Key Insights

  • Dynamic Refinement: The model demonstrates clear adaptivity. For simple images, the policy network quickly reduces re-masking, whereas for complex structures, it maintains high refinement levels until the final steps.
  • Avoiding the Overfitting Trap: Using a pre-trained, static reward model often leads to a loss of diversity. The adversarial reward was crucial for maintaining both the quality and variety of generated images.
  • Efficiency: The policy network is extremely lightweight, accounting for only 0.03% of the total computational cost (GFLOPs) during inference, making the performance gains essentially "free" in terms of compute.

Results

AdaNAT sets new benchmarks for efficiency and quality in token-based generation across several datasets:

  • ImageNet-256: Achieved an FID of 2.86 with only 8 sampling steps, representing a ~40% relative improvement over standard manual baselines and outperforming many compute-intensive diffusion models.
  • MS-COCO: On text-to-image synthesis, AdaNAT-S achieved an FID of 5.75, outperforming larger models like Muse while utilizing fewer TFLOPs.
  • Scalability: The framework showed consistent improvements across ImageNet-512 and CC3M, proving its robustness across different resolutions and data scales.

Conclusion and Future Work

AdaNAT demonstrates that teaching Transformers to adaptively manage their own generation strategy significantly improves both quality and efficiency. While currently tested on models up to 230M parameters, future work will explore scaling this adaptive policy to billion-parameter foundation models and testing on massive, uncurated datasets like LAION-5B. Additionally, further research into the interpretability of the agent's decisions could provide deeper insights into the visual generation process.

Code and pre-trained models are available at: https://github.com/LeapLabTHU/AdaNAT

Summary updated

BibTeX
@inproceedings{ni2024adanat,
  author = {Zanlin Ni and Yulin Wang and Renping Zhou and Rui Lu and Jiayi Guo and Jinyi Hu and Zhiyuan Liu and Yuan Yao and Gao Huang},
  title = {{AdaNAT: Exploring Adaptive Policy for Token-Based Image Generation}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72640-8\_17},
}
Figure