SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2206.01646 · ICML · 2023

Integrating Prior Knowledge in Contrastive Learning with Kernel

Benoit Dufumier, Carlo Barbano, Robin Louiset, Edouard Duchesnay, Pietro Gori

arXiv · PDF · Open in the Atlas

Code that ran

6 of 6 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 3 have no contract verdict; 3 failures of our instrument; 0 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/2206.01646.json · badge: /api/ran/2206.01646.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
duplums/contrastive-decoupled-uniformity canonical (classifier label)
classifier basis: classifier_2025
4 ran · 0 no recorded run
copy not recorded community
not in the paper's declared repositories
2 ran · 0 no recorded run
FunctionStatusWhere it lives
CosineKernel Ran
ran on a synthesized input
duplums/contrastive-decoupled-uniformity/src/decoupled_uniformity.py
code served (permissive licence) · get_code("6cf407f3f9817042")
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 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
import torch.nn.functional as func

class CosineKernel(nn.Module):
    """Compute cosine similarity between samples in X and Y.
       Cosine similarity, or the cosine kernel, computes similarity as the
       normalized dot product of X and Y:
           K(X, Y) = <X, Y> / (||X||*||Y||)
       On L2-normalized data, this function is equivalent to linear_kernel.
       Parameters
       ----------
       X : ndarray or sparse array, shape: (n_samples_X, n_features)
           Input data.

       Y : ndarray or sparse array, shape: (n_samples_Y, n_features)
           Input data. If ``None``, the output will be the pairwise
           similarities between all samples in ``X``.
        Returns
        -------
        kernel matrix : array
            An array with shape (n_samples_X, n_samples_Y).
    """

    def forward(self, X, Y):
        X_norm = func.normalize(X, p=2, dim=-1)
        if Y is X:
            Y_norm = X_norm
        else:
            Y_norm = func.normalize(Y, p=2, dim=-1)
        K = X_norm @ Y_norm.T
        return K


INIT_ARGS = {}

ARGS = {
    'X': torch.randn(2, 4),
    'Y': torch.randn(3, 4),
}

if __name__ == '__main__':
    kernel = CosineKernel(**INIT_ARGS)
    output = kernel(**ARGS)
    print("Output shape:", output.shape)
    print("Output:\n", output)
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 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
DecoupledUniformityLoss Ran
ran on a synthesized input · constructed an object; no result was computed
duplums/contrastive-decoupled-uniformity/src/decoupled_uniformity.py
code served (permissive licence) · get_code("b0a042ebf77aa022")
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, DecoupledUniformityLoss: 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
import numpy as np

torch.manual_seed(0)

ARGS = {
    'kernel': 'cosine',
    'lambda_': 0.01,
    't': 2.0,
    'sigma': 1.0
}
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 DecoupledUniformityLoss — 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 DecoupledUniformityLoss 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
RBFKernel Ran
ran on a synthesized input · constructed an object; no result was computed
duplums/contrastive-decoupled-uniformity/src/decoupled_uniformity.py
code served (permissive licence) · get_code("f9d3a517dc83b040")
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, RBFKernel: 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
import numpy as np

torch.manual_seed(0)

# Create small sample tensors for X and Y
# X: (n_samples_X=2, n_features=4)
# Y: (n_samples_Y=3, n_features=4)
X = torch.randn(2, 4, dtype=torch.float32)
Y = torch.randn(3, 4, dtype=torch.float32)

# gamma: a small positive float for the RBF kernel
gamma = 0.5

ARGS = {
    "gamma": gamma,
}
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 RBFKernel — 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 RBFKernel 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
accuracy Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
this paper's copy was not recorded; identical code first harvested from songweige/contrastive-learning-with-non-semantic-negatives
pointer only · get_code("131a82fd65128218")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

train Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
duplums/contrastive-decoupled-uniformity/main_lincls.py
code served (permissive licence) · get_code("cec655a124623d68")
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 float, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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

torch.manual_seed(0)

# Create a minimal model that accepts images and outputs logits
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Linear(4, 10)  # 10 classes for top-5 accuracy
    
    def forward(self, x):
        return self.fc(x)

# Create a minimal train loader with 3 batches
train_loader = [
    (torch.randn(2, 4), torch.randint(0, 10, (2,))),
    (torch.randn(2, 4), torch.randint(0, 10, (2,))),
    (torch.randn(2, 4), torch.randint(0, 10, (2,))),
]

# Create model, criterion, and optimizer
model = SimpleModel()
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)

# Create args object with required attributes
class Args:
    def __init__(self):
        self.gpu = None
        self.print_freq = 1

args = Args()

ARGS = {
    'train_loader': train_loader,
    'model': model,
    'criterion': criterion,
    'optimizer': optimizer,
    'epoch': 0,
    'args': args,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (call:AssertionError)
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
validate Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
this paper's copy was not recorded; identical code first harvested from songweige/contrastive-learning-with-non-semantic-negatives
pointer only · get_code("63ce1d5edf8fb0a0")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

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

FunctionAlso present inEarliest-datedOthers named
accuracy 116 other papers
44 dated earlier, 7 the same month, 61 later, 4 same year, order not determinable · 8 only as an assembly brick
1502.03044 (2015-02)
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
1610.05820 (2016-10)
Membership Inference Attacks Against Machine Learning Models
1905.03696 (2019-05)
HAWQ: Hessian AWare Quantization of Neural Networks with Mixed-Precision
and 113 more not named here
validate 14 other papers
10 dated earlier, 1 the same month, 3 later
1706.02677 (2017-06)
Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour
1911.12207 (2019-11)
Orthogonal Convolutional Neural Networks
2003.04297 (2020-03)
Improved Baselines with Momentum Contrastive Learning
and 11 more not named here

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

Data augmentation is a crucial component in unsupervised contrastive learning (CL). It determines how positive samples are defined and, ultimately, the quality of the learnt representation. In this work, we open the door to new perspectives for CL by integrating prior knowledge, given either by generative models-viewed as prior representations-or weak attributes in the positive and negative sampling. To this end, we use kernel theory to propose a novel loss, called decoupled uniformity, that i) allows the integration of prior knowledge and ii) removes the negative-positive coupling in the original InfoNCE loss. We draw a connection between contrastive learning and conditional mean embedding theory to derive tight bounds on the downstream classification loss. In an unsupervised setting, we empirically demonstrate that CL benefits from generative models to improve its representation both on natural and medical images. In a weakly supervised scenario, our framework outperforms other unconditional and conditional CL approaches. Source code is available at this https URL.

For agents

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

get_harvested_code_for_paper("2206.01646")
get_code_for_paper("2206.01646")
have("2206.01646")

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

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

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

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

Connect an agent — have() is free.