{"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/leave-no-context-behind-efficient-infinite","title":"Leave No Context Behind: Efficient Infinite Context Transformers with Infini-attention","arxiv_id":"2404.07143","date":"2024-04-10","proceeding":null,"authors":["Tsendsuren Munkhdalai","Manaal Faruqui","Siddharth Gopal"],"abstract":"This work introduces an efficient method to scale Transformer-based Large Language Models (LLMs) to infinitely long inputs with bounded memory and computation. A key component in our proposed approach is a new attention technique dubbed Infini-attention. The Infini-attention incorporates a compressive memory into the vanilla attention mechanism and builds in both masked local attention and long-term linear attention mechanisms in a single Transformer block. We demonstrate the effectiveness of our approach on long-context language modeling benchmarks, 1M sequence length passkey context block retrieval and 500K length book summarization tasks with 1B and 8B LLMs. Our approach introduces minimal bounded memory parameters and enables fast streaming inference for LLMs.","url_abs":"https://arxiv.org/abs/2404.07143v2","url_pdf":"https://arxiv.org/pdf/2404.07143v2.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":"leave-no-context-behind-efficient-infinite","repo_url":"https://github.com/ArionDas/InfiniGPT","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"leave-no-context-behind-efficient-infinite","repo_url":"https://github.com/Beomi/InfiniTransformer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"leave-no-context-behind-efficient-infinite","repo_url":"https://github.com/jlamprou/Infini-Attention","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"leave-no-context-behind-efficient-infinite","repo_url":"https://github.com/lucidrains/infini-transformer-pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"leave-no-context-behind-efficient-infinite","repo_url":"https://github.com/mustafaaljadery/gemma-2b-10m","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":null,"task_name":"Book summarization"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"retrieval","task_name":"Retrieval"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2404.07143","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2404.07143"}},"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/lucidrains/infini-transformer-pytorch","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Beomi/InfiniTransformer","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mustafaaljadery/gemma-2b-10m","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jlamprou/Infini-Attention","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ArionDas/InfiniGPT","reach":null}],"summary":{"ran_fixture":4,"ran":5,"ran_draft_wrong":4,"ran_violates":2,"unverified":1},"by_repo_kind":{"listed":{"samples":12,"ran":11,"repositories":4}},"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":6,"samples":[{"code_sha256_prefix":"30d7eec482ebf6b1","entry":"repeat_kv","repo":"Beomi/InfiniTransformer","repo_kind":"listed","path":"modeling_gemma.py","file_url":"https://github.com/Beomi/InfiniTransformer/blob/HEAD/modeling_gemma.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":2,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"30d7eec482ebf6b1"}},{"code_sha256_prefix":"3c76e52815c5401d","entry":"repeat_kv","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_fixture","verification_level":2,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"3c76e52815c5401d"}},{"code_sha256_prefix":"e3e97263839cab4f","entry":"CompressiveMemory","repo":"ArionDas/InfiniGPT","repo_kind":"listed","path":"src/infini_transformer.py","file_url":"https://github.com/ArionDas/InfiniGPT/blob/HEAD/src/infini_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e3e97263839cab4f"}},{"code_sha256_prefix":"6190672bce0e4f2a","entry":"FeedForward","repo":"ArionDas/InfiniGPT","repo_kind":"listed","path":"src/infini_transformer.py","file_url":"https://github.com/ArionDas/InfiniGPT/blob/HEAD/src/infini_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6190672bce0e4f2a"}},{"code_sha256_prefix":"9fa049dcf996a066","entry":"GELU","repo":"ArionDas/InfiniGPT","repo_kind":"listed","path":"src/infini_transformer.py","file_url":"https://github.com/ArionDas/InfiniGPT/blob/HEAD/src/infini_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9fa049dcf996a066"}},{"code_sha256_prefix":"a4a13041dd37b6f2","entry":"PositionEmbeddings","repo":"ArionDas/InfiniGPT","repo_kind":"listed","path":"src/infini_transformer.py","file_url":"https://github.com/ArionDas/InfiniGPT/blob/HEAD/src/infini_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a4a13041dd37b6f2"}},{"code_sha256_prefix":"bac65c3dafaec040","entry":"apply_rotary_pos_emb","repo":"Beomi/InfiniTransformer","repo_kind":"listed","path":"modeling_gemma.py","file_url":"https://github.com/Beomi/InfiniTransformer/blob/HEAD/modeling_gemma.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bac65c3dafaec040"}},{"code_sha256_prefix":"0fe82a947dc39b42","entry":"apply_rotary_pos_emb","repo":"jlamprou/Infini-Attention","repo_kind":"listed","path":"infiniAttention.py","file_url":"https://github.com/jlamprou/Infini-Attention/blob/HEAD/infiniAttention.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0fe82a947dc39b42"}},{"code_sha256_prefix":"99b3563ebc6734ad","entry":"default","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"99b3563ebc6734ad"}},{"code_sha256_prefix":"b7c3487f192e31b7","entry":"exists","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"b7c3487f192e31b7"}},{"code_sha256_prefix":"943aef7d2bbc32d0","entry":"generate_prompt_landmark","repo":"jlamprou/Infini-Attention","repo_kind":"listed","path":"passkey_retrieval.py","file_url":"https://github.com/jlamprou/Infini-Attention/blob/HEAD/passkey_retrieval.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"943aef7d2bbc32d0"}},{"code_sha256_prefix":"a01911ff65691be7","entry":"get_mem_space","repo":"Beomi/InfiniTransformer","repo_kind":"listed","path":"gpu_mem_track.py","file_url":"https://github.com/Beomi/InfiniTransformer/blob/HEAD/gpu_mem_track.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a01911ff65691be7"}},{"code_sha256_prefix":"8d5b5a4c9c8d7db0","entry":"retrieve_from_kv_memories","repo":"lucidrains/infini-transformer-pytorch","repo_kind":"listed","path":"infini_transformer_pytorch/infini_transformer.py","file_url":"https://github.com/lucidrains/infini-transformer-pytorch/blob/HEAD/infini_transformer_pytorch/infini_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8d5b5a4c9c8d7db0"}},{"code_sha256_prefix":"b99eea6376d1e212","entry":"rotate_half","repo":"Beomi/InfiniTransformer","repo_kind":"listed","path":"modeling_gemma.py","file_url":"https://github.com/Beomi/InfiniTransformer/blob/HEAD/modeling_gemma.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b99eea6376d1e212"}},{"code_sha256_prefix":"e03d53ba9d4f9ae5","entry":"rotate_half","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"e03d53ba9d4f9ae5"}},{"code_sha256_prefix":"e59592481467fbed","entry":"InfiniTransformer","repo":"ArionDas/InfiniGPT","repo_kind":"listed","path":"src/infini_transformer.py","file_url":"https://github.com/ArionDas/InfiniGPT/blob/HEAD/src/infini_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e59592481467fbed"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}