Papers › Adapting LLaMA Decoder to Vision Transformer

Adapting LLaMA Decoder to Vision Transformer

10 Apr 2024arXiv:2404.06773archive 2025-07-28

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

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 ∼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.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2404.06773")

Code

Syntology Ran 9 of 13 code samples harvested from 1 repository linked to this paper; 4 have no recorded run. Of those that ran: 1 ran · honoured contract; 2 ran · violated contract; 1 ran · fixture could not drive it; 5 ran with no contract checked.

By repository: official repository: 13 samples from 1 repository, 9 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

techmonsterwang/illama officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

13 samples harvested; 9 ran; 1 honoured the contract we drafted; 4 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
2ran · violated contract
1ran · fixture could not drive it
5ran
4unverified

Licence: 13 of the 13 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from techmonsterwang/illama. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

apply_rotary_emb techmonsterwang/illama/models/illama.py official repository ran no licence file found · pointer only · 5412a244b5b49ca7 · report
build_transform techmonsterwang/illama/datasets.py official repository ran no licence file found · pointer only · 6a0317bfd6be9557 · report
drop_scheduler techmonsterwang/illama/drop_scheduler.py official repository ran · honoured contract no licence file found · pointer only · 5e1695210460b9d6 · report
mask_scheduler techmonsterwang/illama/mask_scheduler.py official repository ran no licence file found · pointer only · d26194ed53c706da · report
precompute_freqs_cis techmonsterwang/illama/models/illama.py official repository ran · violated contract no licence file found · pointer only · 14a84c2cbfebc413 · report
reg_scheduler techmonsterwang/illama/utils.py official repository ran no licence file found · pointer only · 1d7e5aed37e593e4 · report
reshape_for_broadcast techmonsterwang/illama/models/illama.py official repository ran · fixture could not drive it fingerprinted no licence file found · pointer only · 70bf6ebaafd266c4 · report
str2bool techmonsterwang/illama/main_soft.py official repository ran · violated contract no licence file found · pointer only · ecf287c12bb06741 · report
uniform_element_selection techmonsterwang/illama/llama2/weight_selection.py official repository ran no licence file found · pointer only · 7d05bb3d813045ba · report
build_dataset techmonsterwang/illama/datasets.py official repository unverified no licence file found · pointer only · 9f7ea37592e1e7c7 · report
cosine_scheduler techmonsterwang/illama/utils.py official repository unverified no licence file found · pointer only · b700fb0a3496b255 · report
get_num_layer_for_convnext techmonsterwang/illama/optim_factory.py official repository unverified no licence file found · pointer only · 199223de2f9704cf · report
get_parameter_groups techmonsterwang/illama/optim_factory.py official repository unverified no licence file found · pointer only · 0ef0019514eaaa09 · report

Tasks

Computational EfficiencyDecoderQuantizationTransfer Learning

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

ALIGNLLaMA

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections