ChatPaper.aiChatPaper

Het aanpassen van de LLaMA-decoder aan de Vision Transformer

Adapting LLaMA Decoder to Vision Transformer

April 10, 2024
Auteurs: Jiahao Wang, Wenqi Shao, Mengzhao Chen, Chengyue Wu, Yong Liu, Kaipeng Zhang, Songyang Zhang, Kai Chen, Ping Luo
cs.AI

Samenvatting

Dit onderzoek onderzoekt of decoder-only Transformers zoals LLaMA, die oorspronkelijk zijn ontworpen voor grote taalmodelen (LLMs), kunnen worden aangepast voor het gebied van computervisie. We "LLaMAficeer" eerst stap voor stap een standaard ViT om deze af te stemmen op de architectuur van LLaMA, en ontdekken dat het direct toepassen van een casual masker op de self-attention een aandachtscollaps veroorzaakt, wat resulteert in het falen van het netwerktrainingsproces. We stellen voor om het class-token achter de beeldtokens te plaatsen met een post-sequence class-token techniek om deze uitdaging te overwinnen, waardoor causale self-attention efficiënt de informatie van het hele beeld kan vastleggen. Daarnaast ontwikkelen we een soft mask-strategie die geleidelijk een casual masker introduceert in de self-attention aan het begin van de training om het optimalisatiegedrag te vergemakkelijken. Het aangepaste model, genaamd image LLaMA (iLLaMA), lijkt qua architectuur op LLaMA en maakt directe supervised learning mogelijk. De causale self-attention verhoogt de rekenkundige efficiëntie en leert complexe representaties door de rang van de aandachtmappen te verhogen. iLLaMA kan de prestaties van zijn encoder-only tegenhangers evenaren, met een top-1 nauwkeurigheid van 75,1% op ImageNet met slechts 5,7M parameters. Het opschalen van het model naar ~310M en pre-trainen op ImageNet-21K verhoogt de nauwkeurigheid verder naar 86,0%. Uitgebreide experimenten tonen de betrouwbare eigenschappen van iLLaMA aan: calibratie, vorm-textuur bias, compatibiliteit met kwantisatie, ADE20K segmentatie en CIFAR transfer learning. We hopen dat onze studie nieuwe inzichten kan aanwakkeren voor het ontwerp van visuele modellen in de golf van LLMs. Pre-getrainde modellen en codes zijn hier beschikbaar.
English
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 casual 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 casual 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 ~310M and pre-training on ImageNet-21K further enhances the accuracy to 86.0%. Extensive experiments demonstrate iLLaMA's reliable properties: calibration, shape-texture bias, quantization compatibility, ADE20K segmentation and CIFAR transfer learning. We hope our study can kindle fresh views to visual model design in the wave of LLMs. Pre-trained models and codes are available here.
PDF181December 15, 2024