{"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/attend-first-consolidate-later-on-the","title":"Attend First, Consolidate Later: On the Importance of Attention in Different LLM Layers","arxiv_id":"2409.03621","date":"2024-09-05","proceeding":null,"authors":["Amit Ben-Artzy","Roy Schwartz"],"abstract":"In decoder-based LLMs, the representation of a given layer serves two purposes: as input to the next layer during the computation of the current token; and as input to the attention mechanism of future tokens. In this work, we show that the importance of the latter role might be overestimated. To show that, we start by manipulating the representations of previous tokens; e.g. by replacing the hidden states at some layer k with random vectors. Our experimenting with four LLMs and four tasks show that this operation often leads to small to negligible drop in performance. Importantly, this happens if the manipulation occurs in the top part of the model-k is in the final 30-50% of the layers. In contrast, doing the same manipulation in earlier layers might lead to chance level performance. We continue by switching the hidden state of certain tokens with hidden states of other tokens from another prompt; e.g., replacing the word \"Italy\" with \"France\" in \"What is the capital of Italy?\". We find that when applying this switch in the top 1/3 of the model, the model ignores it (answering \"Rome\"). However if we apply it before, the model conforms to the switch (\"Paris\"). Our results hint at a two stage process in transformer-based LLMs: the first part gathers input from previous tokens, while the second mainly processes that information internally.","url_abs":"https://arxiv.org/abs/2409.03621v2","url_pdf":"https://arxiv.org/pdf/2409.03621v2.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":"attend-first-consolidate-later-on-the","repo_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"hint","method_name":"HINT"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2409.03621","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2409.03621"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later","reach":{"status":"ok"}}],"summary":{"ran":6,"unverified":9},"by_repo_kind":{"official":{"samples":15,"ran":6,"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":15,"samples":[{"code_sha256_prefix":"c77ced1c95818050","entry":"llama_manipulate_casualLM_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/llama_manipulate.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/llama_manipulate.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c77ced1c95818050"}},{"code_sha256_prefix":"b06edc31230f8c63","entry":"llama_skip_casualLM_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/llama_skip.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/llama_skip.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b06edc31230f8c63"}},{"code_sha256_prefix":"faf27efb24417c61","entry":"llama_skip_decoder_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/llama_skip.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/llama_skip.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"faf27efb24417c61"}},{"code_sha256_prefix":"38da980c937dd416","entry":"llama_skip_model_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/llama_skip.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/llama_skip.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"38da980c937dd416"}},{"code_sha256_prefix":"1d312572a2b534cf","entry":"mistral_skip_decoder_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/mistral_skip.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/mistral_skip.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1d312572a2b534cf"}},{"code_sha256_prefix":"1d96b3096bdd4609","entry":"mistral_skip_model_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/mistral_skip.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/mistral_skip.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1d96b3096bdd4609"}},{"code_sha256_prefix":"bca7d43f1dfa3090","entry":"add_argument","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/convert_models.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/convert_models.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"bca7d43f1dfa3090"}},{"code_sha256_prefix":"afad9c2c0ce6ae44","entry":"enable_manipulated_gen","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/convert_models.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/convert_models.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"afad9c2c0ce6ae44"}},{"code_sha256_prefix":"505d78eeb35e450d","entry":"enable_skip_attention","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/convert_models.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/convert_models.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"505d78eeb35e450d"}},{"code_sha256_prefix":"ef50b4a8b49827d4","entry":"get_injection_data","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"information_injection_demo.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/information_injection_demo.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ef50b4a8b49827d4"}},{"code_sha256_prefix":"25fec94220fb4524","entry":"get_next_token","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"information_injection_demo.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/information_injection_demo.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"25fec94220fb4524"}},{"code_sha256_prefix":"de3c8559ca6e9a7d","entry":"llama_manipulate_model_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/llama_manipulate.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/llama_manipulate.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"de3c8559ca6e9a7d"}},{"code_sha256_prefix":"1572d250024e9631","entry":"mistral_model_causalLM_manipulated_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/mistral_manipulated.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/mistral_manipulated.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1572d250024e9631"}},{"code_sha256_prefix":"4fec8ca69367d057","entry":"mistral_model_manipulated_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/mistral_manipulated.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/mistral_manipulated.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4fec8ca69367d057"}},{"code_sha256_prefix":"3a66a57c55207487","entry":"mistral_skip_causalLM_forward","repo":"schwartz-lab-NLP/Attend-First-Consolidate-Later","repo_kind":"official","path":"convert_models/mistral_skip.py","file_url":"https://github.com/schwartz-lab-NLP/Attend-First-Consolidate-Later/blob/HEAD/convert_models/mistral_skip.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3a66a57c55207487"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}