RankLLM: A Python Package for Reranking with LLMs
The adoption of large language models (LLMs) as rerankers in multi-stage retrieval systems has gained significant traction in academia and industry. These models refine a candidate list of retrieved documents, often through carefully designed prompts, and are typically used in applications built on retrieval-augmented generation (RAG). This paper introduces RankLLM, an open-source Python package for reranking that is modular, highly configurable, and supports both proprietary and open-source LLMs in customized reranking workflows. To improve usability, RankLLM features optional integration with Pyserini for retrieval and provides integrated evaluation for multi-stage pipelines. Additionally, RankLLM includes a module for detailed analysis of input prompts and LLM responses, addressing reliability concerns with LLM APIs and non-deterministic behavior in Mixture-of-Experts (MoE) models. This paper presents the architecture of RankLLM, along with a detailed step-by-step guide and sample code. We reproduce results from RankGPT, LRL, RankVicuna, RankZephyr, and other recent models. RankLLM integrates with common inference frameworks and a wide range of LLMs. This compatibility allows for quick reproduction of reported results, helping to speed up both research and real-world applications. The complete repository is available at rankllm.ai, and the package can be installed via PyPI.
Authors
- Yidi Chen
- Yilin Zhang
- Jasper Xian (ORCID: https://orcid.org/0009-0004-2740-6120)
- Sahel Sharifymoghaddam (ORCID: https://orcid.org/0009-0008-8337-6930)
- Jimmy Lin (ORCID: https://orcid.org/0000-0002-0661-7189)
- Andre Slavescu (ORCID: https://orcid.org/0009-0002-7618-8356)
- Ronak Pradeep (ORCID: https://orcid.org/0000-0001-6296-601X)
- Ryan Nguyen
- Andrew Xu
- Zijian Chen (ORCID: https://orcid.org/0009-0001-8809-1618)
Institutions
- University of Waterloo (CA)
Publication Details
- Published
- 2025-07-13
- DOI
- https://doi.org/10.1145/3726302.3730331
- Citations
- 4
- Primary Topic
- Natural Language Processing Techniques
- Type
- article
- Field-Weighted Citation Impact
- 9.92