SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2112.11450 · 2021

Max-Margin Contrastive Learning

arXiv · PDF · Open in the Atlas

Code that ran

5 of 12 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; 1 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 1 failure of our instrument; 7 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/2112.11450.json · badge: /api/ran/2112.11450.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
anshulbshah/MMCL canonical (classifier label)
classifier basis not recorded on the link
5 ran · 7 no recorded run
FunctionStatusWhere it lives
accuracy Ran
ran; our contract draft was wrong, not the code
anshulbshah/MMCL/models/losses.py
code served (permissive licence) · get_code("11bc56dd2ecb7644")
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 1, dtype family float, shape (2,) 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)

# The function expects:
# - logits: a tensor with shape (batch_size, num_classes) that supports .topk() and torch.sort()
# - labels: a tensor with shape (batch_size, k) that supports torch.sort()
# - k: an integer for the top-k parameter

batch_size = 2
num_classes = 4
k = 3

# Create logits tensor: (batch_size, num_classes)
logits = torch.randn(batch_size, num_classes)

# Create labels tensor: (batch_size, k) with class indices
# Labels should contain k distinct class indices for each sample
labels = torch.tensor([[0, 1, 2], [1, 2, 3]], dtype=torch.long)

ARGS = {
    "logits": logits,
    "labels": labels,
    "k": k
}
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 1, dtype family float, shape (2,) — shape (2,) 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
compute_kernel Ran
ran on a synthesized input
anshulbshah/MMCL/models/losses.py
code served (permissive licence) · get_code("9498c0875cc30496")
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, 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

torch.manual_seed(0)

# Create small tensors for X and Y
# X: (2, 4) - 2 samples, 4 features
# Y: (3, 4) - 3 samples, 4 features (different first dimension for clarity)
X = torch.randn(2, 4)
Y = torch.randn(3, 4)

ARGS = {
    'X': X,
    'Y': Y,
    'gamma': 0.1,
    'kernel_type': 'rbf'
}
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, 3) — shape (2, 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
compute_kernel_new Ran
ran on a synthesized input
anshulbshah/MMCL/CIFAR100/svm_losses.py
code served (permissive licence) · get_code("5fa7bb56e6e22a54")
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, 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 torch.nn as nn

torch.manual_seed(0)

# X: input tensor of shape (batch_size, feature_dim)
# Y: input tensor of shape (batch_size, feature_dim)
# Both are used in matrix multiplication: torch.mm(X, Y.T)
# So X is (2, 4) and Y is (3, 4) to have distinct dimensions

X = torch.randn(2, 4)
Y = torch.randn(3, 4)
gamma = 0.1

ARGS = {
    "X": X,
    "Y": Y,
    "gamma": gamma,
}
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, 3) — shape (2, 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_lr Ran
ran, honoured the contract we drafted
anshulbshah/MMCL/CIFAR100/linear.py
pointer only (licence: MIT); the stored copy get_code serves, from yjzhang96/UTI-VFI, is pointer only (licence: NONE) · get_code("7337f1f5ff01dcd0")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from yjzhang96/UTI-VFI, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

only_value_error Ran
ran on a synthesized input
anshulbshah/MMCL/myexman/index.py
code served (permissive licence) · get_code("c404ad6b3c3cae86")
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 function. 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 functools
import torch

def simple_converter(value):
    """A simple conversion function that may raise various exceptions."""
    if value < 0:
        raise RuntimeError("Value cannot be negative")
    return value * 2

ARGS = {
    "conv": simple_converter
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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_args Not yet run
unverified (harvested, no recorded run)
anshulbshah/MMCL/myexman/index.py
code served (permissive licence) · get_code("5bd550cf0a598b22")
How it ran

no invocation recorded.

get_dataset Not yet run
unverified (harvested, no recorded run)
anshulbshah/MMCL/CIFAR100/utils.py
code served (permissive licence) · get_code("0b30248ddcadc9b7")
How it ran

no invocation recorded.

none2none Not yet run
unverified (harvested, no recorded run)
anshulbshah/MMCL/myexman/index.py
code served (permissive licence) · get_code("459939c749c8fd3f")
How it ran

no invocation recorded.

pgd_simple_short Not yet run
unverified (harvested, no recorded run)
anshulbshah/MMCL/models/solvers.py
code served (permissive licence) · get_code("54bdbe97f492c455")
How it ran

no invocation recorded.

pgd_with_nesterov Not yet run
unverified (harvested, no recorded run)
anshulbshah/MMCL/models/solvers.py
code served (permissive licence) · get_code("5a39dd9aa51e8d32")
How it ran

no invocation recorded.

pgd_with_nesterov Not yet run
unverified (harvested, no recorded run)
anshulbshah/MMCL/CIFAR100/solvers.py
code served (permissive licence) · get_code("91f52fbcbca3f103")
How it ran

no invocation recorded.

train_val Not yet run
unverified (harvested, no recorded run)
anshulbshah/MMCL/CIFAR100/linear.py
pointer only (licence: MIT); the stored copy get_code serves, from rjiang03/h-scl, is pointer only (licence: NONE) · get_code("8f49bc51cbbd9f64")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from rjiang03/h-scl, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 6 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 1 the same month, 3 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.

FunctionAlso present inEarliest-datedOthers named
get_lr 25 other papers
11 dated earlier, 1 the same month, 12 later, 1 same year, order not determinable · 2 only as an assembly brick
1605.07148 (2016-05)
Backprop KF: Learning Discriminative Deterministic State Estimators
1606.00915 (2016-06)
DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs
1904.01355 (2019-04)
FCOS: Fully Convolutional One-Stage Object Detection
and 22 more not named here
accuracy 3 other papers
2 dated earlier, 1 later
2002.05709 (2020-02)
A Simple Framework for Contrastive Learning of Visual Representations
2104.08984 (2021-04)
Contrastive Learning Improves Model Robustness Under Label Noise
2309.05300 (2023-09)
Decoupling Common and Unique Representations for Multimodal Self-supervised Learning
train_val 2 other papers
2 later
2209.00078 (2022-09)
Supervised Contrastive Learning with Hard Negative Samples
2306.13924 (2023-06)
Structuring Representation Geometry with Rotationally Equivariant Contrastive Learning
get_args 1 other paper
1 dated earlier
2002.05709 (2020-02)
A Simple Framework for Contrastive Learning of Visual Representations
none2none 1 other paper
1 dated earlier
2002.05709 (2020-02)
A Simple Framework for Contrastive Learning of Visual Representations
only_value_error 1 other paper
1 dated earlier
2002.05709 (2020-02)
A Simple Framework for Contrastive Learning of Visual Representations

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

Standard contrastive learning approaches usually require a large number of negatives for effective unsupervised learning and often exhibit slow convergence. We suspect this behavior is due to the suboptimal selection of negatives used for offering contrast to the positives. We counter this difficulty by taking inspiration from support vector machines (SVMs) to present max-margin contrastive learning (MMCL). Our approach selects negatives as the sparse support vectors obtained via a quadratic optimization problem, and contrastiveness is enforced by maximizing the decision margin. As SVM optimization can be computationally demanding, especially in an end-to-end setting, we present simplifications that alleviate the computational burden. We validate our approach on standard vision benchmark datasets, demonstrating better performance in unsupervised representation learning over state-of-the-art, while having better empirical convergence properties.

For agents

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

get_harvested_code_for_paper("2112.11450")
get_code_for_paper("2112.11450")
have("2112.11450")

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

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

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

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

Connect an agent — have() is free.