SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.08319 · 2023

Fine-Tuning LLaMA for Multi-Stage Text Retrieval

arXiv · PDF · Open in the Atlas

Code that ran

8 of 9 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 0 have no contract verdict; 8 failures 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/2310.08319.json · badge: /api/ran/2310.08319.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
texttron/tevatron canonical (classifier label)
classifier basis: census
8 ran · 1 no recorded run
FunctionStatusWhere it lives
beir_data_path Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
texttron/tevatron/src/tevatron/eval/benchmarks.py
code served (permissive licence) · get_code("58ca9eadffe169a1")
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 str. 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 unittest.mock import Mock, patch

# Create a temporary directory to act as cache
beir_cache_dir = tempfile.mkdtemp()

# Create a mock for the beir.util.download_and_unzip function
# to avoid actual network calls
def mock_download_and_unzip(url, cache_dir):
    """Mock download_and_unzip that creates a fake archive structure"""
    os.makedirs(cache_dir, exist_ok=True)
    # For regular datasets, return the cache_dir itself
    # For cqadupstack, create the nested structure
    if 'cqadupstack' in url:
        archive_path = os.path.join(cache_dir, 'cqadupstack')
        os.makedirs(archive_path, exist_ok=True)
        return archive_path
    else:
        return cache_dir

# Patch beir.util.download_and_unzip before importing
import sys
beir_mock = Mock()
beir_mock.util.download_and_unzip = mock_download_and_unzip
sys.modules['beir'] = beir_mock
sys.modules['beir.util'] = beir_mock.util

ARGS = {
    'dataset': 'trec-covid',
    'beir_cache_dir': beir_cache_dir,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
beir — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
beir_split_for Ran
ran; our contract draft was wrong, not the code
texttron/tevatron/src/tevatron/eval/benchmarks.py
code served (permissive licence) · get_code("da58dea30fe4d922")
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 str. 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.

ARGS = {
    'dataset': 'msmarco'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
beir_url_and_subdir Ran
ran; our contract draft was wrong, not the code
texttron/tevatron/src/tevatron/eval/benchmarks.py
code served (permissive licence) · get_code("f0cd0ee4f1a7e335")
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, ndim 1, dtype family float; no output shape is stated. The image it ran in was 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 os

def beir_url_and_subdir(dataset: str) -> tuple[str, str]:
    """Map a dataset name to (BEIR archive URL, on-disk data folder)."""
    base = 'https://public.ukp.informatik.tu-darmstadt.de/thakur/BEIR/datasets'
    if dataset.startswith('cqadupstack-'):
        sub = dataset[len('cqadupstack-'):]
        return (f'{base}/cqadupstack.zip', os.path.join('cqadupstack', sub))
    return (f'{base}/{dataset}.zip', dataset)


ARGS = {
    'dataset': 'trec-covid'
}
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 tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
last_token_pool Ran
ran; our contract draft was wrong, not the code
texttron/tevatron/src/tevatron/megatron/engine.py
code served (permissive licence) · get_code("cd7cef6e9418ab5d")
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, ndim 2, dtype family float; no output shape is stated. The image it ran in was 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

torch.manual_seed(0)

# Build tensors with distinct dimensions for clarity
batch_size = 2
seq_length = 5
vocab_size = 100

# output: shape (seq_length, batch_size, vocab_size)
# The function transposes it to (batch_size, seq_length, vocab_size)
# Then indexes with last_hidden[batch_idx, seq_lengths] to get (batch_size, vocab_size)
output = torch.randn(seq_length, batch_size, vocab_size)

# attention_mask: shape (batch_size, seq_length)
# Used to compute seq_lengths via sum(dim=-1) - 1
attention_mask = torch.tensor([
    [1, 1, 1, 1, 0],
    [1, 1, 1, 0, 0]
], dtype=torch.long)

# Token IDs for indexing into the vocab dimension
yes_token_id = 10
no_token_id = 20

ARGS = {
    "output": output,
    "attention_mask": attention_mask,
    "yes_token_id": yes_token_id,
    "no_token_id": no_token_id,
}
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, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
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
read_ranklist Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
texttron/tevatron/src/tevatron/eval/metrics.py
code served (permissive licence) · get_code("4b8a981075a9c13c")
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 tempfile
import os

# Create a temporary ranklist file for testing
temp_dir = tempfile.mkdtemp()
ranklist_path = os.path.join(temp_dir, "ranklist.txt")

# Write a sample ranklist file with 3-field format
with open(ranklist_path, 'w') as f:
    f.write("q1 doc1 0.9\n")
    f.write("q1 doc2 0.7\n")
    f.write("q1 doc3 0.5\n")
    f.write("q2 doc4 0.85\n")
    f.write("q2 doc1 0.6\n")

ARGS = {
    "path": ranklist_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
beir — 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
render Ran
ran; our contract draft was wrong, not the code
texttron/tevatron/src/tevatron/eval/summary.py
code served (permissive licence) · get_code("b118264a1ed82791")
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 str. 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.

from dataclasses import dataclass, field
from typing import Dict, List

_METRIC_GROUPS = {'ndcg': 'NDCG', 'recall': 'Recall', 'map': 'MAP', 'mrr': 'MRR', 'precision': 'P'}

DEFAULT_COLUMNS = ('ndcg@10', 'recall@200', 'ndcg@100')

@dataclass
class SummaryRow:
    """One row above the aggregate rule.

    members of length 1 -> a plain per-dataset row; longer -> a *collapsed*
    row whose cells are the per-column average over present members (label may
    contain ``{n}``, filled with the count of present members).
    """
    label: str
    members: List[str]
    show_if_absent: bool = True

@dataclass
class Aggregate:
    """One aggregate row below the rule.

    `units` is a list of task units; each unit is a list of datasets averaged
    into a single task value (length-1 unit = a plain dataset). The aggregate
    is the mean over units that have at least one present member. The label may
    contain ``{n}`` (filled with the number of contributing units).
    """
    label: str
    units: List[List[str]]

@dataclass
class SummaryLayout:
    rows: List[SummaryRow] = field(default_factory=list)
    aggregates: List[Aggregate] = field(default_factory=list)


results = {
    'dataset_a': {
        'ndcg': {'NDCG@10': 0.75, 'NDCG@100': 0.80},
        'recall': {'Recall@200': 0.85},
    },
    'dataset_b': {
        'ndcg': {'NDCG@10': 0.70, 'NDCG@100': 0.78},
        'recall': {'Recall@200': 0.82},
    },
    'dataset_c': {
        'ndcg': {'NDCG@10': 0.72, 'NDCG@100': 0.79},
        'recall': {'Recall@200': 0.83},
    },
}

layout = SummaryLayout(
    rows=[
        SummaryRow(label='Dataset A', members=['dataset_a']),
        SummaryRow(label='Dataset B', members=['dataset_b']),
        SummaryRow(label='Average {n}', members=['dataset_a', 'dataset_b']),
    ],
    aggregates=[
        Aggregate(label='Overall {n}', units=[['dataset_a'], ['dataset_b'], ['dataset_c']]),
    ]
)

name = 'Test Evaluation'

columns = ('ndcg@10', 'recall@200', 'ndcg@100')

ARGS = {
    'results': results,
    'layout': layout,
    'name': name,
    'columns': columns,
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
reranker_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
texttron/tevatron/src/tevatron/megatron/loss.py
code served (permissive licence) · get_code("81c36957e2034400")
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 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
import torch.nn.functional as F

torch.manual_seed(0)

# Construct arguments for reranker_loss
# scores: (batch * group_size,) tensor of scalar relevance scores
# group_size: number of passages per query

batch_size = 2
group_size = 4
total_scores = batch_size * group_size

# Create scores tensor with shape (batch * group_size,)
# These represent relevance scores for each passage
scores = torch.randn(total_scores, dtype=torch.float32)

ARGS = {
    "scores": scores,
    "group_size": group_size,
}
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 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
score Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
texttron/tevatron/src/tevatron/eval/metrics.py
code served (permissive licence) · get_code("5eb05d1d51ec1fa5")
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 dict. 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 numpy as np

# Mock the BEIR evaluator since we can't download it
class MockEvaluateRetrieval:
    def evaluate(self, qrels, results, k_values):
        # Return mock metric dicts matching BEIR's format
        ndcg = {f"NDCG@{k}": 0.5 for k in k_values}
        _map = {f"MAP@{k}": 0.45 for k in k_values}
        recall = {f"Recall@{k}": 0.6 for k in k_values}
        precision = {f"Precision@{k}": 0.55 for k in k_values}
        return ndcg, _map, recall, precision
    
    def evaluate_custom(self, qrels, results, k_values, metric):
        # Return mock MRR dict
        return {f"MRR@{k}": 0.52 for k in k_values}

# Patch the BEIR import
import sys
from types import ModuleType

beir_module = ModuleType('beir')
beir_retrieval = ModuleType('beir.retrieval')
beir_evaluation = ModuleType('beir.retrieval.evaluation')
beir_evaluation.EvaluateRetrieval = MockEvaluateRetrieval

beir_retrieval.evaluation = beir_evaluation
beir_module.retrieval = beir_retrieval

sys.modules['beir'] = beir_module
sys.modules['beir.retrieval'] = beir_retrieval
sys.modules['beir.retrieval.evaluation'] = beir_evaluation

# Build realistic qrels and results dicts matching BEIR format
# qrels: {query_id: {doc_id: relevance_score}}
# results: {query_id: {doc_id: score}}

qrels = {
    "q1": {"doc1": 1, "doc2": 1, "doc3": 0},
    "q2": {"doc4": 1, "doc5": 0, "doc6": 1},
}

results = {
    "q1": {
        "doc1": 0.9,
        "doc2": 0.7,
        "doc3": 0.5,
        "doc4": 0.3,
        "doc5": 0.1,
    },
    "q2": {
        "doc6": 0.85,
        "doc4": 0.8,
        "doc5": 0.6,
        "doc1": 0.4,
        "doc2": 0.2,
    },
}

ARGS = {
    "qrels": qrels,
    "results": results,
    "k_values": (10, 100, 200, 1000),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
beir, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
expand_lora_target_groups Not yet run
unverified (harvested, no recorded run)
texttron/tevatron/src/tevatron/megatron/config.py
code served (permissive licence) · get_code("f560d59e5a1e1ace")
How it ran

no invocation recorded.

Also present in other papers' code

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

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

The effectiveness of multi-stage text retrieval has been solidly demonstrated since before the era of pre-trained language models. However, most existing studies utilize models that predate recent advances in large language models (LLMs). This study seeks to explore potential improvements that state-of-the-art LLMs can bring. We conduct a comprehensive study, fine-tuning the latest LLaMA model both as a dense retriever (RepLLaMA) and as a pointwise reranker (RankLLaMA) for both passage retrieval and document retrieval using the MS MARCO datasets. Our findings demonstrate that the effectiveness of large language models indeed surpasses that of smaller models. Additionally, since LLMs can inherently handle longer contexts, they can represent entire documents holistically, obviating the need for traditional segmenting and pooling strategies. Furthermore, evaluations on BEIR demonstrate that our RepLLaMA-RankLLaMA pipeline exhibits strong zero-shot effectiveness. Model checkpoints from this study are available on HuggingFace.

For agents

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

get_harvested_code_for_paper("2310.08319")
get_code_for_paper("2310.08319")
have("2310.08319")

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

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

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

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

Connect an agent — have() is free.