SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2002.03519 · 2020

Self-Attentive Associative Memory

arXiv · PDF · Open in the Atlas

Code that ran

4 of 4 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-21; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2002.03519.json · badge: /api/ran/2002.03519.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
thaihungle/SAM canonical (classifier label)
classifier basis: census
4 ran · 0 no recorded run
FunctionStatusWhere it lives
norm_col_init Ran
ran, honoured the contract we drafted
thaihungle/SAM/baselines/sam/utils.py
pointer only (licence: MIT); the stored copy get_code serves, from unrealtracking/tom2c, is pointer only (licence: NONE) · get_code("21a7f97ee3e0b7cc")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from unrealtracking/tom2c, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

op_att Ran
ran on a synthesized input
thaihungle/SAM/baselines/sam/stm_basic.py
code served (permissive licence) · get_code("b489920b54ff3e28")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 4, dtype family float, shape (2, 3, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Analyze the function to understand tensor shapes:
# q: unsqueeze(2) -> shape (batch, q_len, 1, d)
#    repeat(1, 1, k.shape[1], 1) -> shape (batch, q_len, k_len, d)
# k: unsqueeze(1) -> shape (batch, 1, k_len, d)
#    repeat(1, q.shape[1], 1, 1) -> shape (batch, q_len, k_len, d)
# q * k: element-wise mult -> shape (batch, q_len, k_len, d)
# F.tanh(q*k): shape (batch, q_len, k_len, d)
# unsqueeze(4): shape (batch, q_len, k_len, d, 1)
# v: unsqueeze(1) -> shape (batch, 1, v_len, v_dim)
#    repeat(1, q.shape[1], 1, 1) -> shape (batch, q_len, v_len, v_dim)
#    unsqueeze(3) -> shape (batch, q_len, v_len, 1, v_dim)
# matmul: (batch, q_len, k_len, d, 1) @ (batch, q_len, v_len, 1, v_dim)
#         This requires k_len == v_len and d == 1 for valid matmul
# sum(dim=2): sum over k_len dimension

# For the matmul to work:
# - k.shape[1] must equal v.shape[1] (k_len == v_len)
# - q.shape[-1] must be compatible with v.shape[-1] after broadcasting

# Let's set:
batch_size = 2
q_len = 3
k_len = 5
v_len = 5
d_q = 4
d_v = 4

# Create tensors
q = torch.randn(batch_size, q_len, d_q)  # (2, 3, 4)
k = torch.randn(batch_size, k_len, d_q)  # (2, 5, 4)
v = torch.randn(batch_size, v_len, d_v)  # (2, 5, 4)

ARGS = {
    "q": q,
    "k": k,
    "v": v,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 3, 4, 4) — shape (2, 3, 4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
read_config Ran
ran; our contract draft was wrong, not the code
thaihungle/SAM/baselines/sam/utils.py
code served (permissive licence) · get_code("4000c95fa330f2ce")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
import os

# Create a temporary JSON config file
temp_dir = tempfile.mkdtemp()
config_file_path = os.path.join(temp_dir, "config.json")

config_data = {
    "model": "test_model",
    "learning_rate": 0.001,
    "batch_size": 32,
    "epochs": 10,
    "layers": [64, 128, 256]
}

with open(config_file_path, 'w') as f:
    json.dump(config_data, f)

ARGS = {
    "file_path": config_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sdp_att Ran
ran on a synthesized input
thaihungle/SAM/baselines/sam/stm_basic.py
code served (permissive licence) · get_code("69a12f5cd80a0f87")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 5) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# The function sdp_att performs scaled dot-product attention
# It expects:
# q: query tensor of shape (batch, seq_len, dim)
# k: key tensor of shape (batch, seq_len, dim)
# v: value tensor of shape (batch, seq_len, dim)
#
# The function:
# 1. Computes dot product between q and k.T
# 2. Applies softmax
# 3. Multiplies with v

batch_size = 2
seq_len_q = 3
seq_len_kv = 4
dim = 5

# Create query tensor: (batch, seq_len_q, dim)
q = torch.randn(batch_size, seq_len_q, dim)

# Create key tensor: (batch, seq_len_kv, dim)
k = torch.randn(batch_size, seq_len_kv, dim)

# Create value tensor: (batch, seq_len_kv, dim)
v = torch.randn(batch_size, seq_len_kv, dim)

ARGS = {
    "q": q,
    "k": k,
    "v": v,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 5) — shape (2, 3, 5) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 2 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 2 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
read_config 5 other papers
1 dated earlier, 4 later
1809.00397 (2018-09)
Visual Transfer between Atari Games using Competitive Reinforcement Learning
2008.01976 (2020-08)
Robust Deep Reinforcement Learning through Adversarial Loss
2402.02165 (2024-02)
Towards Optimal Adversarial Robust Q-learning with Bellman Infinity-error
and 2 more not named here
norm_col_init 4 other papers
4 later · 2 only as an assembly brick
2010.13110 (2020-10)
Learning Multi-Agent Coordination for Enhancing Target Coverage in Directional Sensor Networks
2109.02066 (2021-09)
Hierarchical Object-to-Zone Graph for Object Navigation
2111.09189 (2021-11)
ToM2C: Target-oriented Multi-agent Communication and Cooperation with Theory of Mind
and 1 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Heretofore, neural networks with external memory are restricted to single memory with lossy representations of memory interactions. A rich representation of relationships between memory pieces urges a high-order and segregated relational memory. In this paper, we propose to separate the storage of individual experiences (item memory) and their occurring relationships (relational memory). The idea is implemented through a novel Self-attentive Associative Memory (SAM) operator. Found upon outer product, SAM forms a set of associative memories that represent the hypothetical high-order relationships between arbitrary pairs of memory elements, through which a relational memory is constructed from an item memory. The two memories are wired into a single sequential model capable of both memorization and relational reasoning. We achieve competitive results with our proposed two-memory model in a diversity of machine learning tasks, from challenging synthetic problems to practical testbeds such as geometry, graph, reinforcement learning, and question answering.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2002.03519")
get_code_for_paper("2002.03519")
have("2002.03519")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2002.03519.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2002.03519.svg)](https://syntology.ai/paper/2002.03519)

Connect an agent — have() is free.