{"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/towards-mental-time-travel-a-hierarchical","title":"Towards mental time travel: a hierarchical memory for reinforcement learning agents","arxiv_id":"2105.14039","date":"2021-05-28","proceeding":"NeurIPS 2021 12","authors":["Andrew Kyle Lampinen","Stephanie C. Y. Chan","Andrea Banino","Felix Hill"],"abstract":"Reinforcement learning agents often forget details of the past, especially after delays or distractor tasks. Agents with common memory architectures struggle to recall and integrate across multiple timesteps of a past event, or even to recall the details of a single timestep that is followed by distractor tasks. To address these limitations, we propose a Hierarchical Chunk Attention Memory (HCAM), which helps agents to remember the past in detail. HCAM stores memories by dividing the past into chunks, and recalls by first performing high-level attention over coarse summaries of the chunks, and then performing detailed attention within only the most relevant chunks. An agent with HCAM can therefore \"mentally time-travel\" -- remember past events in detail without attending to all intervening events. We show that agents with HCAM substantially outperform agents with other memory architectures at tasks requiring long-term recall, retention, or reasoning over memory. These include recalling where an object is hidden in a 3D environment, rapidly learning to navigate efficiently in a new neighborhood, and rapidly learning and retaining new object names. Agents with HCAM can extrapolate to task sequences much longer than they were trained on, and can even generalize zero-shot from a meta-learning setting to maintaining knowledge across episodes. HCAM improves agent sample efficiency, generalization, and generality (by solving tasks that previously required specialized architectures). Our work is a step towards agents that can learn, interact, and adapt in complex and temporally-extended environments.","url_abs":"https://arxiv.org/abs/2105.14039v3","url_pdf":"https://arxiv.org/pdf/2105.14039v3.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":"towards-mental-time-travel-a-hierarchical","repo_url":"https://github.com/deepmind/deepmind-research","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"tf","reach":null},{"paper_slug":"towards-mental-time-travel-a-hierarchical","repo_url":"https://github.com/deepmind/dm_fast_mapping","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"towards-mental-time-travel-a-hierarchical","repo_url":"https://github.com/lucidrains/HTM-pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"towards-mental-time-travel-a-hierarchical","repo_url":"https://github.com/MindSpore-scientific-2/code-4/tree/main/HTM-mindspore","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"towards-mental-time-travel-a-hierarchical","repo_url":"https://github.com/MindSpore-scientific-2/code-5/tree/main/HTM-mindspore","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null}],"tasks":[{"task_slug":"meta-learning","task_name":"Meta-Learning"},{"task_slug":"navigate","task_name":"Navigate"},{"task_slug":"reinforcement-learning-1","task_name":"Reinforcement Learning (RL)"},{"task_slug":"reinforcement-learning-2","task_name":"reinforcement-learning"}],"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=2105.14039","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2105.14039"}},"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/deepmind/deepmind-research","reach":null},{"provenance":"deterministic:regex_extraction","url":"https://github.com/deepmind/dm_fast_mapping","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindSpore-scientific-2/code-5/tree/main/HTM-mindspore","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lucidrains/HTM-pytorch","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindSpore-scientific-2/code-4/tree/main/HTM-mindspore","reach":null}],"summary":{"ran":2,"ran_honours":1,"unverified":3},"by_repo_kind":{"official":{"samples":4,"ran":1,"repositories":1},"listed":{"samples":2,"ran":2,"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":"4edc3f6c9182d6ba","entry":"HTMAttention","repo":"lucidrains/HTM-pytorch","repo_kind":"listed","path":"htm_pytorch/htm_pytorch.py","file_url":"https://github.com/lucidrains/HTM-pytorch/blob/HEAD/htm_pytorch/htm_pytorch.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":"4edc3f6c9182d6ba"}},{"code_sha256_prefix":"d5ba387dec7cb4ba","entry":"SinusoidalPosition","repo":"lucidrains/HTM-pytorch","repo_kind":"listed","path":"htm_pytorch/htm_pytorch.py","file_url":"https://github.com/lucidrains/HTM-pytorch/blob/HEAD/htm_pytorch/htm_pytorch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d5ba387dec7cb4ba"}},{"code_sha256_prefix":"1e8ece086c64bdec","entry":"sinusoid_position_encoding","repo":"deepmind/deepmind-research","repo_kind":"official","path":"hierarchical_transformer_memory/hierarchical_attention/htm_attention.py","file_url":"https://github.com/deepmind/deepmind-research/blob/HEAD/hierarchical_transformer_memory/hierarchical_attention/htm_attention.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"1e8ece086c64bdec"}},{"code_sha256_prefix":"2edf304a64ef7730","entry":"HierarchicalMemory","repo":"deepmind/deepmind-research","repo_kind":"official","path":"hierarchical_transformer_memory/hierarchical_attention/htm_attention.py","file_url":"https://github.com/deepmind/deepmind-research/blob/HEAD/hierarchical_transformer_memory/hierarchical_attention/htm_attention.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":"2edf304a64ef7730"}},{"code_sha256_prefix":"47ba4f0ef6df2621","entry":"HierarchicalMemoryAttention","repo":"deepmind/deepmind-research","repo_kind":"official","path":"hierarchical_transformer_memory/hierarchical_attention/htm_attention.py","file_url":"https://github.com/deepmind/deepmind-research/blob/HEAD/hierarchical_transformer_memory/hierarchical_attention/htm_attention.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":"47ba4f0ef6df2621"}},{"code_sha256_prefix":"f91e2499666b6b69","entry":"hk_vmap","repo":"deepmind/deepmind-research","repo_kind":"official","path":"hierarchical_transformer_memory/hierarchical_attention/htm_attention.py","file_url":"https://github.com/deepmind/deepmind-research/blob/HEAD/hierarchical_transformer_memory/hierarchical_attention/htm_attention.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":"f91e2499666b6b69"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}