SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.01012 · ICLR · 2024

Attention-based Iterative Decomposition for Tensor Product Representation

Taewon Park, Inchul Choi, Minho Lee

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; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 failures of our instrument; 0 no recorded run), measured 2026-11-22; 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/2406.01012.json · badge: /api/ran/2406.01012.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
taewonpark/aid canonical (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
taewonpark/AID marked official in Papers with Code
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
Decomposition Ran
ran on a synthesized input
taewonpark/AID/SARtask/models/AID.py
code served (permissive licence) · get_code("1ac5beff9fa808f7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple, ndim 4, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 as nn

# Define initialization arguments
INIT_ARGS = {
    'input_size': 4,
    'num_input': 3,
    'slot_size': 8,
    'mlp_hidden_size': 16,
    'binding_num_slots': 2,
    'reasoning_num_slots': 2,
    'num_iterations': 2,
    'epsilon': 1e-8,
}

# Define forward pass arguments
ARGS = {
    'inputs': torch.randn(5, 2, 4),  # [seq_len=5, batch_size=2, input_size=4]
}

# Construct and call the class
if __name__ == '__main__':
    from torch.nn import Module
    
    class Decomposition(nn.Module):

        def __init__(self, input_size, num_input, slot_size, mlp_hidden_size, binding_num_slots, reasoning_num_slots, num_iterations=3, epsilon=1e-08):
            super(Decomposition, self).__init__()
            self.input_size = input_size
            self.num_input = num_input
            self.binding_num_slots = binding_num_slots
            self.reasoning_num_slots = reasoning_num_slots
            self.slot_size = slot_size
            self.mlp_hidden_size = mlp_hidden_size
            self.num_iterations = num_iterations
            self.epsilon = epsilon
            self.norm_pre_ff = nn.LayerNorm(self.slot_size)
            self.to_q = nn.Linear(self.slot_size, self.slot_size)
            self.to_k = nn.Linear(self.input_size, self.slot_size)
            self.to_v = nn.Linear(self.input_size, self.slot_size)
            self.to_linear = nn.Sequential(nn.Linear(self.slot_size, self.mlp_hidden_size), nn.ReLU(), nn.Linear(self.mlp_hidden_size, self.slot_size))
            self.binding_linear = nn.Linear(self.num_input * self.input_size, self.binding_num_slots * self.slot_size)
            self.reasoning_linear = nn.Linear(self.num_input * self.input_size, self.reasoning_num_slots * self.slot_size)
            self.slot_proj_linear = nn.Linear(self.slot_size * 2, self.slot_size)
            self.dropout = nn.Dropout(p=0.5)

        def forward(self, inputs):
            """
                inputs:   [batch_size, input_size]
            """
            seq_len, batch_size = (inputs.shape[0], inputs.shape[1])
            return (inputs, inputs.view(seq_len, batch_size, -1))

        def binding_slot_attention(self, inputs, inputs_cat):
            seq_len, batch_size = (inputs.shape[0], inputs.shape[1])
            initial_slots = self.binding_linear(inputs_cat)
            initial_slots = initial_slots.view(seq_len, batch_size, -1, self.slot_size)
            k, v = (self.to_k(inputs), self.to_v(inputs))
            k = torch.nn.functional.elu(k, 1.0, False) + 1.0
            slots = initial_slots
            scale = 1.0 / self.slot_size
            for _ in range(self.num_iterations):
                q = self.to_q(slots) + initial_slots
                q = q * self.slot_size ** (-0.5)
                q = torch.nn.functional.elu(q, 1.0, False) + 1.0
                attn_logits = torch.einsum('nbis,nbjs->nbij', k, q)
                attn_logits = attn_logits
                attn = torch.nn.functional.softmax(attn_logits, dim=3)
                attn = attn + self.epsilon
                attn = attn / attn.sum(dim=2, keepdim=True)
                updates = torch.einsum('nbij,nbik->nbjk', attn, v)
                slots = slots + self.to_linear(self.norm_pre_ff(updates)) * scale
            slots = torch.cat((self.dropout(initial_slots), slots), dim=-1)
            slots = self.slot_proj_linear(slots)
            return slots

        def reasoning_slot_attention(self, inputs, inputs_cat):
            seq_len, batch_size = (inputs.shape[0], inputs.shape[1])
            initial_slots = self.reasoning_linear(inputs_cat)
            initial_slots = initial_slots.view(seq_len, batch_size, -1, self.slot_size)
            k, v = (self.to_k(inputs), self.to_v(inputs))
            k = torch.nn.functional.elu(k, 1.0, False) + 1.0
            slots = initial_slots
            scale = 1.0 / self.slot_size
            for _ in range(self.num_iterations):
                q = self.to_q(slots) + initial_slots
                q = q * self.slot_size ** (-0.5)
                q = torch.nn.functional.elu(q, 1.0, False) + 1.0
                attn_logits = torch.einsum('nbis,nbjs->nbij', k, q)
                attn_logits = attn_logits
                attn = torch.nn.functional.softmax(attn_logits, dim=3)
                attn = attn + self.epsilon
                attn = attn / attn.sum(dim=2, keepdim=True)
                updates = torch.einsum('nbij,nbik->nbjk', attn, v)
                slots = slots + self.to_linear(self.norm_pre_ff(updates)) * scale
            slots = torch.cat((self.dropout(initial_slots), slots), dim=-1)
            slots = self.slot_proj_linear(slots)
            return slots

    model = Decomposition(**INIT_ARGS)
    model.eval()
    with torch.no_grad():
        output = model(**ARGS)
    print("Output shapes:", [o.shape for o in output])
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 4, dtype family float — a tuple output has no array shape of its own; none is stated
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
elu_p1 Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
taewonpark/aid/WikiText103/src/utils/AID.py
code served (permissive licence) · get_code("fa08c36ab5558b55")
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) and returned Tensor, ndim 2, dtype family float, shape (2, 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)

# The function elu_p1 takes a single parameter 'x' which is used with F.elu
# F.elu expects a tensor input
x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (2, 4) — shape (2, 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
sum_norm Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
taewonpark/aid/WikiText103/src/utils/AID.py
code served (permissive licence) · get_code("379d7685e2a746e5")
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) and returned Tensor, ndim 2, dtype family float, shape (2, 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

torch.manual_seed(0)

# The function sum_norm takes a single parameter 'x' which is a tensor
# It performs: x / x.sum(-1, keepdim=True)
# This means x should be a tensor where we can sum along the last dimension

# Create a small tensor with distinct dimensions
# batch_size=2, feature_dim=4
x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (2, 4) — shape (2, 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
sum_norm_eps Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
taewonpark/aid/WikiText103/src/utils/AID.py
code served (permissive licence) · get_code("90f48cc1487150b9")
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) and returned Tensor, ndim 2, dtype family float, shape (2, 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

torch.manual_seed(0)

# The function sum_norm_eps takes a single parameter x
# It performs: x / (x.sum(-1, keepdim=True) + 1e-05)
# So x should be a tensor that supports sum operation along the last dimension

x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (2, 4) — shape (2, 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

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, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 3 the same month, 0 later) and 1 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
elu_p1 4 other papers
3 dated earlier, 1 the same month
2106.06295 (2021-06)
Going Beyond Linear Transformers with Recurrent Fast Weight Programmers
2310.16076 (2023-10)
Practical Computational Power of Linear Transformers and Their Recurrent and Self-Referential Extensions
2312.00276 (2023-12)
Metalearning Continual Learning Algorithms
and 1 more not named here
sum_norm 4 other papers
3 dated earlier, 1 the same month
2106.06295 (2021-06)
Going Beyond Linear Transformers with Recurrent Fast Weight Programmers
2310.16076 (2023-10)
Practical Computational Power of Linear Transformers and Their Recurrent and Self-Referential Extensions
2312.00276 (2023-12)
Metalearning Continual Learning Algorithms
and 1 more not named here
sum_norm_eps 2 other papers
1 dated earlier, 1 the same month
2106.06295 (2021-06)
Going Beyond Linear Transformers with Recurrent Fast Weight Programmers
2406.06976 (2024-06)
Discrete Dictionary-based Decomposition Layer for Structured Representation Learning

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-22.

Repositories linked to this paper

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

Abstract

In recent research, Tensor Product Representation (TPR) is applied for the systematic generalization task of deep neural networks by learning the compositional structure of data. However, such prior works show limited performance in discovering and representing the symbolic structure from unseen test data because their decomposition to the structural representations was incomplete. In this work, we propose an Attention-based Iterative Decomposition (AID) module designed to enhance the decomposition operations for the structured representations encoded from the sequential input data with TPR. Our AID can be easily adapted to any TPR-based model and provides enhanced systematic decomposition through a competitive attention mechanism between input features and structured representations. In our experiments, AID shows effectiveness by significantly improving the performance of TPR-based prior works on the series of systematic generalization tasks. Moreover, in the quantitative and qualitative evaluations, AID produces more compositional and well-bound structural representations than other works. 1

For agents

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

get_harvested_code_for_paper("2406.01012")
get_code_for_paper("2406.01012")
have("2406.01012")

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

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

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

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

Connect an agent — have() is free.