{"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/human-like-episodic-memory-for-infinite","title":"Human-like Episodic Memory for Infinite Context LLMs","arxiv_id":"2407.09450","date":"2024-07-12","proceeding":null,"authors":["Zafeirios Fountas","Martin A Benfeghoul","Adnan Oomerjee","Fenia Christopoulou","Gerasimos Lampouras","Haitham Bou-Ammar","Jun Wang"],"abstract":"Large language models (LLMs) have shown remarkable capabilities, but still struggle with processing extensive contexts, limiting their ability to maintain coherence and accuracy over long sequences. In contrast, the human brain excels at organising and retrieving episodic experiences across vast temporal scales, spanning a lifetime. In this work, we introduce EM-LLM, a novel approach that integrates key aspects of human episodic memory and event cognition into LLMs with no fine-tuning, enabling them to handle practically infinite context lengths while maintaining computational efficiency. EM-LLM organises sequences of tokens into coherent episodic events using a combination of Bayesian surprise and graph-theoretic boundary refinement in an online fashion. When needed, these events are retrieved through a two-stage memory process, combining similarity-based and temporally contiguous retrieval for efficient and human-like access to relevant information. Experiments on the LongBench and InfiniteBench benchmarks demonstrate EM-LLM's superior performance, consistently outperforming the state-of-the-art retrieval model InfLLM across various baseline LLMs. In addition, EM-LLM outperforms its popular counterpart, RAG, in a wide range of tasks, while requiring similar resources. Notably, EM-LLM's performance even surpasses full-context models in most tasks, while successfully performing retrieval across 10 million tokens - a scale computationally infeasible for such models. Finally, our analysis reveals strong correlations between EM-LLM's event segmentation and human-perceived events, suggesting a bridge between this artificial system and its biological counterpart, thereby offering a novel computational framework for exploring human memory mechanisms.","url_abs":"https://arxiv.org/abs/2407.09450v2","url_pdf":"https://arxiv.org/pdf/2407.09450v2.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":"human-like-episodic-memory-for-infinite","repo_url":"https://github.com/em-llm/EM-LLM-model","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"computational-efficiency","task_name":"Computational Efficiency"},{"task_slug":"event-segmentation","task_name":"Event Segmentation"},{"task_slug":"rag","task_name":"RAG"},{"task_slug":"retrieval","task_name":"Retrieval"}],"methods":[{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bart","method_name":"BART"},{"method_slug":"bert","method_name":"BERT"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-linear-decay","method_name":"Linear Warmup With Linear Decay"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"rag","method_name":"RAG"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"},{"method_slug":"wordpiece","method_name":"WordPiece"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2407.09450","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2407.09450"}},"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/em-llm/EM-LLM-model","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_fixture":1,"ran":9,"unverified":3},"by_repo_kind":{"official":{"samples":13,"ran":10,"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":"3c76e52815c5401d","entry":"repeat_kv","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/attention/utils.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/attention/utils.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":"3c76e52815c5401d"}},{"code_sha256_prefix":"a359cd294a71264d","entry":"causal_lm_forward","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/utils/patch_hf.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/utils/patch_hf.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":"a359cd294a71264d"}},{"code_sha256_prefix":"0b50d2ffa074850e","entry":"conductance","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/attention/similarity_refinement/similarity.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/attention/similarity_refinement/similarity.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":"0b50d2ffa074850e"}},{"code_sha256_prefix":"0c1a7efc206a20ea","entry":"em_llm_attn_forward","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/attention/em_llm.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/attention/em_llm.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":"0c1a7efc206a20ea"}},{"code_sha256_prefix":"2eb701a1cd15182a","entry":"f1_score","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"benchmark/infinitebench_eval.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/benchmark/infinitebench_eval.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":"2eb701a1cd15182a"}},{"code_sha256_prefix":"fadd3648ce23daa7","entry":"huggingface_forward","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/utils/patch_hf.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/utils/patch_hf.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":"fadd3648ce23daa7"}},{"code_sha256_prefix":"95da472c278d0d78","entry":"intra_inter_sim","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/attention/similarity_refinement/similarity.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/attention/similarity_refinement/similarity.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":"95da472c278d0d78"}},{"code_sha256_prefix":"d9d71f61780321f5","entry":"modularity","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/attention/similarity_refinement/similarity.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/attention/similarity_refinement/similarity.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":"d9d71f61780321f5"}},{"code_sha256_prefix":"4b44a4d3fd80a48d","entry":"normalize_answer","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"benchmark/infinitebench_eval.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/benchmark/infinitebench_eval.py","link_basis":"harvester_set","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":"4b44a4d3fd80a48d"}},{"code_sha256_prefix":"f62b4d2a31aa1081","entry":"normalize_zh_answer","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"benchmark/infinitebench_eval.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/benchmark/infinitebench_eval.py","link_basis":"harvester_set","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":"f62b4d2a31aa1081"}},{"code_sha256_prefix":"b8fd76193f3df437","entry":"em_llm_causal_lm_forward","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/attention/em_llm.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/attention/em_llm.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":"b8fd76193f3df437"}},{"code_sha256_prefix":"bb6ff175b16b7429","entry":"events_with_similarity_adjustment","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/attention/similarity_refinement/segmentation.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/attention/similarity_refinement/segmentation.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":"bb6ff175b16b7429"}},{"code_sha256_prefix":"c32ff1ae851680ef","entry":"model_forward","repo":"em-llm/EM-LLM-model","repo_kind":"official","path":"em_llm/utils/patch_hf.py","file_url":"https://github.com/em-llm/EM-LLM-model/blob/HEAD/em_llm/utils/patch_hf.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":"c32ff1ae851680ef"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}