SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2204.00185 · 2022

Distill-VQ: Learning Retrieval Oriented Vector Quantization By Distilling Knowledge from Dense Embeddings

arXiv · PDF · Open in the Atlas

Code that ran

6 of 8 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, 1 violated it and 5 have no contract verdict; 0 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/2204.00185.json · badge: /api/ran/2204.00185.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
staoxiao/libvq canonical (classifier label)
classifier basis not recorded on the link
6 ran · 2 no recorded run
FunctionStatusWhere it lives
count_line Ran
ran on a synthesized input
staoxiao/libvq/LibVQ/dataset/preprocess.py
code served (permissive licence) · get_code("e53871dceb16e43e")
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 int, ndim 0, dtype family int, shape () 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 tempfile
import os

# Create a temporary file with some lines of text
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt') as f:
    temp_path = f.name
    f.write("line 1\n")
    f.write("line 2\n")
    f.write("line 3\n")
    f.write("line 4\n")
    f.write("line 5\n")

ARGS = {
    'path': temp_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 int, ndim 0, dtype family int, shape () — shape () 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
dist_gather_tensor Ran
ran on a synthesized input
staoxiao/libvq/LibVQ/utils.py
code served (permissive licence) · get_code("2a264328a209d80b")
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 (6, 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.distributed as dist
from unittest.mock import Mock, patch

torch.manual_seed(0)

# Mock dist.all_gather to work without actual distributed setup
def mock_all_gather(all_tensors, vecs):
    # Simulate gathering by copying vecs to each position
    for i in range(len(all_tensors)):
        all_tensors[i].copy_(vecs)

# Patch dist.all_gather for this setup
dist.all_gather = mock_all_gather

# Create a small tensor for vecs parameter
vecs = torch.randn(2, 4)

# World size parameter
world_size = 3

# Local rank parameter
local_rank = 1

# Detach parameter
detach = True

ARGS = {
    "vecs": vecs,
    "world_size": world_size,
    "local_rank": local_rank,
    "detach": detach
}
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 (6, 4) — shape (6, 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
evaluate Ran
ran on a synthesized input
staoxiao/libvq/LibVQ/utils.py
code served (permissive licence) · get_code("1e846bd1884ce044")
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

torch.manual_seed(0)

# Construct retrieve_results: List[List[int]]
# Each inner list represents candidate document IDs for a query
retrieve_results = [
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],  # candidates for query 0
    [5, 4, 3, 2, 1, 6, 7, 8, 9, 10],  # candidates for query 1
]

# Construct ground_truths: Dict[int, List[int]]
# Maps query ID to list of relevant document IDs
ground_truths = {
    0: [1, 3, 5],      # query 0 has relevant docs 1, 3, 5
    1: [2, 4, 6],      # query 1 has relevant docs 2, 4, 6
}

# Construct MRR_cutoffs: List[int]
MRR_cutoffs = [10]

# Construct Recall_cutoffs: List[int]
Recall_cutoffs = [5, 10, 50]

# Construct qids: List[int] (optional, defaults to None)
qids = [0, 1]

ARGS = {
    "retrieve_results": retrieve_results,
    "ground_truths": ground_truths,
    "MRR_cutoffs": MRR_cutoffs,
    "Recall_cutoffs": Recall_cutoffs,
    "qids": qids,
}
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
is_main_process Ran
ran, violated the contract we drafted
staoxiao/libvq/LibVQ/utils.py
code served (permissive licence) · get_code("7cbdad4c2ba7d4ec")
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 bool, ndim 0, dtype family float, shape () 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)

ARGS = {
    "local_rank": 0
}
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 bool, ndim 0, dtype family float, shape () — shape () 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
load_rel Ran
ran on a synthesized input
staoxiao/libvq/LibVQ/dataset/dataset.py
code served (permissive licence) · get_code("4b5e5cff80872752")
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 defaultdict. 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 os
import tempfile
from collections import defaultdict

# Create a temporary file with test data
temp_dir = tempfile.mkdtemp()
rel_file = os.path.join(temp_dir, "test_relations.txt")

with open(rel_file, 'w') as f:
    f.write("1 100\n")
    f.write("1 101\n")
    f.write("2 200\n")
    f.write("3 300 extra_column\n")

ARGS = {
    "rel_file": rel_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict 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
tensorize_batch Ran
ran on a synthesized input
staoxiao/libvq/LibVQ/dataset/dataset.py
code served (permissive licence) · get_code("66edc0d3e601ef5f")
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 (3, 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 list of tensors with different lengths
# The function will pad them to the same length
sequences = [
    torch.tensor([1.0, 2.0, 3.0]),  # length 3
    torch.tensor([4.0, 5.0]),        # length 2
    torch.tensor([6.0, 7.0, 8.0, 9.0])  # length 4
]

padding_value = 0.0
align_right = False

ARGS = {
    "sequences": sequences,
    "padding_value": padding_value,
    "align_right": align_right
}
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 (3, 4) — shape (3, 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
job Not yet run
unverified (harvested, no recorded run)
staoxiao/libvq/LibVQ/dataset/preprocess.py
code served (permissive licence) · get_code("23d489f2a1942e31")
How it ran

no invocation recorded.

tokenize_data Not yet run
unverified (harvested, no recorded run)
staoxiao/libvq/LibVQ/dataset/preprocess.py
code served (permissive licence) · get_code("637f46b59be670f3")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 7 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
is_main_process 1 other paper
1 later
2403.18684 (2024-03)
Scaling Laws For 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-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

Vector quantization (VQ) based ANN indexes, such as Inverted File System (IVF) and Product Quantization (PQ), have been widely applied to embedding based document retrieval thanks to the competitive time and memory efficiency. Originally, VQ is learned to minimize the reconstruction loss, i.e., the distortions between the original dense embeddings and the reconstructed embeddings after quantization. Unfortunately, such an objective is inconsistent with the goal of selecting ground-truth documents for the input query, which may cause severe loss of retrieval quality. Recent works identify such a defect, and propose to minimize the retrieval loss through contrastive learning. However, these methods intensively rely on queries with ground-truth documents, whose performance is limited by the insufficiency of labeled data. In this paper, we propose Distill-VQ, which unifies the learning of IVF and PQ within a knowledge distillation framework. In Distill-VQ, the dense embeddings are leveraged as "teachers", which predict the query's relevance to the sampled documents. The VQ modules are treated as the "students", which are learned to reproduce the predicted relevance, such that the reconstructed embeddings may fully preserve the retrieval result of the dense embeddings. By doing so, Distill-VQ is able to derive substantial training signals from the massive unlabeled data, which significantly contributes to the retrieval quality. We perform comprehensive explorations for the optimal conduct of knowledge distillation, which may provide useful insights for the learning of VQ based ANN index. We also experimentally show that the labeled data is no longer a necessity for high-quality vector quantization, which indicates Distill-VQ's strong applicability in practice.

For agents

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

get_harvested_code_for_paper("2204.00185")
get_code_for_paper("2204.00185")
have("2204.00185")

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

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

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

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

Connect an agent — have() is free.