{"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/online-adaptation-of-language-models-with-a","title":"Online Adaptation of Language Models with a Memory of Amortized Contexts","arxiv_id":"2403.04317","date":"2024-03-07","proceeding":null,"authors":["Jihoon Tack","Jaehyung Kim","Eric Mitchell","Jinwoo Shin","Yee Whye Teh","Jonathan Richard Schwarz"],"abstract":"Due to the rapid generation and dissemination of information, large language models (LLMs) quickly run out of date despite enormous development costs. To address the crucial need to keep models updated, online learning has emerged as a critical tool when utilizing LLMs for real-world applications. However, given the ever-expanding corpus of unseen documents and the large parameter space of modern LLMs, efficient adaptation is essential. To address these challenges, we propose Memory of Amortized Contexts (MAC), an efficient and effective online adaptation framework for LLMs with strong knowledge retention. We propose a feature extraction and memory-augmentation approach to compress and extract information from new documents into compact modulations stored in a memory bank. When answering questions, our model attends to and extracts relevant knowledge from this memory bank. To learn informative modulations in an efficient manner, we utilize amortization-based meta-learning, which substitutes an otherwise required optimization process with a single forward pass of the encoder. Subsequently, we learn to choose from and aggregate selected documents into a single modulation by conditioning on the question, allowing us to adapt a frozen language model during test time without requiring further gradient updates. Our experiment demonstrates the superiority of MAC in multiple aspects, including online adaptation performance, time, and memory efficiency. In addition, we show how MAC can be combined with and improve the performance of popular alternatives such as retrieval augmented generations (RAGs). Code is available at: https://github.com/jihoontack/MAC.","url_abs":"https://arxiv.org/abs/2403.04317v2","url_pdf":"https://arxiv.org/pdf/2403.04317v2.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":"online-adaptation-of-language-models-with-a","repo_url":"https://github.com/jihoontack/mac","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"meta-learning","task_name":"Meta-Learning"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2403.04317","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.04317"}},"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":"deterministic:regex_extraction","url":"https://github.com/jihoontack/MAC","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jihoontack/mac","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":4,"ran_violates":5,"ran_honours":1,"ran_fixture":1,"ran_draft_wrong":2,"unverified":2},"by_repo_kind":{"official":{"samples":14,"ran":12,"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":1,"samples":[{"code_sha256_prefix":"28e11820c8f8d9f0","entry":"clean_up","repo":"jihoontack/MAC","repo_kind":"official","path":"utils.py","file_url":"https://github.com/jihoontack/MAC/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"28e11820c8f8d9f0"}},{"code_sha256_prefix":"4053ebe53b067c39","entry":"context_summarization","repo":"jihoontack/MAC","repo_kind":"official","path":"evals/qa_utils.py","file_url":"https://github.com/jihoontack/MAC/blob/HEAD/evals/qa_utils.py","link_basis":"first_harvest_node","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":"4053ebe53b067c39"}},{"code_sha256_prefix":"4bc8c9e308a24e2f","entry":"decode_to_clean_text","repo":"jihoontack/mac","repo_kind":"official","path":"models/amortized_encdec.py","file_url":"https://github.com/jihoontack/mac/blob/HEAD/models/amortized_encdec.py","link_basis":"first_harvest_node","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":"4bc8c9e308a24e2f"}},{"code_sha256_prefix":"424012cb37b31172","entry":"default","repo":"jihoontack/MAC","repo_kind":"official","path":"models/module/cross_attention.py","file_url":"https://github.com/jihoontack/MAC/blob/HEAD/models/module/cross_attention.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"424012cb37b31172"}},{"code_sha256_prefix":"3e376007f812c566","entry":"embeddings_to_ids","repo":"jihoontack/MAC","repo_kind":"official","path":"evals/qa_utils.py","file_url":"https://github.com/jihoontack/MAC/blob/HEAD/evals/qa_utils.py","link_basis":"first_harvest_node","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":"3e376007f812c566"}},{"code_sha256_prefix":"64702a446a4111bd","entry":"exact_match","repo":"jihoontack/mac","repo_kind":"official","path":"models/amortized_encdec.py","file_url":"https://github.com/jihoontack/mac/blob/HEAD/models/amortized_encdec.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"64702a446a4111bd"}},{"code_sha256_prefix":"aa5486a3650902d8","entry":"exists","repo":"jihoontack/MAC","repo_kind":"official","path":"models/module/cross_attention.py","file_url":"https://github.com/jihoontack/MAC/blob/HEAD/models/module/cross_attention.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"aa5486a3650902d8"}},{"code_sha256_prefix":"fdd9a4d20f5a9d6f","entry":"f1_score","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"fdd9a4d20f5a9d6f"}},{"code_sha256_prefix":"8f7b3874eb0e028a","entry":"log_perplexity","repo":"jihoontack/mac","repo_kind":"official","path":"models/amortized_encdec.py","file_url":"https://github.com/jihoontack/mac/blob/HEAD/models/amortized_encdec.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8f7b3874eb0e028a"}},{"code_sha256_prefix":"c6a80c065d2e4851","entry":"normalize_answer","repo":"jihoontack/MAC","repo_kind":"official","path":"utils.py","file_url":"https://github.com/jihoontack/MAC/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c6a80c065d2e4851"}},{"code_sha256_prefix":"6ba8cee9f5daea41","entry":"pair","repo":"jihoontack/MAC","repo_kind":"official","path":"models/module/self_attention.py","file_url":"https://github.com/jihoontack/MAC/blob/HEAD/models/module/self_attention.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6ba8cee9f5daea41"}},{"code_sha256_prefix":"726980f025dbc7ee","entry":"passprompt","repo":"jihoontack/mac","repo_kind":"official","path":"models/amortized_encdec.py","file_url":"https://github.com/jihoontack/mac/blob/HEAD/models/amortized_encdec.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"726980f025dbc7ee"}},{"code_sha256_prefix":"9a299fe5ae09e407","entry":"uniq","repo":"jihoontack/MAC","repo_kind":"official","path":"models/module/cross_attention.py","file_url":"https://github.com/jihoontack/MAC/blob/HEAD/models/module/cross_attention.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9a299fe5ae09e407"}},{"code_sha256_prefix":"60f40382e49d0e3b","entry":"AmortEncDecAggregateWrapper","repo":"jihoontack/mac","repo_kind":"official","path":"models/amortized_encdec.py","file_url":"https://github.com/jihoontack/mac/blob/HEAD/models/amortized_encdec.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"60f40382e49d0e3b"}},{"code_sha256_prefix":"e8baf90dada23a73","entry":"tqdm_distributed","repo":"jihoontack/mac","repo_kind":"official","path":"models/amortized_encdec.py","file_url":"https://github.com/jihoontack/mac/blob/HEAD/models/amortized_encdec.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e8baf90dada23a73"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}