{"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/in-context-autoencoder-for-context","title":"In-context Autoencoder for Context Compression in a Large Language Model","arxiv_id":"2307.06945","date":"2023-07-13","proceeding":null,"authors":["Tao Ge","Jing Hu","Lei Wang","Xun Wang","Si-Qing Chen","Furu Wei"],"abstract":"We propose the In-context Autoencoder (ICAE), leveraging the power of a large language model (LLM) to compress a long context into short compact memory slots that can be directly conditioned on by the LLM for various purposes. ICAE is first pretrained using both autoencoding and language modeling objectives on massive text data, enabling it to generate memory slots that accurately and comprehensively represent the original context. Then, it is fine-tuned on instruction data for producing desirable responses to various prompts. Experiments demonstrate that our lightweight ICAE, introducing about 1% additional parameters, effectively achieves $4\\times$ context compression based on Llama, offering advantages in both improved latency and GPU memory cost during inference, and showing an interesting insight in memorization as well as potential for scalability. These promising results imply a novel perspective on the connection between working memory in cognitive science and representation learning in LLMs, revealing ICAE's significant implications in addressing the long context problem and suggesting further research in LLM context management. Our data, code and models are available at https://github.com/getao/icae.","url_abs":"https://arxiv.org/abs/2307.06945v4","url_pdf":"https://arxiv.org/pdf/2307.06945v4.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":"in-context-autoencoder-for-context","repo_url":"https://github.com/getao/icae","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"CC0-1.0"}},{"paper_slug":"in-context-autoencoder-for-context","repo_url":"https://github.com/srgrace/contextual-compression","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":null,"task_name":"GPU"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"large-language-model","task_name":"Large Language Model"},{"task_slug":"management","task_name":"Management"},{"task_slug":"memorization","task_name":"Memorization"},{"task_slug":"representation-learning","task_name":"Representation Learning"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2307.06945","atlas_url":"https://app.syntology.ai/?focus=2307.06945","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2307.06945"}},"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/getao/icae","reach":{"status":"ok","spdx":"CC0-1.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/srgrace/contextual-compression","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran_fixture":2,"ran":3,"ran_draft_wrong":1},"by_repo_kind":{"official":{"samples":6,"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":0,"samples":[{"code_sha256_prefix":"30d7eec482ebf6b1","entry":"repeat_kv","repo":"getao/icae","repo_kind":"official","path":"code/icae_v1/base/modeling_llama_icae.py","file_url":"https://github.com/getao/icae/blob/HEAD/code/icae_v1/base/modeling_llama_icae.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":2,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"30d7eec482ebf6b1"}},{"code_sha256_prefix":"f725bc2d76076485","entry":"apply_rotary_pos_emb","repo":"getao/icae","repo_kind":"official","path":"code/icae_v1/base/modeling_llama_icae.py","file_url":"https://github.com/getao/icae/blob/HEAD/code/icae_v1/base/modeling_llama_icae.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f725bc2d76076485"}},{"code_sha256_prefix":"5d4c3fbe9286bb9a","entry":"instruct_ft_tokenize_function","repo":"getao/icae","repo_kind":"official","path":"code/icae_v2/training_utils.py","file_url":"https://github.com/getao/icae/blob/HEAD/code/icae_v2/training_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5d4c3fbe9286bb9a"}},{"code_sha256_prefix":"620be8b457171d50","entry":"pretrain_tokenize_function","repo":"getao/icae","repo_kind":"official","path":"code/icae_v2/training_utils.py","file_url":"https://github.com/getao/icae/blob/HEAD/code/icae_v2/training_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"620be8b457171d50"}},{"code_sha256_prefix":"b99eea6376d1e212","entry":"rotate_half","repo":"getao/icae","repo_kind":"official","path":"code/icae_v1/base/modeling_llama_icae.py","file_url":"https://github.com/getao/icae/blob/HEAD/code/icae_v1/base/modeling_llama_icae.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b99eea6376d1e212"}},{"code_sha256_prefix":"1e1210d72545f26a","entry":"text_extraction","repo":"getao/icae","repo_kind":"official","path":"code/icae_v2/training_utils.py","file_url":"https://github.com/getao/icae/blob/HEAD/code/icae_v2/training_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"1e1210d72545f26a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}