Introduction
Autoregressive (AR) models have demonstrated remarkable success in sequence modeling, particularly in natural language processing. When applied to visual generation, these models typically treat an image as a sequence of patches, predicting them in a fixed, predefined order—most commonly a "raster-scan" pattern. While effective for standard generation, this rigid structure limits the model's flexibility for downstream tasks like image editing and inpainting.
The Limitations of Fixed Ordering
Traditional AR visual models face two primary challenges. First, the unidirectionality of the raster-scan order (top-left to bottom-right) prevents the model from utilizing future context, making it difficult to fill in missing regions (inpainting) that aren't at the end of the sequence. Second, while random permutation of patches offers a potential solution for flexibility, it often leads to a significant degradation in image quality. This is because random shuffling destroys spatial locality—the natural relationship between neighboring pixels—and fails to account for the "center bias" inherent in most photographic compositions.
The STAR Framework
To address these issues, the authors propose Spanning Tree Autoregressive (STAR) modeling. This approach introduces a structured yet randomized ordering mechanism based on graph theory.
Uniform Spanning Trees (UST)
Instead of a linear sequence, STAR treats the image grid as a lattice graph where each patch is a node. For each generation step, the model samples a random Uniform Spanning Tree (UST) using Wilson’s algorithm. This tree connects every patch in the grid without cycles, providing a skeleton for the prediction sequence.
BFS Traversal and Locality
To convert the tree into a sequence suitable for a Transformer, the model performs a Breadth-First Search (BFS) starting from a random corner. This traversal ensures that the model predicts patches in a way that prioritizes immediate neighbors, thereby preserving spatial locality. By starting from corners and moving inward, the model also implicitly learns to handle center-weighted information more effectively than random shuffling.
Flexible Image Editing
For tasks like inpainting, STAR employs a rejection sampling strategy. The goal is to find a spanning tree traversal where the "known" (unmasked) patches appear at the beginning of the sequence (the prefix), allowing the model to generate the "unknown" (masked) patches as the remainder (the postfix). This allows the model to "see" the surrounding context regardless of where the hole is located in the image.
Experimental Results
The STAR framework was evaluated on the ImageNet-1k dataset at 256×256 resolution using a standard decoder-only Transformer architecture.
- Generative Quality: The STAR-XXL model (1.5B parameters) achieved a state-of-the-art Fréchet Inception Distance (FID) of 1.55, outperforming many diffusion-based models and remaining highly competitive with the best fixed-order AR models.
- Inpainting Performance: STAR demonstrated a clear advantage in image editing. Unlike raster-scan models, which often fail when the mask is not at the end of the sequence, STAR maintained high visual fidelity across various masking ratios and configurations.
- Efficiency: The method integrates seamlessly with existing Transformer blocks, requiring no significant architectural changes and maintaining training efficiency comparable to standard AR models.
Conclusion
STAR represents a significant step forward for autoregressive visual generation. By replacing rigid raster-scan orders with structured, randomized spanning trees, it combines the high-quality generation of AR models with the flexibility typically associated with bidirectional or diffusion models. This "middle ground" approach respects the 2D nature of images while enabling powerful new capabilities for interactive image editing.
Summary updated