SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2206.10436 · ICLR · 2022

Transformer-Based Multi-modal Proposal and Re-Rank for Wikipedia Image-Caption Matching

Nicola Messina, Davide Coccomini, Andrea Esuli, Fabrizio Falchi

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 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; 1 failure 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/2206.10436.json · badge: /api/ran/2206.10436.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
towhee-io/towhee community
Papers with Code archive
5 ran · 1 no recorded run
FunctionStatusWhere it lives
TransformerDecoder Ran
ran on a synthesized input · constructed an object; no result was computed
towhee-io/towhee/towhee/models/coformer/transformer.py
code served (permissive licence) · get_code("e8e30cc7f67b29f5")
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, TransformerDecoder: 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
from typing import Optional

torch.manual_seed(0)

# Create a minimal decoder layer that matches the expected interface
class MinimalDecoderLayer(nn.Module):
    def __init__(self, d_model=4):
        super().__init__()
        self.linear = nn.Linear(d_model, d_model)
    
    def forward(self, tgt, memory, tgt_mask=None, memory_mask=None, 
                tgt_key_padding_mask=None, memory_key_padding_mask=None, 
                pos=None, query_pos=None):
        # Process tgt and return it
        return self.linear(tgt)

# Create instances for the arguments
decoder_layer = MinimalDecoderLayer(d_model=4)
num_layers = 2

# Create sample tensors for testing
batch_size = 2
seq_len = 3
d_model = 4

tgt = torch.randn(seq_len, batch_size, d_model)
memory = torch.randn(seq_len, batch_size, d_model)
tgt_mask = None
memory_mask = None
tgt_key_padding_mask = None
memory_key_padding_mask = None
pos = None
query_pos = None

ARGS = {
    "decoder_layer": decoder_layer,
    "num_layers": num_layers,
}
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 TransformerDecoder — 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 TransformerDecoder 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
TransformerDecoderLayer Ran
ran on a synthesized input
towhee-io/towhee/towhee/models/coformer/transformer.py
code served (permissive licence) · get_code("1b28a7326df88e10")
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 Tensor, ndim 3, 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
import torch.nn.functional as F
from typing import Optional

def _get_activation_fn(activation):
    """Return an activation function given a string"""
    if activation == 'relu':
        return F.relu
    if activation == 'gelu':
        return F.gelu
    if activation == 'glu':
        return F.glu
    raise RuntimeError(f'activation should be relu/gelu, not {activation}.')

class TransformerDecoderLayer(nn.Module):
    """
    TransformerDecoderLayer class.
    Args:
        d_model (int): dimension of model
        nhead (int): number of head
        dim_feedforward (int): dimension of feedforward
        dropout (float): dropout
        activation (str): activation
    """

    def __init__(self, d_model, nhead, dim_feedforward=2048, dropout=0.15, activation='relu'):
        super().__init__()
        self.self_attn = nn.MultiheadAttention(d_model, nhead, dropout=dropout)
        self.norm1 = nn.LayerNorm(d_model)
        self.dropout1 = nn.Dropout(dropout)
        self.multihead_attn = nn.MultiheadAttention(d_model, nhead, dropout=dropout)
        self.linear1 = nn.Linear(d_model, dim_feedforward)
        self.dropout = nn.Dropout(dropout)
        self.linear2 = nn.Linear(dim_feedforward, d_model)
        self.norm2 = nn.LayerNorm(d_model)
        self.norm3 = nn.LayerNorm(d_model)
        self.dropout2 = nn.Dropout(dropout)
        self.dropout3 = nn.Dropout(dropout)
        self.activation = _get_activation_fn(activation)

    def with_pos_embed(self, tensor, pos: Optional[torch.Tensor]):
        return tensor if pos is None else tensor + pos

    def forward(self, tgt, memory, tgt_mask: Optional[torch.Tensor]=None, memory_mask: Optional[torch.Tensor]=None, tgt_key_padding_mask: Optional[torch.Tensor]=None, memory_key_padding_mask: Optional[torch.Tensor]=None, pos: Optional[torch.Tensor]=None, query_pos: Optional[torch.Tensor]=None):
        tgt2 = self.norm1(tgt)
        q = k = self.with_pos_embed(tgt2, query_pos)
        tgt2 = self.self_attn(q, k, value=tgt2, attn_mask=tgt_mask, key_padding_mask=tgt_key_padding_mask)[0]
        tgt = tgt + self.dropout1(tgt2)
        tgt2 = self.norm2(tgt)
        tgt2 = self.multihead_attn(query=self.with_pos_embed(tgt2, query_pos), key=self.with_pos_embed(memory, pos), value=memory, attn_mask=memory_mask, key_padding_mask=memory_key_padding_mask)[0]
        tgt = tgt + self.dropout2(tgt2)
        tgt2 = self.norm3(tgt)
        tgt2 = self.linear2(self.dropout(self.activation(self.linear1(tgt2))))
        tgt = tgt + self.dropout3(tgt2)
        return tgt


INIT_ARGS = {
    'd_model': 8,
    'nhead': 2,
    'dim_feedforward': 16,
    'dropout': 0.1,
    'activation': 'relu'
}

ARGS = {
    'tgt': torch.randn(3, 2, 8),
    'memory': torch.randn(5, 2, 8),
    'tgt_mask': None,
    'memory_mask': None,
    'tgt_key_padding_mask': None,
    'memory_key_padding_mask': None,
    'pos': torch.randn(5, 2, 8),
    'query_pos': torch.randn(3, 2, 8)
}

layer = TransformerDecoderLayer(**INIT_ARGS)
output = layer(**ARGS)
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 Tensor, ndim 3, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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)
TransformerEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
towhee-io/towhee/towhee/models/coformer/transformer.py
code served (permissive licence) · get_code("bdcda6c39e35013d")
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, TransformerEncoder: 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
from typing import Optional

torch.manual_seed(0)

# Create a minimal encoder layer that matches the interface expected by TransformerEncoder
class MinimalEncoderLayer(nn.Module):
    def __init__(self, d_model=4):
        super().__init__()
        self.d_model = d_model
        self.linear = nn.Linear(d_model, d_model)
    
    def forward(self, src, src_mask=None, src_key_padding_mask=None, pos=None, num_zeros=None):
        # The layer receives src and optional parameters, processes and returns output
        output = self.linear(src)
        return output

# Create encoder_layer instance
encoder_layer = MinimalEncoderLayer(d_model=4)

# Create input tensor: (batch_size=2, seq_len=3, d_model=4)
src = torch.randn(2, 3, 4)

# Create optional mask tensor
mask = torch.zeros(3, 3, dtype=torch.bool)

# Create optional src_key_padding_mask tensor
src_key_padding_mask = torch.zeros(2, 3, dtype=torch.bool)

# Create optional pos (positional encoding) tensor
pos = torch.randn(2, 3, 4)

# num_zeros is optional
num_zeros = None

ARGS = {
    "encoder_layer": encoder_layer,
    "num_layers": 2,
}
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 TransformerEncoder — 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 TransformerEncoder 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
TransformerEncoderLayer Ran
ran on a synthesized input · constructed an object; no result was computed
towhee-io/towhee/towhee/models/coformer/transformer.py
code served (permissive licence) · get_code("5f606c3ea722baea")
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, TransformerEncoderLayer: 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)

# Small configuration values
d_model = 4
nhead = 2
dim_feedforward = 8
dropout = 0.1
activation = 'relu'

# Create a small batch of input
batch_size = 2
seq_len = 3
src = torch.randn(seq_len, batch_size, d_model)

# Optional positional embeddings (same shape as src)
pos = torch.randn(seq_len, batch_size, d_model)

# Optional masks
src_mask = None
src_key_padding_mask = None

# Optional num_zeros parameter
num_zeros = None

ARGS = {
    'd_model': d_model,
    'nhead': nhead,
    'dim_feedforward': dim_feedforward,
    'dropout': dropout,
    'activation': activation,
}
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 TransformerEncoderLayer — 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 TransformerEncoderLayer 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
towhee-io/towhee/towhee/models/coformer/transformer.py
code served (permissive licence) · get_code("695bfb488e490407")
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 torch
import torch.nn as nn
import copy

torch.manual_seed(0)

# Create a simple module to be cloned
class SimpleModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Construct the module and number of clones
module = SimpleModule()
n = 5

ARGS = {
    "module": module,
    "n": n
}
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
Transformer Not yet run
unverified (harvested, no recorded run)
towhee-io/towhee/towhee/models/coformer/transformer.py
code served (permissive licence) · get_code("12a4f89ae433d0da")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 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 6 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-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

With the increased accessibility of web and online encyclopedias, the amount of data to manage is constantly increasing. In Wikipedia, for example, there are millions of pages written in multiple languages. These pages contain images that often lack the textual context, remaining conceptually floating and therefore harder to find and manage. In this work, we present the system we designed for participating in the Wikipedia Image-Caption Matching challenge on Kaggle, whose objective is to use data associated with images (URLs and visual data) to find the correct caption among a large pool of available ones. A system able to perform this task would improve the accessibility and completeness of multimedia content on large online encyclopedias. Specifically, we propose a cascade of two models, both powered by the recent Transformer model, able to efficiently and effectively infer a relevance score between the query image data and the captions. We verify through extensive experimentation that the proposed two-model approach is an effective way to handle a large pool of images and captions while maintaining bounded the overall computational complexity at inference time. Our approach achieves remarkable results, obtaining a normalized Discounted Cumulative Gain (nDCG) value of 0.53 on the private leaderboard of the Kaggle challenge.

For agents

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

get_harvested_code_for_paper("2206.10436")
get_code_for_paper("2206.10436")
have("2206.10436")

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

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

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

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

Connect an agent — have() is free.