{"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/attention-approximates-sparse-distributed","title":"Attention Approximates Sparse Distributed Memory","arxiv_id":"2111.05498","date":"2021-11-10","proceeding":"NeurIPS 2021 12","authors":["Trenton Bricken","Cengiz Pehlevan"],"abstract":"While Attention has come to be an important mechanism in deep learning, there remains limited intuition for why it works so well. Here, we show that Transformer Attention can be closely related under certain data conditions to Kanerva's Sparse Distributed Memory (SDM), a biologically plausible associative memory model. We confirm that these conditions are satisfied in pre-trained GPT2 Transformer models. We discuss the implications of the Attention-SDM map and provide new computational and biological interpretations of Attention.","url_abs":"https://arxiv.org/abs/2111.05498v2","url_pdf":"https://arxiv.org/pdf/2111.05498v2.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":"attention-approximates-sparse-distributed","repo_url":"https://github.com/trentbrick/attention-approximates-sdm","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"jax","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[],"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":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2111.05498","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2111.05498"}},"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/trentbrick/attention-approximates-sdm","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":5,"ran_draft_wrong":1,"unverified":13},"by_repo_kind":{"official":{"samples":19,"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":"a727df5fd2f5599a","entry":"check_number_comma","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/src/transformers/convert_slow_tokenizer.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/src/transformers/convert_slow_tokenizer.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":"a727df5fd2f5599a"}},{"code_sha256_prefix":"d770e1dd1d799a47","entry":"ensure_valid_input","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/src/transformers/convert_graph_to_onnx.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/src/transformers/convert_graph_to_onnx.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":"d770e1dd1d799a47"}},{"code_sha256_prefix":"a4475703ff58ecf9","entry":"gelu_fast","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/src/transformers/activations.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/src/transformers/activations.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":"a4475703ff58ecf9"}},{"code_sha256_prefix":"45bb87451230d5e8","entry":"gelu_new","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/src/transformers/activations.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/src/transformers/activations.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":"45bb87451230d5e8"}},{"code_sha256_prefix":"7efe3db5c9e2f94d","entry":"generate_identified_filename","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/src/transformers/convert_graph_to_onnx.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/src/transformers/convert_graph_to_onnx.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":"7efe3db5c9e2f94d"}},{"code_sha256_prefix":"e21f72f1a9834aef","entry":"quick_gelu","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/src/transformers/activations.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/src/transformers/activations.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":"e21f72f1a9834aef"}},{"code_sha256_prefix":"9339ca51cea1f469","entry":"convert_slow_tokenizer","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/src/transformers/convert_slow_tokenizer.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/src/transformers/convert_slow_tokenizer.py","link_basis":"harvester_set","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":"9339ca51cea1f469"}},{"code_sha256_prefix":"0a85051c7ca5e520","entry":"cosine_to_hamm","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"SDM_Circ_Inter_Funcs.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/SDM_Circ_Inter_Funcs.py","link_basis":"harvester_set","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":"0a85051c7ca5e520"}},{"code_sha256_prefix":"7cedca63fc0c0ef4","entry":"f","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/SDM_Circ_Inter_Funcs.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/SDM_Circ_Inter_Funcs.py","link_basis":"harvester_set","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":"7cedca63fc0c0ef4"}},{"code_sha256_prefix":"4ffbc66e592539d9","entry":"fit_beta","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"Implementations_Associative_Memory.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/Implementations_Associative_Memory.py","link_basis":"harvester_set","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":"4ffbc66e592539d9"}},{"code_sha256_prefix":"02bdc6d03c9e9398","entry":"hamm_to_cosine","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"SDM_Circ_Inter_Funcs.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/SDM_Circ_Inter_Funcs.py","link_basis":"harvester_set","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":"02bdc6d03c9e9398"}},{"code_sha256_prefix":"3449d7d975edfb89","entry":"infer_shapes","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/src/transformers/convert_graph_to_onnx.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/src/transformers/convert_graph_to_onnx.py","link_basis":"harvester_set","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":"3449d7d975edfb89"}},{"code_sha256_prefix":"cc8c8c3ebf0c343f","entry":"mish","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/src/transformers/activations_tf.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/src/transformers/activations_tf.py","link_basis":"harvester_set","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":"cc8c8c3ebf0c343f"}},{"code_sha256_prefix":"c0614eb63596689f","entry":"optimal_p_and_ham","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"HugFace/SDM_Circ_Inter_Funcs.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/HugFace/SDM_Circ_Inter_Funcs.py","link_basis":"harvester_set","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":"c0614eb63596689f"}},{"code_sha256_prefix":"df0360e77dc451b9","entry":"softmax","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"SDM_Circ_Inter_Funcs.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/SDM_Circ_Inter_Funcs.py","link_basis":"harvester_set","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":"df0360e77dc451b9"}},{"code_sha256_prefix":"53ca5e262920709d","entry":"test_projection","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"utils_LearnProjections.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/utils_LearnProjections.py","link_basis":"harvester_set","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":"53ca5e262920709d"}},{"code_sha256_prefix":"ad63033a1bd00f97","entry":"train_projection","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"utils_LearnProjections.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/utils_LearnProjections.py","link_basis":"harvester_set","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":"ad63033a1bd00f97"}},{"code_sha256_prefix":"26f72e9fdbfa1b09","entry":"update_Binary_Neuron_SDM","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"Implementations_Associative_Memory.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/Implementations_Associative_Memory.py","link_basis":"harvester_set","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":"26f72e9fdbfa1b09"}},{"code_sha256_prefix":"7380c3067187ef0e","entry":"update_Cont_Attention","repo":"trentbrick/attention-approximates-sdm","repo_kind":"official","path":"Implementations_Associative_Memory.py","file_url":"https://github.com/trentbrick/attention-approximates-sdm/blob/HEAD/Implementations_Associative_Memory.py","link_basis":"harvester_set","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":"7380c3067187ef0e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}