{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/on-the-surprising-effectiveness-of-attention","title":"On the Surprising Effectiveness of Attention Transfer for Vision Transformers","arxiv_id":"2411.09702","date":"2024-11-14","proceeding":null,"authors":["Alexander C. Li","Yuandong Tian","Beidi Chen","Deepak Pathak","Xinlei Chen"],"abstract":"Conventional wisdom suggests that pre-training Vision Transformers (ViT) improves downstream performance by learning useful representations. Is this actually true? We investigate this question and find that the features and representations learned during pre-training are not essential. Surprisingly, using only the attention patterns from pre-training (i.e., guiding how information flows between tokens) is sufficient for models to learn high quality features from scratch and achieve comparable downstream performance. We show this by introducing a simple method called attention transfer, where only the attention patterns from a pre-trained teacher ViT are transferred to a student, either by copying or distilling the attention maps. Since attention transfer lets the student learn its own features, ensembling it with a fine-tuned teacher also further improves accuracy on ImageNet. We systematically study various aspects of our findings on the sufficiency of attention maps, including distribution shift settings where they underperform fine-tuning. We hope our exploration provides a better understanding of what pre-training accomplishes and leads to a useful alternative to the standard practice of fine-tuning","url_abs":"https://arxiv.org/abs/2411.09702v1","url_pdf":"https://arxiv.org/pdf/2411.09702v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"on-the-surprising-effectiveness-of-attention","repo_url":"https://github.com/alexlioralexli/attention-transfer","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2411.09702","atlas_url":"https://app.syntology.ai/?focus=2411.09702","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2411.09702"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/alexlioralexli/attention-transfer","reach":null}],"summary":{"ran":2,"unverified":2},"by_repo_kind":{"official":{"samples":4,"ran":2,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":4,"samples":[{"code_sha256_prefix":"66fae84cdc8d8912","entry":"Attention","repo":"alexlioralexli/attention-transfer","repo_kind":"official","path":"models_dual_vit.py","file_url":"https://github.com/alexlioralexli/attention-transfer/blob/HEAD/models_dual_vit.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"66fae84cdc8d8912"}},{"code_sha256_prefix":"3554200165b73275","entry":"Block","repo":"alexlioralexli/attention-transfer","repo_kind":"official","path":"models_dual_vit.py","file_url":"https://github.com/alexlioralexli/attention-transfer/blob/HEAD/models_dual_vit.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"3554200165b73275"}},{"code_sha256_prefix":"cbd765d78399d806","entry":"DualVisionTransformer","repo":"alexlioralexli/attention-transfer","repo_kind":"official","path":"models_dual_vit.py","file_url":"https://github.com/alexlioralexli/attention-transfer/blob/HEAD/models_dual_vit.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"cbd765d78399d806"}},{"code_sha256_prefix":"02bbece47468309a","entry":"VisionTransformer","repo":"alexlioralexli/attention-transfer","repo_kind":"official","path":"models_dual_vit.py","file_url":"https://github.com/alexlioralexli/attention-transfer/blob/HEAD/models_dual_vit.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"02bbece47468309a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}