SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2112.09118 · 2021

Unsupervised Dense Information Retrieval with Contrastive Learning

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 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; 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/2112.09118.json · badge: /api/ran/2112.09118.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
nthakur20/income community (classifier label)
classifier basis not recorded on the link
4 ran · 1 no recorded run
FunctionStatusWhere it lives
PassagePreprocessingFn Ran
ran on a synthesized input
nthakur20/income/income/jpq/preprocess.py
code served (permissive licence) · get_code("0ffcad8ea0548ac6")
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.nn as nn

class MockTokenizer:
    def encode(self, text, add_special_tokens=True, max_length=512, truncation=True):
        # Return a list of token IDs
        # Simulate tokenization: split text into words and map to IDs
        tokens = text.split()
        token_ids = [101] + [i + 1000 for i in range(len(tokens))] + [102]  # [CLS] + tokens + [SEP]
        if truncation and len(token_ids) > max_length:
            token_ids = token_ids[:max_length]
        return token_ids

class MockArgs:
    def __init__(self):
        self.max_doc_character = 100
        self.max_seq_length = 16

# Create mock objects
torch.manual_seed(0)

args = MockArgs()
tokenizer = MockTokenizer()
line = "passage_001\tThis is a test passage with some sample text content for processing"

ARGS = {
    "args": args,
    "line": line,
    "tokenizer": tokenizer
}
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
get_collate_function Ran
ran on a synthesized input
nthakur20/income/income/jpq/dataset.py
code served (permissive licence) · get_code("a9a03792761f628c")
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 torch

torch.manual_seed(0)

def pack_tensor_2D(lstlst, default, dtype, length=None):
    batch_size = len(lstlst)
    length = length if length is not None else max((len(l) for l in lstlst))
    tensor = default * torch.ones((batch_size, length), dtype=dtype)
    for i, l in enumerate(lstlst):
        tensor[i, :len(l)] = torch.tensor(l, dtype=dtype)
    return tensor

def get_collate_function(max_seq_length):

    def collate_function(batch):
        input_ids = [x['input_ids'] for x in batch]
        attention_mask = [x['attention_mask'] for x in batch]
        data = {'input_ids': pack_tensor_2D(input_ids, default=1, dtype=torch.int64, length=None), 'attention_mask': pack_tensor_2D(attention_mask, default=0, dtype=torch.int64, length=None)}
        ids = [x['id'] for x in batch]
        return (data, ids)
    return collate_function

ARGS = {
    'max_seq_length': 128
}
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
pack_tensor_2D Ran
ran on a synthesized input
nthakur20/income/income/jpq/dataset.py
code served (permissive licence) · get_code("7f738a55dde7b691")
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)

# lstlst: a list of lists of numbers (variable lengths)
lstlst = [
    [1.0, 2.0, 3.0],
    [4.0, 5.0]
]

# default: a scalar value to use for padding
default = 0.0

# dtype: torch data type
dtype = torch.float32

# length: optional maximum length (can be None or an integer)
length = None

ARGS = {
    "lstlst": lstlst,
    "default": default,
    "dtype": dtype,
    "length": length
}
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
pad_input_ids Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
nthakur20/income/income/jpq/preprocess.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from fengranMark/QRACDR, is pointer only (licence: NONE) · get_code("b201d8d93b242b70")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from fengranMark/QRACDR, 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.

multi_file_process Not yet run
unverified (harvested, no recorded run)
nthakur20/income/income/jpq/preprocess.py
code served (permissive licence) · get_code("7cc208c6b8263844")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 1 later) and 2 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
pad_input_ids 2 other papers
1 dated earlier, 1 later
2110.05789 (2021-10)
Learning Discrete Representations via Constrained Clustering for Effective and Efficient Dense Retrieval
2607.08540 (2026-07)
Improving Ad-hoc Search Effectiveness for Conversational Information Retrieval via Model Merging
get_collate_function 1 other paper
1 dated earlier
2110.05789 (2021-10)
Learning Discrete Representations via Constrained Clustering for Effective and Efficient Dense Retrieval
pack_tensor_2D 1 other paper
1 dated earlier
2110.05789 (2021-10)
Learning Discrete Representations via Constrained Clustering for Effective and Efficient Dense Retrieval

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

Recently, information retrieval has seen the emergence of dense retrievers, using neural networks, as an alternative to classical sparse methods based on term-frequency. These models have obtained state-of-the-art results on datasets and tasks where large training sets are available. However, they do not transfer well to new applications with no training data, and are outperformed by unsupervised term-frequency methods such as BM25. In this work, we explore the limits of contrastive learning as a way to train unsupervised dense retrievers and show that it leads to strong performance in various retrieval settings. On the BEIR benchmark our unsupervised model outperforms BM25 on 11 out of 15 datasets for the Recall@100. When used as pre-training before fine-tuning, either on a few thousands in-domain examples or on the large MS~MARCO dataset, our contrastive model leads to improvements on the BEIR benchmark. Finally, we evaluate our approach for multi-lingual retrieval, where training data is even scarcer than for English, and show that our approach leads to strong unsupervised performance. Our model also exhibits strong cross-lingual transfer when fine-tuned on supervised English data only and evaluated on low resources language such as Swahili. We show that our unsupervised models can perform cross-lingual retrieval between different scripts, such as retrieving English documents from Arabic queries, which would not be possible with term matching methods.

For agents

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

get_harvested_code_for_paper("2112.09118")
get_code_for_paper("2112.09118")
have("2112.09118")

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

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

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

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

Connect an agent — have() is free.