SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.03827 · ICML · 2024

Uniform Memory Retrieval with Larger Capacity for Modern Hopfield Models

Han Liu, Jerry Yao, Chieh Hu, Dennis Wu, Jerry Yao-Chieh Hu, Teng-Yun Hsiao

arXiv · PDF · Open in the Atlas

Code that ran

6 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (4 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 2 failures of our instrument; 1 no recorded run), measured 2026-11-23; 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/2404.03827.json · badge: /api/ran/2404.03827.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
magics-lab/uhop canonical (classifier label)
classifier basis: classifier_2025
6 ran · 1 no recorded run
FunctionStatusWhere it lives
Association Ran
ran on a synthesized input · constructed an object; no result was computed
magics-lab/uhop/layers.py
code served (permissive licence) · get_code("7b1cf2534617049b")
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 an instance of its own class, Association: the run constructed the object and did not call it, so no result was computed. 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)

ARGS = {
    'scale': 0.5,
    'attention_dropout': 0.1,
    'mode': 'softmax',
    'norm': False
}
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 Association — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Association 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
LearnableHopfield Ran
ran on a synthesized input · constructed an object; no result was computed
magics-lab/uhop/layers.py
code served (permissive licence) · get_code("5664657431b7e7a4")
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 an instance of its own class, LearnableHopfield: the run constructed the object and did not call it, so no result was computed. 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)

ARGS = {
    'd_model': 8,
    'n_heads': 2,
    'd_keys': 4,
    'd_values': 4,
    'mix': True,
    'update_steps': 1,
    'dropout': 0.1,
    'mode': 'softmax',
    'kernel': 'lin',
    'scale': None,
}
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 LearnableHopfield — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a LearnableHopfield 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
Sparsemax Ran
ran on a synthesized input · constructed an object; no result was computed
magics-lab/uhop/layers.py
code served (permissive licence) · get_code("8c413a2b668b9234")
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 an instance of its own class, Sparsemax: the run constructed the object and did not call it, so no result was computed. 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)

# Create a small input tensor for testing
# Shape: (2, 4) - batch size 2, dimension 4
input_tensor = torch.randn(2, 4, requires_grad=True)

# Test with different dimensions to ensure robustness
# dim=-1 is the default and most common case
dim_value = -1

ARGS = {
    'dim': dim_value
}
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 Sparsemax — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Sparsemax 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
SparsemaxFunction Ran
ran on a synthesized input · constructed an object; no result was computed
magics-lab/uhop/layers.py
code served (permissive licence) · get_code("31d60d234cc0692f")
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 an instance of its own class, SparsemaxFunction: the run constructed the object and did not call it, so no result was computed. 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)

# SparsemaxFunction.forward takes (ctx, input, dim)
# where input is a torch.Tensor and dim is an int
# The function processes input through various operations and uses ctx to store state

# Create a small input tensor
# Using shape (2, 3, 4) to test the reshaping logic (input_dim > 2)
input_tensor = torch.randn(2, 3, 4)

# dim parameter: -1 means the last dimension (default and common case)
dim = -1

ARGS = {
    "input": input_tensor,
    "dim": dim,
}
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 SparsemaxFunction — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SparsemaxFunction 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
flatten_all_but_nth_dim Ran
ran; our contract draft was wrong, not the code
magics-lab/uhop/layers.py
code served (permissive licence) · get_code("32ac3d67805b2251")
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 tuple. 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)

class Context:
    def __init__(self, dim):
        self.dim = dim
        self.original_size = None

ctx = Context(dim=1)
x = torch.randn(2, 3, 4, 5)

ARGS = {
    "ctx": ctx,
    "x": x,
}
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 tuple — a tuple output has no array shape of its own; none is 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
unflatten_all_but_nth_dim Ran
ran; our contract draft was wrong, not the code
magics-lab/uhop/layers.py
code served (permissive licence) · get_code("bdec64ff3f52a1cc")
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 tuple. 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)

class Context:
    def __init__(self):
        self.original_size = (3, 2, 4, 5)
        self.dim = 1

ctx = Context()
x = torch.randn(2, 3, 4, 5)

ARGS = {
    "ctx": ctx,
    "x": x,
}
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 tuple — a tuple output has no array shape of its own; none is 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
sqdiff Not yet run
unverified (harvested, no recorded run)
magics-lab/uhop/memory_retrieval_max_loss.py
code served (permissive licence) · get_code("827fc074dd33abc1")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 4 the same month, 0 later) and 3 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
flatten_all_but_nth_dim
brick of this paper's assembly: helper
3 other papers
2 dated earlier, 1 the same month · 2 only as an assembly brick
1902.06292 (2019-02)
ProtoAttend: Attention-Based Prototypical Learning
2309.12673 (2023-09)
On Sparse Modern Hopfield Model
2404.03828 (2024-04)
Outlier-Efficient Hopfield Layers for Large Transformer-Based Models
unflatten_all_but_nth_dim
brick of this paper's assembly: helper
3 other papers
2 dated earlier, 1 the same month · 2 only as an assembly brick
1902.06292 (2019-02)
ProtoAttend: Attention-Based Prototypical Learning
2309.12673 (2023-09)
On Sparse Modern Hopfield Model
2404.03828 (2024-04)
Outlier-Efficient Hopfield Layers for Large Transformer-Based Models
Sparsemax
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 the same month · 2 only as an assembly brick
2309.12673 (2023-09)
On Sparse Modern Hopfield Model
2404.03828 (2024-04)
Outlier-Efficient Hopfield Layers for Large Transformer-Based Models
SparsemaxFunction
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 the same month · 2 only as an assembly brick
2309.12673 (2023-09)
On Sparse Modern Hopfield Model
2404.03828 (2024-04)
Outlier-Efficient Hopfield Layers for Large Transformer-Based Models

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

We propose a two-stage memory retrieval dynamics for modern Hopfield models, termed U-Hop, with enhanced memory capacity. Our key contribution is a learnable feature map Φ which transforms the Hopfield energy function into kernel space. This transformation ensures convergence between the local minima of energy and the fixed points of retrieval dynamics within the kernel space. Consequently, the kernel norm induced by Φ serves as a novel similarity measure. It utilizes the stored memory patterns as learning data to enhance memory capacity across all modern Hopfield models. Specifically, we accomplish this by constructing a separation loss L Φ that separates the local minima of kernelized energy by separating stored memory patterns in kernel space. Methodologically, U-Hop memory retrieval process consists of: (Stage I) minimizing separation loss for a more uniformed memory (local minimum) distribution, followed by (Stage II) standard Hopfield energy minimization for memory retrieval. This results in a significant reduction of possible metastable states in the Hopfield energy function, thus enhancing memory capacity by preventing memory confusion. Empirically, with real-world datasets, we demonstrate that U-Hop outperforms all existing modern Hopfield models and SOTA similarity measures, achieving substantial improvements in both associative memory retrieval and deep learning tasks. Code is available at GitHub; future updates are on arXiv. 1

For agents

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

get_harvested_code_for_paper("2404.03827")
get_code_for_paper("2404.03827")
have("2404.03827")

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

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

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

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

Connect an agent — have() is free.