RankLLM: A Python Package for Reranking with LLMs

Sahel Sharifymoghaddam, Ronak Pradeep, Andre Slavescu, Ryan Nguyen, Andrew Xu, Zijian Chen, Yilin Zhang, Yidi Chen, Jasper Xian, Jimmy Lin

Introduction

In modern Information Retrieval (IR), search is typically a multi-stage process. A fast "retriever" (e.g., BM25) identifies a set of candidate documents, which are then re-ordered by a more sophisticated "reranker" to maximize relevance. Recently, Large Language Models (LLMs) used as "prompt-decoders" have achieved state-of-the-art performance, particularly through listwise reranking. However, the field has lacked a unified framework, often relying on fragmented, model-specific scripts.

RankLLM is an open-source Python library designed to bridge this gap. It provides a modular framework for document reranking using both proprietary (e.g., GPT-4, Gemini) and open-source (e.g., Llama, Vicuna) LLMs, supporting pointwise, pairwise, and listwise strategies.

System Architecture

RankLLM is built on a modular architecture that separates data handling, model inference, and evaluation. This design allows researchers to easily swap components and integrate the library into existing Retrieval-Augmented Generation (RAG) pipelines.

The RankLLM system architecture, illustrating the flow from dataset retrieval to reranking, training, and evaluation.

Key technical features include:

  • Unified Model Coordinators: The package abstracts differences between API-based models and local models served via high-throughput engines like vLLM or SGLang.
  • Robust Response Processing: Includes a "graceful degradation" module to handle cases where LLMs fail to follow formatting instructions (e.g., missing IDs), ensuring a valid ranked list is always returned.
  • Specialized Training Module: Supports fine-tuning LLMs using specialized Learning-to-Rank (LTR) losses like RankNet and LambdaRank, which prioritize accuracy at the top of the results list.

Reranking Paradigms

RankLLM supports three primary reranking paradigms: pointwise, pairwise, and listwise. Standardizing these interfaces allows for direct comparison between different ranking methodologies.

Comparison of (a) Pointwise, (b) Pairwise, and (c) Listwise reranking strategies. The listwise approach (c) utilizes a sliding window to process documents in context.
  • Pointwise: Scores each document independently against the query.
  • Pairwise: Compares pairs of documents to determine relative order.
  • Listwise: Processes multiple documents simultaneously. RankLLM implements a sliding window algorithm to handle lists exceeding the model's context window, allowing relevant documents to "bubble up" to the top of the list through overlapping chunks.

Evaluation and Results

The library was evaluated using industry-standard benchmarks including TREC Deep Learning Tracks (2019–2023), BEIR, Mr.TyDi, and MS MARCO V1. Results on the DL19 dataset (measured by nDCG@10) demonstrate the effectiveness of the listwise approach:

  • BM25 (Baseline): 0.5058
  • MonoT5 (Pointwise): 0.7174
  • RankGPT (Listwise/GPT-4o-mini): 0.7338
  • RankZephyr (Listwise/Open-source): 0.7412

These findings highlight that specialized open-source models like RankZephyr can outperform proprietary models when properly fine-tuned for ranking tasks.

Conclusion

RankLLM standardizes the "User Journey" for LLM-based reranking, making advanced listwise techniques accessible for both research and production. Future work will focus on reducing inference latency and expanding the framework to support additional IR tasks such as query expansion and summarization within the same pipeline.

Summary updated

BibTeX
@inproceedings{sharifymoghaddam2025rankllm,
  author = {Sahel Sharifymoghaddam and Ronak Pradeep and Andre Slavescu and Ryan Nguyen and Andrew Xu and Zijian Chen and Yilin Zhang and Yidi Chen and Jasper Xian and Jimmy Lin},
  title = {{RankLLM: A Python Package for Reranking with LLMs}},
  booktitle = {International ACM SIGIR Conference on Research and Development in Information Retrieval},
  year = {2025},
}
Figure