SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · aaai_30436 · AAAI · 2024

Rethinking Attention: Exploring Shallow Feed-Forward Neural Networks as an Alternative to Attention Layers in Transformers (Student Abstract)

Sidak Singh, Danilo Dordevic, Vukasin Bozic, Joseph Thommes, Daniele Coppola

Open in the Atlas

Code that ran

7 of 9 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 5 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-23; 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/aaai_30436.json · badge: /api/ran/aaai_30436.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
vulus98/Rethinking-attention canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
count_parameters Ran
ran, honoured the contract we drafted
vulus98/Rethinking-attention/models/definitions/transformer_model.py
code served (permissive licence) · get_code("f6b944f50d3f15ae")
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 int, ndim 0, dtype family int, shape () 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 as nn

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model
}
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 int, ndim 0, dtype family int, shape () — shape () 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
get_batches Ran
ran on a synthesized input
vulus98/Rethinking-attention/utils/simulator.py
code served (permissive licence) · get_code("aff0f75474f861cf")
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 list, ndim 2, dtype family int; 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 numpy as np

# Simple dataset - just a list of items
data_set = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
batch_size = 3

ARGS = {
    "data_set": data_set,
    "batch_size": batch_size
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — a list 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: none by the harness; any seed is in the setup block
get_checkpoint_name Ran
ran on a synthesized input
vulus98/Rethinking-attention/utils/simulator.py
code served (permissive licence) · get_code("7aa51ea1d6a57c2a")
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 str. 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 torch

torch.manual_seed(0)

ARGS = {
    'model_name': 'resnet50',
    'batch_size': 32,
    'index_in': 0,
    'index_out': 10,
    'epoch': 5,
    'ext_pref': 'ELR'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
get_clones Ran
ran; our contract draft was wrong, not the code
vulus98/Rethinking-attention/models/definitions/transformer_model.py
code served (permissive licence) · get_code("288a87cd381a7d1b")
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 ModuleList. 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 copy
import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a simple neural network module to deep copy
class SimpleModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self.relu = nn.ReLU()
    
    def forward(self, x):
        return self.relu(self.linear(x))

# Instantiate the module
module = SimpleModule()

# Define the number of deep copies to create
num_of_deep_copies = 3

# Construct the ARGS dictionary
ARGS = {
    "module": module,
    "num_of_deep_copies": num_of_deep_copies
}
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 ModuleList — a ModuleList output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ModuleList output the recorded ndim 1 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
get_training_state Ran
ran on a synthesized input
vulus98/Rethinking-attention/utils/utils.py
code served (permissive licence) · get_code("00622c5e24192d8a")
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 torch
import torch.nn as nn

torch.manual_seed(0)

# Define a minimal model that has a state_dict() method
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create model instance
model = SimpleModel()

# Create training config dict with all required keys
training_config = {
    'dataset_name': 'test_dataset',
    'language_direction': 'en-fr',
    'num_of_epochs': 10,
    'batch_size': 32
}

# Define ARGS mapping
ARGS = {
    'training_config': training_config,
    'model': model
}
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 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
replace_encoder Ran
ran on a synthesized input
vulus98/Rethinking-attention/utils/full_sentence_utils.py
code served (permissive licence) · get_code("ac3328dc2d08d50c")
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 MinimalTransformer. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 torch
import torch.nn as nn

torch.manual_seed(0)

device = torch.device('cpu')

# Global constant used in pad_shape
MAX_LEN = 8

# Stand-in FF network that accepts src_representations_batch and mask
class SimpleFFNetwork(nn.Module):
    def __init__(self, input_dim, output_dim):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def forward(self, x, mask):
        # x shape: (B, S*MD)
        # mask shape: (B, S*MD)
        return self.linear(x)

# Build a minimal transformer with encoder_layers
class MinimalTransformer(nn.Module):
    def __init__(self, num_layers=2, d_model=4):
        super().__init__()
        self.encoder = nn.Module()
        # Create encoder_layers as a list of simple modules
        self.encoder.encoder_layers = nn.ModuleList([
            nn.Identity() for _ in range(num_layers)
        ])
        self.d_model = d_model
    
    def forward(self, x):
        return x

# Create substitute FF network
# Input will be (batch_size, seq_len * model_dim) after reshaping
# Output should match same shape
substitute_ff = SimpleFFNetwork(input_dim=16, output_dim=16)  # 2*4 = 8, but padding makes it larger

# Create transformer with multiple encoder layers
transformer = MinimalTransformer(num_layers=3, d_model=4)

# Layer index to replace
layer_idx = 1

ARGS = {
    'transformer': transformer,
    'substitute': substitute_ff,
    'layer': layer_idx,
    'device': device
}
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 MinimalTransformer — a MinimalTransformer output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MinimalTransformer 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
replace_sublayer Ran
ran on a synthesized input
vulus98/Rethinking-attention/utils/full_sentence_utils.py
code served (permissive licence) · get_code("0eb7ba8b5ed87468")
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 SimpleTransformer. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 torch
import torch.nn as nn

torch.manual_seed(0)

MAX_LEN = 10

# Build a minimal FF_net that matches the signature used in SublayerZeroSubstitute
class SimpleFFNet(nn.Module):
    def __init__(self, input_dim):
        super().__init__()
        self.linear = nn.Linear(input_dim, input_dim)
    
    def forward(self, x, mask):
        return self.linear(x)

# Build a minimal sublayer that matches the signature used in EncoderLayerSubstitute
class SimpleSublayer(nn.Module):
    def __init__(self, model_dim):
        super().__init__()
        self.linear = nn.Linear(model_dim, model_dim)
    
    def forward(self, src, pointwise_net):
        return self.linear(src)

# Build a minimal encoder_layer that EncoderLayerSubstitute expects
class SimpleEncoderLayer(nn.Module):
    def __init__(self, model_dimension=4):
        super().__init__()
        self.model_dimension = model_dimension
        self.multi_headed_attention = nn.Linear(model_dimension, model_dimension)
        self.pointwise_net = nn.Linear(model_dimension, model_dimension)
        
        # sublayers[0] would normally be the MHA layer (which we replace)
        # sublayers[1] is the pointwise feedforward layer
        self.sublayers = nn.ModuleList([
            nn.Linear(model_dimension, model_dimension),
            SimpleSublayer(model_dimension)
        ])

# Build a minimal transformer with encoder structure
class SimpleTransformer(nn.Module):
    def __init__(self, model_dim=4, num_layers=2):
        super().__init__()
        self.encoder = nn.Module()
        self.encoder.encoder_layers = nn.ModuleList([
            SimpleEncoderLayer(model_dim) for _ in range(num_layers)
        ])

# Create instances
model_dim = 4
transformer = SimpleTransformer(model_dim=model_dim, num_layers=2)
ff_substitute = SimpleFFNet(input_dim=model_dim * MAX_LEN)
device = torch.device('cpu')
layer_idx = 0

ARGS = {
    'transformer': transformer,
    'substitute': ff_substitute,
    'layer': layer_idx,
    'device': 'cpu'
}
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 SimpleTransformer — a SimpleTransformer output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SimpleTransformer 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
batch_size_fn Not yet run
unverified (harvested, no recorded run)
vulus98/Rethinking-attention/utils/data_utils.py
code served (permissive licence) · get_code("64193f1fda8ca8f5")
How it ran

no invocation recorded.

calculate_bleu_score Not yet run
unverified (harvested, no recorded run)
vulus98/Rethinking-attention/utils/utils.py
code served (permissive licence) · get_code("4069795d86c6927d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 2 later) and 7 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
count_parameters 180 other papers
114 dated earlier, 24 later, 42 same year, order not determinable · 8 only as an assembly brick
1705.08415 (2017-05)
Supervised Community Detection with Line Graph Neural Networks
1707.01926 (2017-07)
Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting
1808.09367 (2018-08)
Deriving Machine Attention from Human Rationales
and 177 more not named here
get_clones 2 other papers
1 dated earlier, 1 later
1706.03762 (2017-06)
Attention Is All You Need
2511.00446 (2025-11)
ToxicTextCLIP: Text-Based Poisoning and Backdoor Attacks on CLIP Pre-training

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

Repositories linked to this paper

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

Abstract

This work presents an analysis of the effectiveness of using standard shallow feed-forward networks to mimic the behavior of the attention mechanism in the original Transformer model, a state-of-the-art architecture for sequence-tosequence tasks. We substitute key elements of the attention mechanism in the Transformer with simple feed-forward networks, trained using the original components via knowledge distillation. Our experiments, conducted on the IWSLT2017 dataset, reveal the capacity of these "attentionless Transformers" to rival the performance of the original architecture. Through rigorous ablation studies, and experimenting with various replacement network types and sizes, we offer insights that support the viability of our approach. This not only sheds light on the adaptability of shallow feed-forward networks in emulating attention mechanisms but also underscores their potential to streamline complex architectures for sequence-to-sequence tasks.

For agents

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

get_harvested_code_for_paper("aaai_30436")
get_code_for_paper("aaai_30436")
have("aaai_30436")

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

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

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

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

Connect an agent — have() is free.