arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2404.06773cs.CV
收藏

将LLaMA解码器适配到视觉Transformer

Adapting LLaMA Decoder to Vision Transformer

The University of HongKong(香港大学);Shanghai AI Laboratory(上海人工智能实验室);Tsinghua Shenzhen International Graduate School(清华大学深圳国际研究生院)

Jiahao Wang, Wenqi Shao, Mengzhao Chen, Chengyue Wu, Yong Liu, Taiqiang Wu, Kaipeng Zhang, Songyang Zhang, Kai Chen, Ping Luo

AI总结:

本研究将LLaMA解码器架构适配到视觉Transformer,提出iLLaMA模型,通过后序列类标记和软掩码策略解决注意力崩溃问题,以少量参数达到高精度图像分类性能。

摘要:

本研究探讨了原本为大型语言模型(LLMs)设计的仅解码器Transformer(如LLaMA)能否适配到计算机视觉领域。我们首先逐步“LLaMA化”一个标准ViT,以使其与LLaMA的架构对齐,并发现直接将因果掩码应用于自注意力会引发注意力崩溃问题,导致网络训练失败。我们建议采用后序列类标记技术,将类标记重新定位到图像标记之后,以克服这一挑战,使因果自注意力能够高效捕获整个图像的信息。此外,我们开发了一种软掩码策略,在训练初期逐步引入因果掩码到自注意力中,以促进优化行为。定制模型被称为图像LLaMA(iLLaMA),其架构与LLaMA相似,并支持直接监督学习。其因果自注意力通过提升注意力图秩来提高计算效率并学习复杂表示。iLLaMA的性能可与仅编码器的同类模型相媲美,仅用5.7M参数即可达到75.1%的ImageNet top-1准确率。将模型扩展到约310M参数并在ImageNet-21K上预训练,可进一步提高准确率至86.0%。大量实验证明了iLLaMA的可靠特性:形状-纹理偏差、校准、量化兼容性、ADE20K分割和CIFAR迁移学习。我们希望这项研究能在LLM浪潮中为视觉架构带来新的视角,并激发统一多模态模型的发展。预训练模型和代码可在https://github.com/techmonsterwang/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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑