SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2010.03403 · 2020

Universal Weighting Metric Learning for Cross-Modal Matching

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 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 3 have no contract verdict; 6 failures of our instrument; 2 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/2010.03403.json · badge: /api/ran/2010.03403.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
wayne980/PolyLoss canonical (classifier label)
classifier basis: census
9 ran · 2 no recorded run
FunctionStatusWhere it lives
EncoderImage Ran
ran on a synthesized input
wayne980/PolyLoss/model.py
code served (permissive licence) · get_code("07c90e643974e90d")
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 EncoderImagePrecomp. 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 collections import OrderedDict

torch.manual_seed(0)

# Define arguments for the EncoderImage function
ARGS = {
    'data_name': 'coco',
    'img_dim': 4,
    'embed_size': 3,
    'precomp_enc_type': 'basic',
    'no_imgnorm': False
}
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 EncoderImagePrecomp — a EncoderImagePrecomp output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a EncoderImagePrecomp 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
collate_fn Ran
ran on a synthesized input
wayne980/PolyLoss/data.py
code served (permissive licence) · get_code("eb35209092068c75")
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
import torch.utils.data as data

torch.manual_seed(0)

# Build sample data: list of (image, caption, id, img_id) tuples
# The function expects each caption to be a tensor with variable length
sample_data = [
    (
        torch.randn(3, 256, 256),  # image: (3, 256, 256)
        torch.tensor([1, 2, 3, 4, 5]),  # caption: variable length tensor
        "id_0",  # id
        "img_id_0"  # img_id
    ),
    (
        torch.randn(3, 256, 256),  # image: (3, 256, 256)
        torch.tensor([6, 7, 8]),  # caption: shorter, variable length
        "id_1",  # id
        "img_id_1"  # img_id
    ),
]

ARGS = {
    "data": sample_data
}
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
deserialize_vocab Ran
ran; our contract draft was wrong, not the code
wayne980/PolyLoss/vocab.py
code served (permissive licence) · get_code("cdee6932aa05022e")
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 Vocabulary. 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 json
import tempfile
import os

# Create a temporary directory and file for the vocabulary
temp_dir = tempfile.mkdtemp()
vocab_file = os.path.join(temp_dir, "vocab.json")

# Create a sample vocabulary dictionary
vocab_data = {
    "word2idx": {
        "<unk>": 0,
        "hello": 1,
        "world": 2,
        "python": 3
    },
    "idx2word": {
        "0": "<unk>",
        "1": "hello",
        "2": "world",
        "3": "python"
    },
    "idx": 4
}

# Write the vocabulary to the temporary file
with open(vocab_file, 'w') as f:
    json.dump(vocab_data, f)

ARGS = {
    "src": vocab_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Vocabulary — a Vocabulary output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Vocabulary 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
from_txt Ran
ran; our contract draft was wrong, not the code
wayne980/PolyLoss/vocab.py
code served (permissive licence) · get_code("ef05dda21c1cc726")
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 list, ndim 1, 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 tempfile
import os

# Create a temporary text file with some caption data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write(b"caption one\n".decode())
temp_file.write(b"caption two\n".decode())
temp_file.write(b"caption three\n".decode())
temp_file.close()

# Create the ARGS dictionary
ARGS = {
    'txt': temp_file.name
}

# Clean up will happen after function execution
# Note: In production, you'd want to clean up with os.unlink(temp_file.name)
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — 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_loaders Ran
ran; our contract draft was wrong, not the code
wayne980/PolyLoss/data.py
code served (permissive licence) · get_code("a90b1e5a707539c5")
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, ndim 1, 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 numpy as np
import nltk
from nltk.tokenize import word_tokenize
import tempfile
import os

torch.manual_seed(0)

# Create a minimal vocab class that acts like a callable dictionary
class Vocab:
    def __init__(self):
        self.word2idx = {
            '<start>': 0,
            '<end>': 1,
            'hello': 2,
            'world': 3,
            'test': 4,
            'caption': 5,
        }
    
    def __call__(self, word):
        return self.word2idx.get(word, 6)

# Create a minimal options class
class Opt:
    def __init__(self, data_path):
        self.data_path = data_path

# Create temporary directory with test data files
temp_dir = tempfile.mkdtemp()
data_name = "test_data"
data_path = os.path.join(temp_dir, data_name)
os.makedirs(data_path, exist_ok=True)

# Create train caps file
with open(os.path.join(data_path, 'train_caps.txt'), 'wb') as f:
    f.write(b'hello world\n')
    f.write(b'test caption\n')

# Create train images file (2 images, 3 features each)
train_images = np.random.rand(2, 3).astype(np.float32)
np.save(os.path.join(data_path, 'train_ims.npy'), train_images)

# Create dev caps file
with open(os.path.join(data_path, 'dev_caps.txt'), 'wb') as f:
    f.write(b'hello world\n')
    f.write(b'test caption\n')

# Create dev images file
dev_images = np.random.rand(2, 3).astype(np.float32)
np.save(os.path.join(data_path, 'dev_ims.npy'), dev_images)

# Instantiate the components
vocab = Vocab()
opt = Opt(temp_dir)

ARGS = {
    'data_name': data_name,
    'vocab': vocab,
    'batch_size': 2,
    'workers': 0,
    'opt': opt,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, 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: none by the harness; any seed is in the setup block
get_precomp_loader Ran
ran on a synthesized input
wayne980/PolyLoss/data.py
code served (permissive licence) · get_code("329698e5a722c7d4")
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 DataLoader. 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.utils.data as data
import nltk
import numpy as np
from unittest.mock import Mock, MagicMock
import tempfile
import os

torch.manual_seed(0)

# Create a simple vocab class that acts like a callable
class SimpleVocab:
    def __init__(self):
        self.word_to_idx = {
            '<start>': 0,
            '<end>': 1,
            'hello': 2,
            'world': 3,
            'this': 4,
            'is': 5,
            'a': 6,
            'test': 7,
        }
    
    def __call__(self, word):
        return self.word_to_idx.get(word, 8)

# Create temporary directory with mock data files
temp_dir = tempfile.mkdtemp()

# Create mock caption file
with open(os.path.join(temp_dir, 'train_caps.txt'), 'wb') as f:
    f.write(b'hello world\n')
    f.write(b'this is a test\n')

# Create mock image numpy file
images = np.random.rand(2, 3, 256, 256).astype(np.float32)
np.save(os.path.join(temp_dir, 'train_ims.npy'), images)

# Create simple opt object (not actually used in the function body)
opt = {}

vocab = SimpleVocab()

ARGS = {
    'data_path': temp_dir,
    'data_split': 'train',
    'vocab': vocab,
    'opt': opt,
    'batch_size': 2,
    'shuffle': False,
    'num_workers': 0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
l1norm Ran
ran; our contract draft was wrong, not the code
wayne980/PolyLoss/model.py
code served (permissive licence) · get_code("a1e099b0f700be6a")
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 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 as nn

torch.manual_seed(0)

# Create a small tensor to normalize
# Shape: (2, 4) - batch size 2, dimension 4
X = torch.randn(2, 4)

# The function signature is: l1norm(X, dim, eps=1e-08)
# X: tensor to normalize
# dim: dimension along which to compute L1 norm
# eps: small constant to avoid division by zero

ARGS = {
    "X": X,
    "dim": 1,
    "eps": 1e-08
}
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 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
l2norm Ran
ran; our contract draft was wrong, not the code
wayne980/PolyLoss/model.py
code served (permissive licence) · get_code("fe7440ba7662dcfc")
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 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)

# Create a small tensor to normalize
# Shape: (2, 4) - 2 samples, 4 features
X = torch.randn(2, 4)

# The function performs L2 normalization along a specified dimension
# We'll normalize along dimension 1 (features for each sample)
dim = 1

# eps parameter has a default value, but we can also specify it explicitly
eps = 1e-08

ARGS = {
    "X": X,
    "dim": dim,
    "eps": eps
}
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 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
softmax Ran
ran; our contract draft was wrong, not the code
wayne980/PolyLoss/evaluation.py
code served (permissive licence) · get_code("652f07c5ff410713")
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 ndarray, 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 numpy as np

# Create a small 2D array for testing
X = np.array([[1.0, 2.0, 3.0, 4.0],
              [5.0, 6.0, 7.0, 8.0]])

# axis parameter - compute softmax along axis 1 (across columns for each row)
axis = 1

ARGS = {
    "X": X,
    "axis": axis
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, 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
build_vocab Not yet run
unverified (harvested, no recorded run)
wayne980/PolyLoss/vocab.py
code served (permissive licence) · get_code("7b9b11b5023a6ca4")
How it ran

no invocation recorded.

encode_data Not yet run
unverified (harvested, no recorded run)
wayne980/PolyLoss/evaluation.py
code served (permissive licence) · get_code("9fb1dc913236e6d2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 10 are also present in other papers whose code we hold (10 with at least one paper dated earlier, 0 the same month, 3 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
l1norm 12 other papers
1 dated earlier, 11 later · 3 only as an assembly brick
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching
2101.01368 (2021-01)
Similarity Reasoning and Filtration for Image-Text Matching
2303.12419 (2023-03)
BiCro: Noisy Correspondence Rectification for Multi-modality Data via Bi-directional Cross-modal Similarity Consistency
and 9 more not named here
l2norm 12 other papers
2 dated earlier, 10 later · 2 only as an assembly brick
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching
1904.01310 (2019-04)
DM-GAN: Dynamic Memory Generative Adversarial Networks for Text-to-Image Synthesis
2109.05433 (2021-09)
Are Gender-Neutral Queries Really Gender-Neutral? Mitigating Gender Bias in Image Search
and 9 more not named here
from_txt 3 other papers
2 dated earlier, 1 later
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching
1806.10348 (2018-06)
Learning Visually-Grounded Semantics from Contrastive Adversarial Samples
2506.23502 (2025-06)
LLM-enhanced Action-aware Multi-modal Prompt Tuning for Image-Text Matching
EncoderImage 1 other paper
1 dated earlier
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching
build_vocab 1 other paper
1 dated earlier
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching
collate_fn 1 other paper
1 dated earlier
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching
deserialize_vocab 1 other paper
1 dated earlier
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching
encode_data 1 other paper
1 dated earlier
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching
get_loaders 1 other paper
1 dated earlier
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching
softmax 1 other paper
1 dated earlier
1803.08024 (2018-03)
Stacked Cross Attention for Image-Text Matching

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

Cross-modal matching has been a highlighted research topic in both vision and language areas. Learning appropriate mining strategy to sample and weight informative pairs is crucial for the cross-modal matching performance. However, most existing metric learning methods are developed for unimodal matching, which is unsuitable for cross-modal matching on multimodal data with heterogeneous features. To address this problem, we propose a simple and interpretable universal weighting framework for cross-modal matching, which provides a tool to analyze the interpretability of various loss functions. Furthermore, we introduce a new polynomial loss under the universal weighting framework, which defines a weight function for the positive and negative informative pairs respectively. Experimental results on two image-text matching benchmarks and two video-text matching benchmarks validate the efficacy of the proposed method.

For agents

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

get_harvested_code_for_paper("2010.03403")
get_code_for_paper("2010.03403")
have("2010.03403")

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

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

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

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

Connect an agent — have() is free.