SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2203.15243 · CVPR · 2022

Fine-tuning Image Transformers using Learnable Memory

Mark Sandler, Max Vladymyrov, Andrey Zhmoginov, Andrew Jackson

arXiv · PDF · Open in the Atlas

Code that ran

3 of 4 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 1 failure of our instrument; 1 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/2203.15243.json · badge: /api/ran/2203.15243.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
necrashter/transformers-learnable-memory community
Papers with Code archive
3 ran · 1 no recorded run
FunctionStatusWhere it lives
MultiEmbeddings Ran
ran on a synthesized input · constructed an object; no result was computed
necrashter/transformers-learnable-memory/vit.py
code served (permissive licence) · get_code("5102eaa1fc2675b3")
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, MultiEmbeddings: 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
from torch import nn
import math

torch.manual_seed(0)

# Create a minimal config class that matches what MultiEmbeddings expects
class MinimalConfig:
    def __init__(self):
        self.patch_size = 2
        self.hidden_size = 4

# Create a minimal PatchEmbeddings mock
class MinimalPatchEmbeddings(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.hidden_size = hidden_size
        self.projection = nn.Linear(12, hidden_size)  # 3 channels * 2*2 patch = 12
    
    def forward(self, pixel_values, interpolate_pos_encoding=False):
        batch_size, num_channels, height, width = pixel_values.shape
        # Create patch embeddings: (batch, num_patches, hidden_size)
        # For a 4x4 image with patch_size=2, we get 2x2=4 patches
        num_patches = (height // 2) * (width // 2)
        return torch.randn(batch_size, num_patches, self.hidden_size)

# Create a minimal ViTEmbeddings base
class MinimalViTEmbeddings(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = MinimalConfig()
        self.cls_token = nn.Parameter(torch.randn(1, 1, 4))
        self.mask_token = nn.Parameter(torch.randn(1, 1, 4))
        self.patch_embeddings = MinimalPatchEmbeddings(hidden_size=4)
        # Position embeddings: [1, num_patches + 1, hidden_size]
        # 4 patches + 1 cls token = 5 total
        self.position_embeddings = nn.Parameter(torch.randn(1, 5, 4))
        self.dropout = nn.Dropout(0.1)

# Create the base ViTEmbeddings instance
base = MinimalViTEmbeddings()

# Define ARGS for MultiEmbeddings.__init__
ARGS = {
    "base": base
}
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 MultiEmbeddings — 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 MultiEmbeddings 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
SelfAttentionWithMemory Ran
ran on a synthesized input · constructed an object; no result was computed
necrashter/transformers-learnable-memory/vit.py
code served (permissive licence) · get_code("761fa038f12c7533")
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, SelfAttentionWithMemory: 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
from torch import nn
import math

torch.manual_seed(0)

# Create a minimal base ViTSelfAttention-like object
class MinimalViTSelfAttention(nn.Module):
    def __init__(self, hidden_size=4, num_attention_heads=2):
        super().__init__()
        self.num_attention_heads = num_attention_heads
        self.attention_head_size = hidden_size // num_attention_heads
        self.all_head_size = hidden_size
        
        self.query = nn.Linear(hidden_size, hidden_size)
        self.key = nn.Linear(hidden_size, hidden_size)
        self.value = nn.Linear(hidden_size, hidden_size)
        self.dropout = nn.Dropout(0.1)

# Instantiate base attention module
base_attention = MinimalViTSelfAttention(hidden_size=4, num_attention_heads=2)
patch_count = 9

ARGS = {
    "base": base_attention,
    "patch_count": patch_count,
}
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 SelfAttentionWithMemory — 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 SelfAttentionWithMemory 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
build_attention_mask Ran
ran; our contract draft was wrong, not the code
necrashter/transformers-learnable-memory/vit.py
code served (permissive licence) · get_code("90b7bb767752b07d")
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 (1, 8, 14) 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 math

torch.manual_seed(0)

# The function takes:
# - patches: int
# - memory_tokens_list: list
# - extension: bool (optional, default False)

# Looking at the function body:
# - patches is used as an integer for indexing
# - memory_tokens_list is iterated over, each element is an integer (memory_tokens)
# - extension is a boolean controlling conditional logic
# - The function computes: class_tokens = len(memory_tokens_list) + 1
#   and uses patches, class_tokens for tensor indexing

ARGS = {
    "patches": 4,
    "memory_tokens_list": [2, 3, 1],
    "extension": 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 Tensor, ndim 3, dtype family float, shape (1, 8, 14) — shape (1, 8, 14) 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
MemoryCapableViT Not yet run
unverified (harvested, no recorded run)
necrashter/transformers-learnable-memory/vit.py
code served (permissive licence) · get_code("c1dc9aaea3681853")
How it ran

no invocation recorded.

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, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 4 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.

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 this paper we propose augmenting Vision Transformer models with learnable memory tokens. Our approach allows the model to adapt to new tasks, using few parameters, while optionally preserving its capabilities on previously learned tasks. At each layer we introduce a set of learnable embedding vectors that provide contextual information useful for specific datasets. We call these "memory tokens". We show that augmenting a model with just a handful of such tokens per layer significantly improves accuracy when compared to conventional head-only fine-tuning, and performs only slightly below the significantly more expensive full fine-tuning. We then propose an attention-masking approach that enables extension to new downstream tasks, with a computation reuse. In this setup in addition to being parameters efficient, models can execute both old and new tasks as a part of single inference at a small incremental cost.

For agents

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

get_harvested_code_for_paper("2203.15243")
get_code_for_paper("2203.15243")
have("2203.15243")

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

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

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

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

Connect an agent — have() is free.