SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.18424 · EMNLP · 2024

PromptReps: Prompting Large Language Models to Generate Dense and Sparse Representations for Zero-Shot Document Retrieval

Jimmy Lin, Guido Zuccon, Xueguang Ma, Shengyao Zhuang, Bevan Koopman

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 (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; 6 failures of our instrument; 0 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/2404.18424.json · badge: /api/ran/2404.18424.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
ielab/promptreps canonical (classifier label)
classifier basis: census
6 ran · 0 no recorded run
FunctionStatusWhere it lives
fuse Ran
ran; our contract draft was wrong, not the code
ielab/promptreps/hybrid.py
code served (permissive licence) · get_code("febf3230a16d067b")
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.

# Analyzing the function signature and body:
# fuse(runs, weights)
# - runs: list of dicts where each dict has:
#   - keys: query IDs (qids)
#   - values: dicts with 'docs', 'min_score', 'max_score' keys
#     - 'docs': dict mapping doc_id to score
#     - 'min_score': numeric value
#     - 'max_score': numeric value
# - weights: list/iterable of numeric weights (one per run)

# Construct minimal valid arguments:

ARGS = {
    'runs': [
        {
            'q1': {
                'docs': {'doc_a': 0.5, 'doc_b': 0.8},
                'min_score': 0.0,
                'max_score': 1.0
            },
            'q2': {
                'docs': {'doc_c': 0.3},
                'min_score': 0.0,
                'max_score': 1.0
            }
        },
        {
            'q1': {
                'docs': {'doc_a': 0.6, 'doc_c': 0.7},
                'min_score': 0.0,
                'max_score': 1.0
            },
            'q2': {
                'docs': {'doc_b': 0.4, 'doc_c': 0.9},
                'min_score': 0.0,
                'max_score': 1.0
            }
        }
    ],
    'weights': [0.4, 0.6]
}
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 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
get_filtered_ids Ran
ran; our contract draft was wrong, not the code
ielab/promptreps/encode.py
code served (permissive licence) · get_code("76f1dfd3c74d286d")
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 set. 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

class MockTokenizer:
    def get_vocab(self):
        return {
            '▁hello': 0,
            '▁world': 1,
            ' test': 2,
            'apple': 3,
            'banana': 4,
            '123': 5,
            '!@#': 6,
            '▁a': 7,
            ' z': 8,
            'A': 9,
            '1a': 10,
            'xyz': 11,
        }

tokenizer = MockTokenizer()

ARGS = {
    '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 set — a set output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a set 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_run_dict Ran
ran; our contract draft was wrong, not the code
ielab/promptreps/search.py
code served (permissive licence) · get_code("7bcc4c919dd0fcec")
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

torch.manual_seed(0)

# Construct valid arguments for get_run_dict
batch_ids = ['q1', 'q2']
batch_scores = [
    [0.9, 0.7, 0.5],
    [0.8, 0.6]
]
batch_rankings = [
    ['doc1', 'doc2', 'doc3'],
    ['doc4', 'doc5']
]
remove_query = False

ARGS = {
    'batch_ids': batch_ids,
    'batch_scores': batch_scores,
    'batch_rankings': batch_rankings,
    'remove_query': remove_query
}
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 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
pickle_load Ran
ran; our contract draft was wrong, not the code
ielab/promptreps/search.py
code served (permissive licence) · get_code("d2d5d62b9c53b6d4")
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 pickle
import tempfile
import os

# Create a temporary pickle file with valid data
temp_dir = tempfile.mkdtemp()
temp_path = os.path.join(temp_dir, "test.pkl")

# Create sample data
reps = [[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]
lookup = {"key1": 0, "key2": 1}

# Pickle and save the data
with open(temp_path, 'wb') as f:
    pickle.dump((reps, lookup), f)

ARGS = {
    "path": temp_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
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
read_trec_run Ran
ran; our contract draft was wrong, not the code
ielab/promptreps/hybrid.py
code served (permissive licence) · get_code("da98823d4692c734")
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 tempfile
import os

# Create a temporary TREC run file
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("q1 0 doc1 1 10.5 run_name\n")
temp_file.write("q1 0 doc2 2 8.3 run_name\n")
temp_file.write("q2 0 doc3 1 15.2 run_name\n")
temp_file.write("q2 0 doc4 2 6.1 run_name\n")
temp_file.close()

ARGS = {
    'file': temp_file.name
}
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 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
search_queries Ran
ran; our contract draft was wrong, not the code
ielab/promptreps/search.py
code served (permissive licence) · get_code("01c4c73be2b9b863")
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 3, 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
import numpy as np

# Small stand-in retriever class
class MockRetriever:
    def __init__(self):
        pass
    
    def batch_search(self, q_reps, depth, batch_size, quiet):
        # q_reps shape: (num_queries, embedding_dim)
        num_queries = q_reps.shape[0]
        # Return scores and indices
        all_scores = np.random.rand(num_queries, depth).astype(np.float32)
        all_indices = np.random.randint(0, 100, size=(num_queries, depth))
        return all_scores, all_indices
    
    def search(self, q_reps, depth):
        num_queries = q_reps.shape[0]
        all_scores = np.random.rand(num_queries, depth).astype(np.float32)
        all_indices = np.random.randint(0, 100, size=(num_queries, depth))
        return all_scores, all_indices

# Small args config class
class Args:
    def __init__(self, batch_size=32, depth=10, quiet=False):
        self.batch_size = batch_size
        self.depth = depth
        self.quiet = quiet

# Create retriever
retriever = MockRetriever()

# Create query representations (num_queries=2, embedding_dim=4)
q_reps = np.random.rand(2, 4).astype(np.float32)

# Create passage lookup dictionary mapping passage indices to passage IDs
p_lookup = {i: f"passage_{i}" for i in range(100)}

# Create args
args = Args(batch_size=32, depth=10, quiet=False)

ARGS = {
    "retriever": retriever,
    "q_reps": q_reps,
    "p_lookup": p_lookup,
    "args": args
}
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 tuple, ndim 3, 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

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, 0 the same month, 1 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
search_queries 2 other papers
1 dated earlier, 1 later
2306.16680 (2023-06)
Exploring the Representation Power of SPLADE Models
2410.13230 (2024-10)
Starbucks-v2: Improved Training for 2D Matryoshka Embeddings
pickle_load 1 other paper
1 dated earlier
2306.16680 (2023-06)
Exploring the Representation Power of SPLADE Models

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

Utilizing large language models (LLMs) for zero-shot document ranking is done in one of two ways: (1) prompt-based re-ranking methods, which require no further training but are only feasible for re-ranking a handful of candidate documents due to computational costs; and (2) unsupervised contrastive trained dense retrieval methods, which can retrieve relevant documents from the entire corpus but require a large amount of paired text data for contrastive training. In this paper, we propose PromptReps, which combines the advantages of both categories: no need for training and the ability to retrieve from the whole corpus. Our method only requires prompts to guide an LLM to generate query and document representations for effective document retrieval. Specifically, we prompt the LLMs to represent a given text using a single word, and then use the last token's hidden states and the corresponding logits associated with the prediction of the next token to construct a hybrid document retrieval system. The retrieval system harnesses both dense text embedding and sparse bag-of-words representations given by the LLM. Our experimental evaluation on the MSMARCO, TREC deep learning and BEIR zero-shot document retrieval datasets illustrates that this simple prompt-based LLM retrieval method can achieve a similar or higher retrieval effectiveness than state-of-the-art LLM embedding methods that are trained with large amounts of unsupervised data, especially when using a larger LLM.

For agents

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

get_harvested_code_for_paper("2404.18424")
get_code_for_paper("2404.18424")
have("2404.18424")

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

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

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

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

Connect an agent — have() is free.