An Investigation of Prompt Variations for Zero-shot LLM-based Rankers

Shuoqi Sun, Shengyao Zhuang, Shuai Wang, Guido ZucconarXiv 2024 · DOI

TL;DR

When using Large Language Models (LLMs) for zero-shot document ranking, the subtle wording and structure of your prompt can matter just as much as—or even more than—the underlying ranking algorithm. By systematically evaluating 1,248 prompt variations, this paper reveals that previous benchmarks were heavily biased by arbitrary prompt choices, and shows that supposedly "inferior" ranking methods can become highly competitive when properly prompted.

What Problem Does This Paper Address?

Information Retrieval (IR) has recently embraced zero-shot ranking using LLMs, where a model re-ranks documents for a query without explicit fine-tuning. These rankers generally fall into four algorithmic families: pointwise (evaluating one document at a time), pairwise (comparing two documents), listwise (ranking a whole list), and setwise (iteratively selecting the best from a subset).

While recent literature suggested that listwise and setwise approaches vastly outperform pointwise ones, the authors noticed a glaring experimental flaw: these methods were evaluated using completely different prompt styles. For instance, one popular listwise method included "role-playing" instructions ("You are RankGPT..."), while a competing pointwise method did not. Were listwise methods actually superior, or did they just have better prompt engineering? This paper untangles the impact of the ranking algorithm from the "accessory wording" of the prompts.

Methods

The authors broke down ranking prompts into a structured taxonomy consisting of five core components and two structural ordering choices:

  • Evidence (EV): The actual query and passages.
  • Task Instruction (TI): The algorithmic instruction (e.g., "Is this passage relevant?").
  • Output Type (OT): The format requested (e.g., Yes/No vs. a 0-4 scale).
  • Tone Words (TW): Nuances added to alter the model's behavior (e.g., "Please", "Must", or even "You better get this right or you will be punished").
  • Role Playing (RP): Assigning a persona to the LLM.
  • Evidence Ordering (EO) & Position of Evidence (PE): Whether the query or passage comes first, and whether this evidence sits at the beginning or end of the prompt.

By systematically mixing and matching these components, they generated 1,248 unique prompt variations across the four ranking families. They tested these prompts across several open-source LLM backbones: Flan-T5 (Large, XL, XXL), Mistral-7B, and Llama3-8B. To ensure a fair comparison, they standardized input constraints to 512 tokens across all models.

Taxonomy of prompt components and wording alternatives evaluated in the study.

Datasets

The prompt variations were evaluated using standard information retrieval benchmarks from the ir_datasets library:

  • TREC Deep Learning (DL) 2019 (43 queries)
  • TREC Deep Learning (DL) 2020 (48 queries)
  • BeIR TREC COVID (50 queries)

The initial retrieval stage utilized a standard BM25 pipeline to fetch the top 100 documents, which the LLMs then re-ranked.

Key Insights and Ideas

  • Pointwise is Not Dead: Historically dismissed as the weakest approach, pointwise ranking exhibits the highest sensitivity to prompt variations. With an optimized prompt, pointwise rankers can match or even exceed the performance of listwise and setwise methods on certain datasets.
  • The "Original" Prompts are Sub-optimal: The prompts published in seminal LLM-ranking papers are rarely the best choices. In almost all tested configurations, the authors discovered alternative wordings that yielded statistically significant performance gains.
  • No Silver Bullet Prompt: There is no single master prompt template. The optimal combination of tone words, role-playing, and evidence positioning shifts depending on the specific dataset and the underlying LLM backbone.
  • Persona and Tone Help (Usually): Incorporating tone words improved ranking effectiveness in 82% of cases, and role-playing frequently boosted pointwise and pairwise methods, though it surprisingly had little positive impact on listwise approaches.

Key Results

The primary evaluation metric was nDCG@10. Across the board, optimizing the prompt structure tightened the gap between different ranking algorithms.

As shown in the Flan-T5 evaluations below, pointwise methods showed massive variance based on prompt choice, with the worst prompts performing terribly, but the best prompts climbing up to compete directly with the traditionally dominant pairwise and setwise methods.

Performance variance across ranking families using the FlanT5-large backbone.

Scaling the model size generally stabilized performance. Moving from Flan-T5-Large to Flan-T5-XL reduced the downward variance of the rankers, making them more robust to poor prompt choices.

Performance variance across ranking families using the FlanT5-xl backbone.

Limitations and Future Work

  • API Costs and Closed Models: Due to the massive scale of the experiments (requiring over 12,400 GPU-hours), the authors restricted their study to open-source models under 11B parameters, leaving proprietary giants like GPT-4 unexamined.
  • Latency Ignored: While adding accessory components like role-playing or explanations improves nDCG@10, it increases prompt length and generation time, which impacts real-world production latency.
  • The Infinite Search Space: 1,248 prompts is a massive evaluation, but it only scratches the surface of possible natural language permutations.

The authors conclude that manual prompt engineering is an inefficient way to design LLM rankers. Instead, future work should focus on leveraging automated prompt optimization and self-optimizing LLM loops to dynamically tailor instructions to specific datasets and backbones.

Summary updated

BibTeX
@misc{sun2024investigation,
  author = {Shuoqi Sun and Shengyao Zhuang and Shuai Wang and Guido Zuccon},
  title = {{An Investigation of Prompt Variations for Zero-shot LLM-based Rankers}},
  year = {2024},
  eprint = {2406.14117},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.14117},
}
Figure