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 View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

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

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 17 code samples harvested from 1 repository linked to this paper: 13 ran (of which 0 constructed an object rather than computing a result; 8 with no instrument failure: 0 honoured, 0 violated, 8 with no contract checked; 5 where Syntology's instrument failed) · 4 unverified. Where Syntology's instrument failed: 3 where our contract draft was wrong; 2 where the contract check could not run; failures of Syntology's instrument, not of the code.

By repository: official repository: 17 samples from 1 repository, 13 ran (8 with no instrument failure; 5 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Levels written on 2026-09-24 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed.

8421bcd/demorank officialmentioned in papermentioned on GitHubpytorchSyntology: 17 samples, 13 ran (5 instrument-failed) · 4 unverified 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 (of which 0 constructed an object rather than computing a result; 8 with no instrument failure: 0 honoured, 0 violated, 8 with no contract checked; 5 where Syntology's instrument failed) · 4 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page last changed ; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

3ran · our draft was wrong
2ran; the contract check could not run
8ran
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. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (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 are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. 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 six 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; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. 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.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity.

8421bcd/demorank official repository 17 samples, 13 ran (5 instrument-failed) · 4 unverified
add_prefix in 20 papers build_index/build_dense_index_after_train.py ran · our draft was wrong no licence file found · pointer only · 9d00cfb48e576f8d · report fixture: signature example:dict/0/? · returned dict · level recorded 2026-09-24
construct_flatindex_from_embeddings retrieve_utils.py ran; the contract check could not run (RAISES) no licence file found · pointer only · b3d0e9d10e74431c · report fixture: signature embeddings:ndarray/2/float, ids:ndarray/1/int · returned IndexIDMap2 · level recorded 2026-09-24
get_few_shot_prompts llm_score.py ran no licence file found · pointer only · 79e2396cd92c6647 · report fixture: signature qd_info:dict/0/?, id_demonquery:NoneType/0/?, id_demondoc:NoneType/0/?, id_demon:NoneType/0/?, searcher:MockSearcher/0/?, demonstration_num:int/0/int, args:MockArgs/0/?, is_e5_retrieval:bool/0/bool · returned list · level recorded 2026-09-24
get_few_shot_prompts llm_score_dependency_aware_rerank.py ran no licence file found · pointer only · 2d5ea04a0d0d12b6 · report fixture: signature qd_info:dict/0/?, id_demonquery:str/0/str, id_demondoc:str/0/str, searcher:MockSearcher/0/?, demonstration_num:int/0/int, args:MockArgs/0/?, is_e5_retrieval:bool/0/bool · returned list · level recorded 2026-09-24
get_pointwise_prompt utils.py ran fingerprinted no licence file found · pointer only · 2bb876a8dec0d022 · report fixture: signature query:str/0/str, doc:str/0/str, label:str/0/str · returned str · level recorded 2026-09-24
get_random_prompts llm_score_dependency_aware_rerank.py ran no licence file found · pointer only · 54c92ed61e995cdb · report fixture: signature qd_info:dict/0/?, id_posdemon:dict/0/?, demonstration_num:int/0/int, args:dict/0/? · returned list · level recorded 2026-09-24
get_random_prompts run_kshot.py ran no licence file found · pointer only · dd988220ebbf663f · report fixture: signature results:list/1/tuple, id_demon:dict/0/?, args:Args/0/? · returned dict · level recorded 2026-09-24
index_retrieve retrieve_utils.py ran no licence file found · pointer only · 62fc247c87911474 · report fixture: signature index:MockIndex/0/?, query_embeddings:ndarray/2/float, topk:int/0/int, batch:int/0/int · returned list · level recorded 2026-09-24
pool in 9 papers build_index/build_dense_index_after_train.py ran no licence file found · pointer only · 595c0a53a8076613 · report fixture: signature last_hidden_states:Tensor/3/float, attention_mask:Tensor/2/int, pool_type:str/0/str · returned Tensor · level recorded 2026-09-24
sample_train_data train/src/data_utils.py ran · our draft was wrong no licence file found · pointer only · dec7eb98d9881f43 · report fixture: signature example:dict/0/?, train_num:int/0/int · returned dict · level recorded 2026-09-24
select_demon_by_rank llm_score.py ran; the contract check could not run (RAISES) no licence file found · pointer only · 15fc32dc01a4d6a2 · report fixture: signature demon_ids:list/1/str, scores:list/1/float · returned str_ · level recorded 2026-09-24
select_demon_by_rank llm_score_dependency_aware_rerank.py ran no licence file found · pointer only · 5fe38dc5d56a7bc1 · report fixture: signature demon_ids:list/1/str, scores:list/1/float, none_score:float/0/float · returned str_ · level recorded 2026-09-24
to_up_down_format train/src/data_utils.py ran · our draft was wrong no licence file found · pointer only · 1094917da0e69ba3 · report fixture: signature example:dict/0/? · returned dict · level recorded 2026-09-24
convert_index_to_gpu retrieve_utils.py unverified no licence file found · pointer only · 04460628a698fdd7 · report
get_dbs_prompts run_kshot.py unverified no licence file found · pointer only · 55ce04e044d233b9 · report
get_kmeans_prompts run_kshot.py unverified no licence file found · pointer only · 6f3c55ed5d1e9d5e · report
get_random_prompts llm_score.py 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