SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.19435 · NeurIPS · 2023

AdANNS: A Framework for Adaptive Semantic Search

Aditya Kusupati, Prateek Jain, Sham Kakade, Ali Farhadi, Aniket Rege, Sharan †⋄, S Ranjit, Alan Fan, Qingqing Cao

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 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/2305.19435.json · badge: /api/ran/2305.19435.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
RAIVNLab/AdANNS canonical (classifier label)
classifier basis: census
4 ran · 1 no recorded run
raivnlab/adanns canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
MRL_Linear_Layer Ran
ran on a synthesized input · constructed an object; no result was computed
raivnlab/adanns/MRL.py
code served (permissive licence) · get_code("6d4d4dcc43eb7a74")
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, MRL_Linear_Layer: 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
from typing import List

torch.manual_seed(0)

class MRL_Linear_Layer(nn.Module):

    def __init__(self, nesting_list: List, num_classes=1000, efficient=False, **kwargs):
        super(MRL_Linear_Layer, self).__init__()
        self.nesting_list = nesting_list
        self.num_classes = num_classes
        self.efficient = efficient
        if self.efficient:
            setattr(self, f'nesting_classifier_{0}', nn.Linear(nesting_list[-1], self.num_classes, **kwargs))
        else:
            for i, num_feat in enumerate(self.nesting_list):
                setattr(self, f'nesting_classifier_{i}', nn.Linear(num_feat, self.num_classes, **kwargs))

    def reset_parameters(self):
        if self.efficient:
            self.nesting_classifier_0.reset_parameters()
        else:
            for i in range(len(self.nesting_list)):
                getattr(self, f'nesting_classifier_{i}').reset_parameters()

    def forward(self, x):
        nesting_logits = ()
        for i, num_feat in enumerate(self.nesting_list):
            if self.efficient:
                if self.nesting_classifier_0.bias is None:
                    nesting_logits += (torch.matmul(x[:, :num_feat], self.nesting_classifier_0.weight[:, :num_feat].t()),)
                else:
                    nesting_logits += (torch.matmul(x[:, :num_feat], self.nesting_classifier_0.weight[:, :num_feat].t()) + self.nesting_classifier_0.bias,)
            else:
                nesting_logits += (getattr(self, f'nesting_classifier_{i}')(x[:, :num_feat]),)
        return nesting_logits

# Create test input tensor with batch size 2 and feature dimension 6
x = torch.randn(2, 6)

ARGS = {
    'nesting_list': [2, 4, 6],
    'num_classes': 10,
    'efficient': False,
}
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 MRL_Linear_Layer — 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 MRL_Linear_Layer 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_activation Ran
ran; our contract draft was wrong, not the code
RAIVNLab/AdANNS/utils.py
code served (permissive licence) · get_code("42855fe8dc821c2e")
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
import torch.nn as nn

torch.manual_seed(0)

activation = {}

def get_activation(name):
    """
	Get the activation from an intermediate point in the network.
	:param name: layer whose activation is to be returned
	:return: activation of layer
	"""

    def hook(model, input, output):
        activation[name] = output.detach()
    return hook

# Build a simple model to demonstrate hook usage
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = nn.Linear(4, 3)
        self.layer2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.layer1(x)
        x = self.layer2(x)
        return x

model = SimpleModel()
model.layer1.register_forward_hook(get_activation("layer1"))

# Create sample input
x = torch.randn(2, 4)

# Execute the model to populate activation
output = model(x)

ARGS = {
    "name": "layer1"
}
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
load_embeddings Ran
ran on a synthesized input
RAIVNLab/AdANNS/adanns/utils.py
code served (permissive licence) · get_code("11a69b869864eb2e")
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 numpy as np
import faiss

# Create mock numpy files and mock the np.load function
_mock_data = {}

def _create_mock_embeddings(shape):
    """Create small mock embedding arrays"""
    return np.random.randn(*shape).astype(np.float32)

# Pre-populate mock data for all possible combinations
datasets = ['1K', '4K', 'A', 'R', 'O']
models_config = [
    ('mrl', 'mrl1_e0_ff2048'),
    ('rr', 'mrl0_e0_ff128'),
]
arch = 'resnet50'

for dataset in datasets:
    for model, config in models_config:
        # Create small mock data: 8 samples, 128 dims
        db_data = _create_mock_embeddings((8, 128))
        query_data = _create_mock_embeddings((4, 128))
        db_labels = np.random.randint(0, 10, 8).astype(np.int64)
        query_labels = np.random.randint(0, 10, 4).astype(np.int64)
        
        db_npy = f'{dataset}_train_{config}-X.npy'
        query_npy = f'{dataset}_val_{config}-X.npy'
        db_label_npy = f'{dataset}_train_{config}-y.npy'
        query_label_npy = f'{dataset}_val_{config}-y.npy'
        
        _mock_data[db_npy] = db_data
        _mock_data[query_npy] = query_data
        _mock_data[db_label_npy] = db_labels
        _mock_data[query_label_npy] = query_labels

# Mock np.load to return our pre-created data
_original_np_load = np.load
def _mock_np_load(path, *args, **kwargs):
    filename = path.split('/')[-1]
    if filename in _mock_data:
        return _mock_data[filename]
    raise FileNotFoundError(f"Mock file not found: {filename}")

np.load = _mock_np_load

ARGS = {
    'model': 'mrl',
    'dataset': '1K',
    'embedding_dim': 128,
    'arch': 'resnet50',
    'using_gcloud': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
faiss, numpy — 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
load_from_old_ckpt Ran
ran on a synthesized input
RAIVNLab/AdANNS/utils.py
code served (permissive licence) · get_code("90e640a68fafb411")
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 MinimalModel. 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

torch.manual_seed(0)

# Create a minimal model with an 'fc' attribute that will be replaced
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Linear(10, 1000)  # placeholder that will be replaced

model = MinimalModel()

# Define parameters for load_from_old_ckpt
efficient = True  # Test with efficient=True (SingleHeadNestedLinear)
nesting_list = [4, 8, 12]  # List of feature dimensions for nesting

ARGS = {
    "model": model,
    "efficient": efficient,
    "nesting_list": nesting_list
}
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 MinimalModel — a MinimalModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MinimalModel 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
normalize_embeddings Ran
ran on a synthesized input
RAIVNLab/AdANNS/adanns/utils.py
code served (permissive licence) · get_code("500c10080bc80827")
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 ndarray, 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 numpy as np
import faiss

# Create a small embedding matrix
# The function expects a numpy array that faiss can normalize
embeddings = np.array([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0]
], dtype=np.float32)

# Define the arguments dictionary
ARGS = {
    'embeddings': embeddings,
    'dtype': 'float32'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
faiss, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, 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
get_ckpt Not yet run
unverified (harvested, no recorded run)
RAIVNLab/AdANNS/utils.py
code served (permissive licence) · get_code("08f2259843ec19ec")
How it ran

no invocation 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, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 5 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_activation 4 other papers
2 dated earlier, 2 later
2002.05810 (2020-02)
RNA Secondary Structure Prediction By Learning Unrolled Algorithms
2103.03000 (2021-03)
SpectralDefense: Detecting Adversarial Attacks on CNNs in the Fourier Domain
2311.05808 (2023-11)
Scale-MIA: A Scalable Model Inversion Attack against Secure Federated Learning via Latent Space Reconstruction
and 1 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-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

Web-scale search systems learn an encoder to embed a given query which is then hooked into an approximate nearest neighbor search (ANNS) pipeline to retrieve similar data points. To accurately capture tail queries and data points, learned representations typically are rigid, high-dimensional vectors that are generally used as-is in the entire ANNS pipeline and can lead to computationally expensive retrieval. In this paper, we argue that instead of rigid representations, different stages of ANNS can leverage adaptive representations of varying capacities to achieve significantly better accuracy-compute trade-offs, i.e., stages of ANNS that can get away with more approximate computation should use a lower-capacity representation of the same data point. To this end, we introduce AdANNS , a novel ANNS design framework that explicitly leverages the flexibility of Matryoshka Representations [31]. We demonstrate state-of-the-art accuracy-compute trade-offs using novel AdANNS-based key ANNS building blocks like search data structures (AdANNS-IVF) and quantization (AdANNS-OPQ). For example on ImageNet retrieval, AdANNS-IVF is up to 1.5% more accurate than the rigid representations-based IVF [48] at the same compute budget; and matches accuracy while being up to 90× faster in wall-clock time. For Natural Questions, 32-byte AdANNS-OPQ matches the accuracy of the 64-byte OPQ baseline [13] constructed using rigid representations -same accuracy at half the cost! We further show that the gains from AdANNS translate to modern-day composite ANNS indices that combine search structures and quantization. Finally, we demonstrate that AdANNS can enable inference-time adaptivity for compute-aware search on ANNS indices built non-adaptively on matryoshka representations. Code is open-sourced at https://github.com/RAIVNLab/AdANNS.

For agents

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

get_harvested_code_for_paper("2305.19435")
get_code_for_paper("2305.19435")
have("2305.19435")

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

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

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

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

Connect an agent — have() is free.