Adapting LLaMA Decoder to Vision Transformer
作者: Jiahao Wang, Wenqi Shao, Mengzhao Chen, Chengyue Wu, Yong Liu, Taiqiang Wu, Kaipeng Zhang, Songyang Zhang, Kai Chen, Ping Luo
分类: cs.CV
发布日期: 2024-04-10 (更新: 2024-05-27)
备注: 23 pages, 11 figures
🔗 代码/项目: GITHUB
💡 一句话要点
提出iLLaMA以解决视觉Transformer适应性问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 视觉Transformer 仅解码模型 因果掩码 多模态模型 图像分类 深度学习 模型优化
📋 核心要点
- 现有的仅解码Transformer在计算机视觉任务中面临注意力崩溃的问题,导致训练失败。
- 论文提出通过重新定位类标记和逐步引入因果掩码的策略,解决了注意力崩溃的问题。
- iLLaMA在ImageNet上表现出色,75.1%的准确率和310M参数的扩展后达到了86.0%的准确率,显示出良好的性能和可靠性。
📝 摘要(中文)
本研究探讨了如何将仅解码的Transformer(如LLaMA)适应于计算机视觉领域。我们逐步将标准ViT与LLaMA架构对齐,发现直接应用因果掩码会导致注意力崩溃,影响网络训练。为此,我们提出将类标记重新定位到图像标记之后,并采用逐步引入因果掩码的策略,以提高优化效果。最终,iLLaMA在仅有5.7M参数的情况下,达到了75.1%的ImageNet top-1准确率,经过扩展和预训练后,准确率提升至86.0%。
🔬 方法详解
问题定义:本研究旨在解决仅解码Transformer(如LLaMA)在计算机视觉任务中应用时遇到的注意力崩溃问题。现有方法在直接应用因果掩码时,导致网络训练失败,无法有效捕捉图像信息。
核心思路:论文的核心思路是通过将类标记重新定位到图像标记之后,结合逐步引入因果掩码的策略,来优化自注意力机制的表现,从而提高模型的训练效果和性能。
技术框架:整体架构包括标准ViT与LLaMA的对齐,采用后序列类标记技术和软掩码策略。模型分为多个阶段,首先进行结构调整,然后逐步引入因果掩码以优化训练。
关键创新:最重要的技术创新在于提出了后序列类标记和软掩码策略,这与现有方法的直接因果掩码应用形成了本质区别,显著提升了模型的训练稳定性和性能。
关键设计:在参数设置上,iLLaMA使用了5.7M参数,经过扩展至310M并在ImageNet-21K上预训练,采用了特定的损失函数和网络结构设计,以确保模型的高效学习和复杂表示能力。
🖼️ 关键图片
📊 实验亮点
iLLaMA在ImageNet上达到了75.1%的top-1准确率,参数仅为5.7M。经过扩展至约310M并在ImageNet-21K上预训练后,准确率提升至86.0%。实验结果显示iLLaMA在形状-纹理偏差、校准、量化兼容性等方面表现出色,验证了其可靠性。
🎯 应用场景
该研究的潜在应用领域包括计算机视觉任务,如图像分类、目标检测和图像分割等。iLLaMA的设计不仅提升了视觉模型的性能,还有助于推动多模态模型的发展,促进语言与视觉的融合,为未来的智能系统提供更强的支持。
📄 摘要(原文)
This work examines whether decoder-only Transformers such as LLaMA, which were originally designed for large language models (LLMs), can be adapted to the computer vision field. We first "LLaMAfy" a standard ViT step-by-step to align with LLaMA's architecture, and find that directly applying a causal mask to the self-attention brings an attention collapse issue, resulting in the failure to the network training. We suggest to reposition the class token behind the image tokens with a post-sequence class token technique to overcome this challenge, enabling causal self-attention to efficiently capture the entire image's information. Additionally, we develop a soft mask strategy that gradually introduces a causal mask to the self-attention at the onset of training to facilitate the optimization behavior. The tailored model, dubbed as image LLaMA (iLLaMA), is akin to LLaMA in architecture and enables direct supervised learning. Its causal self-attention boosts computational efficiency and learns complex representation by elevating attention map ranks. iLLaMA rivals the performance with its encoder-only counterparts, achieving 75.1% ImageNet top-1 accuracy with only 5.7M parameters. Scaling the model to $\sim$310M and pre-training on ImageNet-21K further enhances the accuracy to 86.0%. Extensive experiments demonstrate iLLaMA's reliable properties: shape-texture bias, calibration, quantization compatibility, ADE20K segmentation and CIFAR transfer learning. We hope our study can kindle fresh views to visual architectures in the wave of LLMs and inspire the development of unified multimodal models. Pre-trained models and codes are available https://github.com/techmonsterwang/iLLaMA.