Papers › DemoRank: Selecting Effective Demonstrations for Large Language Models in Ranking Task

DemoRank: Selecting Effective Demonstrations for Large Language Models in Ranking Task

24 Jun 2024arXiv:2406.16332archive 2025-07-28

Wenhan Liu, Yutao Zhu, Zhicheng Dou

Recently, there has been increasing interest in applying large language models (LLMs) as zero-shot passage rankers. However, few studies have explored how to select appropriate in-context demonstrations for the passage ranking task, which is the focus of this paper. Previous studies mainly use LLM's feedback to train a retriever for demonstration selection. These studies apply the LLM to score each demonstration independently, which ignores the dependencies between demonstrations (especially important in ranking task), leading to inferior performance of top-k retrieved demonstrations. To mitigate this issue, we introduce a demonstration reranker to rerank the retrieved demonstrations so that top-k ranked ones are more suitable for ICL. However, generating training data for such reranker is quite challenging. On the one hand, different from demonstration retriever, the training samples of reranker need to incorporate demonstration dependencies. On the other hand, obtaining the gold ranking from the retrieved demonstrations is an NP-hard problem, which is hard to implement. To overcome these challenges, we propose a method to approximate the optimal demonstration list iteratively and utilize LLM to score demonstration lists of varying lengths. By doing so, the search space is greatly reduced and demonstration dependencies are considered. Based on these scored demonstration lists, we further design a list-pairwise training approach which compares a pair of lists that only differ in the last demonstration, to teach the reranker how to select the next demonstration given a previous sequence. In this paper, we propose a demonstration selection framework DemoRank for ranking task and conduct extensive experiments to prove its strong ability.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2406.16332")

Code

Syntology Ran 13 of 17 code samples harvested from 1 repository linked to this paper; 4 have no recorded run. Of those that ran: 13 ran with no contract checked.

By repository: official repository: 17 samples from 1 repository, 13 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

8421bcd/demorank officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

17 samples harvested; 13 ran; 0 honoured the contract we drafted; 4 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

13ran
4unverified

Licence: 17 of the 17 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 8421bcd/demorank. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

add_prefix 8421bcd/demorank/build_index/build_dense_index_after_train.py official repository ran no licence file found · pointer only · 9d00cfb48e576f8d · report
construct_flatindex_from_embeddings 8421bcd/demorank/retrieve_utils.py official repository ran no licence file found · pointer only · b3d0e9d10e74431c · report
get_few_shot_prompts 8421bcd/demorank/llm_score.py official repository ran no licence file found · pointer only · 79e2396cd92c6647 · report
get_few_shot_prompts 8421bcd/demorank/llm_score_dependency_aware_rerank.py official repository ran no licence file found · pointer only · 2d5ea04a0d0d12b6 · report
get_pointwise_prompt 8421bcd/demorank/utils.py official repository ran fingerprinted no licence file found · pointer only · 2bb876a8dec0d022 · report
get_random_prompts 8421bcd/demorank/llm_score_dependency_aware_rerank.py official repository ran no licence file found · pointer only · 54c92ed61e995cdb · report
get_random_prompts 8421bcd/demorank/run_kshot.py official repository ran no licence file found · pointer only · dd988220ebbf663f · report
index_retrieve 8421bcd/demorank/retrieve_utils.py official repository ran no licence file found · pointer only · 62fc247c87911474 · report
pool 8421bcd/demorank/build_index/build_dense_index_after_train.py official repository ran no licence file found · pointer only · 595c0a53a8076613 · report
sample_train_data 8421bcd/demorank/train/src/data_utils.py official repository ran no licence file found · pointer only · dec7eb98d9881f43 · report
select_demon_by_rank 8421bcd/demorank/llm_score.py official repository ran no licence file found · pointer only · 15fc32dc01a4d6a2 · report
select_demon_by_rank 8421bcd/demorank/llm_score_dependency_aware_rerank.py official repository ran no licence file found · pointer only · 5fe38dc5d56a7bc1 · report
to_up_down_format 8421bcd/demorank/train/src/data_utils.py official repository ran no licence file found · pointer only · 1094917da0e69ba3 · report
convert_index_to_gpu 8421bcd/demorank/retrieve_utils.py official repository unverified no licence file found · pointer only · 04460628a698fdd7 · report
get_dbs_prompts 8421bcd/demorank/run_kshot.py official repository unverified no licence file found · pointer only · 55ce04e044d233b9 · report
get_kmeans_prompts 8421bcd/demorank/run_kshot.py official repository unverified no licence file found · pointer only · 6f3c55ed5d1e9d5e · report
get_random_prompts 8421bcd/demorank/llm_score.py official repository unverified no licence file found · pointer only · f56c7d1d6b97751f · report

Tasks

In-Context LearningPassage Ranking

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Focus

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections