TL;DR
NARAIM introduces a native aspect ratio pre-training method for autoregressive vision transformers, eliminating the spatial distortions caused by standard square cropping. By preserving original image proportions during next-patch prediction, it boosts downstream classification accuracy by over 2% without increasing computational costs.
What Problem Does This Paper Address?
In computer vision, the standard practice for training Vision Transformers (ViTs) involves forcing images into a uniform square box (typically 224x224 pixels) using random resized cropping. While this simplifies batching and computation, it stretches, squishes, or cuts out critical visual structures.
For autoregressive models trained on a "next-patch prediction" objective (similar to how large language models predict the next word), these geometric distortions are particularly harmful. Squishing a wide landscape or a tall skyscraper into a square disrupts the natural spatial patterns and textures that the model is trying to learn to predict. The authors of NARAIM tackle this gap by asking: can we train autoregressive vision models on images in their native aspect ratios to preserve spatial context?
Methods
NARAIM modifies the Autoregressive Image Model (AIM) framework to handle images of arbitrary shapes through several key innovations:
- Native Aspect Ratio Resize: Instead of resizing an image to a fixed $224 \times 224$ square, NARAIM rescales the image so that its total pixel area remains roughly equivalent ($\approx 224^2$ or 50,176 pixels), keeping the original aspect ratio intact. The image is then cropped slightly so its dimensions are multiples of the patch size ($14 \times 14$) and tokenized into a variable grid of up to 256 patches. Padding tokens are appended to handle slight variations in sequence length and are masked out during loss calculation.
- Fractional Positional Embeddings: Standard absolute positional embeddings rely on fixed row and column indices, which fail when image layouts change dynamically. NARAIM adopts fractional positional embeddings, where patch coordinates are normalized by the total number of patches along that axis (i.e., $\text{index} / \text{total patches}$). This allows the model to generalize seamlessly to out-of-distribution aspect ratios.
- Aspect-Preserving Augmentation: To maintain regularization benefits without introducing distortion, the authors adapt the standard random crop augmentation to ensure the cropped region retains the image's original aspect ratio.
- Prefix Causal Attention: During pre-training, a random prefix of patches is allowed to use bidirectional attention (where patches can look both forward and backward). This prevents the model from relying solely on causal, left-to-right context, making it much easier to adapt to non-causal downstream tasks like classification.
Datasets
The model is pre-trained and evaluated using ImageNet-1k, a standard benchmark containing over 1.2 million images across 1,000 classes. Downstream performance is measured by freezing the pre-trained ViT backbone and training an attentive classification probe on top.
Key Insights and Ideas
- Distortion Hinders Generative Learning: Forcing non-square images into squares destroys the spatial continuity that autoregressive next-token prediction relies on. Preserving the native aspect ratio keeps the visual structures intact.
- Fractional Embeddings Provide Edge Awareness: By using proportions instead of absolute indices, the model inherently understands when a patch is approaching the boundary of an image (as the fraction approaches 1), regardless of whether the image is wide or tall.
- Normalization Prevents Global Shortcuts: The authors found that patch-wise normalization is critical. Without it, the autoregressive model focuses too heavily on low-frequency global color patterns. This leads the downstream classifier to develop shortcuts (e.g., predicting "boat" simply because it encounters a large patch of blue sky), which degrades accuracy.
Key Results
The authors evaluated NARAIM against the standard square-based AIM using a scaled-down ViT-B/14 backbone (~86M parameters):
- Accuracy Boost: The baseline NARAIM model achieves a validation accuracy of 55.4% compared to AIM's 54.7%.
- Synergistic Enhancements: Incorporating both fractional positional embeddings and aspect-preserving random crops pushes NARAIM’s performance to 56.8%, outperforming the standard AIM baseline by more than two percentage points.
- Robustness to Extreme Shapes: When grouping validation images by their aspect ratios, NARAIM demonstrates a significant performance advantage on highly non-square images (very tall or very wide aspect ratios), where the standard square-trained AIM model's accuracy drops sharply.
Limitations and Future Work
- Compute and Scale Constraints: Due to hardware limitations, the authors trained a smaller backbone (~86M parameters) rather than the 600M+ parameter models featured in the original AIM paper. They note that verifying whether these aspect-ratio benefits hold true under massive scaling laws remains future work.
- Downstream Task Variety: The evaluation in this paper is limited to image classification. Future work will need to explore how native aspect ratio pre-training impacts dense prediction tasks like object detection, semantic segmentation, or pure image generation.
Summary updated