SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2003.02546 · 2020

Embedding Expansion: Augmentation in Embedding Space for Deep Metric Learning

arXiv · PDF · 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; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-21; 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/2003.02546.json · badge: /api/ran/2003.02546.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
clovaai/embedding-expansion canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
puneesh00/loop community (classifier label)
classifier basis not recorded on the link
6 ran · 2 no recorded run
FunctionStatusWhere it lives
concat Ran
ran on a synthesized input
puneesh00/loop/loss/embedding_aug_mx.py
code served (permissive licence) · get_code("a645a2dfd75685c5")
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 numpy as np

torch.manual_seed(0)

# Create a mock framework object F that implements the required methods
class MockFramework:
    def array(self, data):
        """Convert list to torch tensor"""
        return torch.tensor(data, dtype=torch.long)
    
    class contrib:
        @staticmethod
        def boolean_mask(tensor, mask):
            """Apply boolean mask to tensor"""
            return tensor[mask]

# Construct arguments
n = 2
F = MockFramework()

# X1: shape (n, 4) - first feature matrix
X1 = torch.randn(n, 4, dtype=torch.float32)

# X2: shape (n, 3) - second feature matrix (different dim for distinction)
X2 = torch.randn(n, 3, dtype=torch.float32)

# X1l: shape (n,) - labels for X1
X1l = torch.tensor([0, 1], dtype=torch.long)

# X2l: shape (n,) - labels for X2
X2l = torch.tensor([0, 1], dtype=torch.long)

ARGS = {
    'F': F,
    'X1': X1,
    'X2': X2,
    'X1l': X1l,
    'X2l': X2l
}
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 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
get_embedding_aug Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
clovaai/embedding-expansion/loss/embedding_aug.py
code served (permissive licence) · get_code("70b3555b698a27db")
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 numpy as np

torch.manual_seed(0)

class FakeFramework:
    """Mock framework object that provides L2Normalization and concat methods"""
    
    def L2Normalization(self, x):
        """L2 normalize along dimension 1"""
        # Assuming x is numpy array, normalize each row
        norm = np.linalg.norm(x, axis=1, keepdims=True)
        return x / (norm + 1e-8)
    
    def concat(self, a, b, dim=0):
        """Concatenate two numpy arrays"""
        return np.concatenate([a, b], axis=dim)

# Create small test data
batch_size = 2
embedding_dim = 4
num_classes = 3

# Create embeddings as numpy array (batch_size x embedding_dim)
embeddings = np.random.randn(batch_size, embedding_dim).astype(np.float32)

# Create labels as numpy array (batch_size,)
labels = np.array([0, 1], dtype=np.int64)

# Create the framework object
F = FakeFramework()

# Parameters
num_instance = 4  # Must be even
n_inner_pts = 2
l2_norm = True

ARGS = {
    "F": F,
    "embeddings": embeddings,
    "labels": labels,
    "num_instance": num_instance,
    "n_inner_pts": n_inner_pts,
    "l2_norm": l2_norm
}
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 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
get_lam_lin Ran
ran on a synthesized input
puneesh00/loop/loss/optimum_pts_lin.py
code served (permissive licence) · get_code("238d0e58bf5e2c2a")
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 (4, 3) 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 numpy as np

torch.manual_seed(0)

# Analyze the function: get_lam_lin(A, B, C, kp, k)
# It performs: -C - B * kp - A * k
# This suggests matrix/tensor operations where:
# - A, B, C are likely matrices or tensors
# - kp, k are likely scalars or vectors
# All parameters appear to be used in arithmetic operations

# Create small tensors for testing
A = torch.randn(4, 3)
B = torch.randn(4, 3)
C = torch.randn(4, 3)
kp = torch.tensor(0.5)
k = torch.tensor(0.2)

ARGS = {
    'A': A,
    'B': B,
    'C': C,
    'kp': kp,
    'k': k
}
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 Tensor, ndim 2, dtype family float, shape (4, 3) — shape (4, 3) 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_roots Ran
ran on a synthesized input
puneesh00/loop/loss/optimum_pts.py
code served (permissive licence) · get_code("ad23c83f976df643")
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 numpy as np

torch_seed = 0
np.random.seed(0)

# The function takes 4 numeric parameters (A, B, C, D)
# It performs arithmetic operations on them (multiplication, addition, division, sqrt, arctan)
# So they should be numeric values - floats or numpy scalars/arrays

A = 2.5
B = 1.5
C = 3.0
D = 0.8

ARGS = {
    "A": A,
    "B": B,
    "C": C,
    "D": D,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
getn Ran
ran on a synthesized input
puneesh00/loop/loss/optimum_pts.py
code served (permissive licence) · get_code("4efe9ed220f93e69")
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 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 numpy as np

# Create small numpy arrays for X1 and X2
# X1 and X2 should have shape (rows, columns)
# The function uses einsum with 'ij,ij->j', so both need same shape
# Let's use shape (2, 4) - batch size 2, dimension 4

np.random.seed(0)

X1 = np.random.randn(2, 4).astype(np.float32)
X2 = np.random.randn(2, 4).astype(np.float32)

ARGS = {
    'X1': X1,
    'X2': X2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, 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
normalize Ran
ran on a synthesized input
puneesh00/loop/loss/optimum_pts.py
code served (permissive licence) · get_code("5f68094ff552c59d")
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 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 numpy as np

# Create small numpy arrays with distinct shapes for each parameter
# Shape: (4, 3) - 4 features, 3 samples
X1 = np.random.randn(4, 3).astype(np.float32)
X2 = np.random.randn(4, 3).astype(np.float32)
X3 = np.random.randn(4, 3).astype(np.float32)
X4 = np.random.randn(4, 3).astype(np.float32)

ARGS = {
    "X1": X1,
    "X2": X2,
    "X3": X3,
    "X4": X4,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, 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
point_lin Ran
ran on a synthesized input
puneesh00/loop/loss/optimum_pts_lin.py
code served (permissive licence) · get_code("7be77be876544ef9")
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)

# x1 and x2 are tensors used in element-wise arithmetic operations
# cos is a scalar or tensor used in arithmetic operations
x1 = torch.randn(2, 4)
x2 = torch.randn(2, 4)
cos = torch.randn(1).item()  # scalar value

ARGS = {
    "x1": x1,
    "x2": x2,
    "cos": cos,
}
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
euclidean_dist Not yet run
unverified (harvested, no recorded run)
puneesh00/loop/loss/embedding_aug_mx.py
code served (permissive licence) · get_code("63190af7829635b2")
How it ran

no invocation recorded.

euclidean_dist_alt Not yet run
unverified (harvested, no recorded run)
puneesh00/loop/loss/embedding_aug_mx.py
code served (permissive licence) · get_code("98fc6cdbe46dc59f")
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, 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 9 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-21.

Repositories linked to this paper

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

Abstract

Learning the distance metric between pairs of samples has been studied for image retrieval and clustering. With the remarkable success of pair-based metric learning losses, recent works have proposed the use of generated synthetic points on metric learning losses for augmentation and generalization. However, these methods require additional generative networks along with the main network, which can lead to a larger model size, slower training speed, and harder optimization. Meanwhile, post-processing techniques, such as query expansion and database augmentation, have proposed the combination of feature points to obtain additional semantic information. In this paper, inspired by query expansion and database augmentation, we propose an augmentation method in an embedding space for pair-based metric learning losses, called embedding expansion. The proposed method generates synthetic points containing augmented information by a combination of feature points and performs hard negative pair mining to learn with the most informative feature representations. Because of its simplicity and flexibility, it can be used for existing metric learning losses without affecting model size, training speed, or optimization difficulty. Finally, the combination of embedding expansion and representative metric learning losses outperforms the state-of-the-art losses and previous sample generation methods in both image retrieval and clustering tasks. The implementation is publicly available.

For agents

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

get_harvested_code_for_paper("2003.02546")
get_code_for_paper("2003.02546")
have("2003.02546")

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

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

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

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

Connect an agent — have() is free.