Abstract
The Vision Transformer (ViT) has traditionally relied on encoder-only architectures, diverging from the decoder-only trend dominant in Large Language Models (LLMs) like LLaMA. This work introduces iLLaMA, a vision model that successfully adapts the decoder-only architecture for computer vision. By utilizing a "post-sequence" class token and a "soft mask" training strategy, iLLaMA overcomes the limitations of causal masking in vision tasks, matching or exceeding the performance of standard encoder-based models while offering superior calibration and representation complexity.
Bridging the Modality Gap
Since its inception, the Vision Transformer (ViT) has largely mirrored the encoder-only design of early NLP models like BERT. In contrast, modern NLP has shifted almost exclusively toward decoder-only architectures. This architectural divergence creates a "modality gap" that complicates the development of unified multimodal systems.
The primary obstacle in applying decoder-only architectures to vision is the causal mask. In a standard decoder, tokens can only attend to preceding tokens. For images, where global context is essential, this often leads to "attention collapse." Specifically, a class token placed at the start of a sequence remains blind to the subsequent image patches, failing to aggregate global information.
The iLLaMA Architecture
The researchers developed iLLaMA by systematically integrating LLaMA's core components into the ViT framework:
- Component Swapping: Standard MLPs were replaced with SwiGLU (Gated Linear Units), Layer Normalization with RMSNorm, and absolute positional embeddings with RoPE (Rotary Positional Embeddings).
- Isotropic Design: iLLaMA maintains a constant resolution and channel count across layers, preserving the simplicity of the LLaMA architecture.
Solving Attention Collapse
To enable effective learning under a causal constraint, two key innovations were introduced:
Post-Sequence Class Token (PS [cls])
By moving the class token from the beginning to the end of the sequence, the model ensures that the token can attend to every image patch. This simple shift restores the global context necessary for discriminative tasks.
Soft Mask Strategy
Strict causal masking can hinder optimization during the early stages of training. The "soft mask" strategy begins with bi-directional attention and gradually transitions to a strict causal mask. This allows the model to establish initial global relationships before enforcing the causal constraint.
Key Insights and Empirical Results
iLLaMA demonstrates that decoder-only architectures are not only viable but offer distinct advantages for vision:
- Higher Representation Rank: Causal self-attention produces higher-rank attention maps compared to bi-directional attention, suggesting that the causal constraint forces the model to learn more complex and less redundant features.
- Human-like Bias: iLLaMA exhibits a higher shape-texture bias than standard ViTs, relying more on object shapes than local textures, which aligns more closely with human visual perception.
- Improved Calibration: iLLaMA exhibits lower Expected Calibration Error (ECE) than its encoder-only counterparts, meaning its confidence scores are more representative of actual accuracy.
- Competitive Performance: The iLLaMA-T (Tiny) variant achieves 75.1% top-1 accuracy on ImageNet with just 5.7M parameters. The Large variant (iLLaMA-L) reaches 86.0% accuracy when pre-trained on ImageNet-21K, outperforming the original ViT-L.
- Robustness: The model shows strong transferability on tasks like semantic segmentation (ADE20K) and maintains performance under 8-bit quantization.
Conclusion
iLLaMA proves that the decoder-only architecture, optimized for text, is equally capable of processing visual data. By unifying the architectural backbone across modalities, this work paves the way for more efficient and cohesive multimodal models. Future research will explore the potential of iLLaMA in generative vision tasks, potentially mirroring the success of LLMs in text generation.
Summary updated