Skip to main content

LlamaIndex Postprocessor Integration: Rankllm-Rerank

RankLLM offers a suite of rerankers, albeit with focus on open source LLMs finetuned for the task. To use a model offered by the RankLLM suite, pass the desired model's Hugging Face model path, found at Castorini's Hugging Face.

e.g., to access LiT5-Distill-base, pass castorini/LiT5-Distill-base as the model name.

For more information about RankLLM and the models supported, visit rankllm.ai. Please pip install llama-index-postprocessor-rankllm-rerank to install RankLLM rerank package.

Parameters:

  • model: Reranker model name
  • top_n: Top N nodes to return from reranking
  • window_size: Reranking window size. Applicable only for listwise and pairwise models.
  • batch_size: Reranking batch size. Applicable only for pointwise models.

Model Coverage

Below are all the rerankers supported with the model name to be passed as an argument to the constructor. Some model have convenience names for ease of use:

Listwise:

  • RankZephyr. model=rank_zephyr or castorini/rank_zephyr_7b_v1_full
  • RankVicuna. model=rank_zephyr or castorini/rank_vicuna_7b_v1
  • RankGPT. Takes in a valid gpt model. e.g., gpt-3.5-turbo, gpt-4,gpt-3
  • LiT5 Distill. model=castorini/LiT5-Distill-base
  • LiT5 Score. model=castorini/LiT5-Score-base

Pointwise:

  • MonoT5. model='monot5'

💻 Example Usage

pip install llama-index-core
pip install llama-index-llms-openai
from llama_index.postprocessor.rankllm_rerank import RankLLMRerank

First, build a vector store index with llama-index.

index = VectorStoreIndex.from_documents(
    documents,
)

To set up the retriever and reranker:

query_bundle = QueryBundle(query_str)

# configure retriever
retriever = VectorIndexRetriever(
    index=index,
    similarity_top_k=vector_top_k,
)

# configure reranker
reranker = RankLLMRerank(
    model=model_name
    top_n=reranker_top_n,
)

To run retrieval+reranking:

# retrieve nodes
retrieved_nodes = retriever.retrieve(query_bundle)

# rerank nodes
reranked_nodes = reranker.postprocess_nodes(
    retrieved_nodes, query_bundle
)

🔧 Dependencies

Currently, RankLLM rerankers require CUDA and for rank-llm to be installed (pip install rank-llm). The built-in retriever, which uses Pyserini, requires JDK11, PyTorch, and Faiss.

castorini/rank_llm

Repository for prompt-decoding using LLMs: http://rankllm.ai

Metadata

Release files for llama-index-postprocessor-rankllm-rerank 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-postprocessor-rankllm-rerank 0.8.0
File Size Uploaded Provenance Actions
llama_index_postprocessor_rankllm_rerank-0.8.0.tar.gz 5.9 kB Without provenance Details for llama_index_postprocessor_rankllm_rerank-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-postprocessor-rankllm-rerank 0.8.0
File Interpreter ABI Platform Actions
llama_index_postprocessor_rankllm_rerank-0.8.0-py3-none-any.whl Python 3 none any Details for llama_index_postprocessor_rankllm_rerank-0.8.0-py3-none-any.whl

Total release size: 11.8 kB

Release files / llama_index_postprocessor_rankllm_rerank-0.8.0.tar.gz

Download URL llama_index_postprocessor_rankllm_rerank-0.8.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8bbbe6b7e826df46fe042237852542a518c24f3a73fb66cc30f726ded35a9d6e
BLAKE2b-256 checksum
How to use checksums
9b69913dc6fbfc91892e65a7ca99b30de2ee3efd062323b7e2c92f80f0246321
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llama_index_postprocessor_rankllm_rerank-0.8.0-py3-none-any.whl

Download URL llama_index_postprocessor_rankllm_rerank-0.8.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07a7e779cdf6d1a1c2fae04a30e0b625cec7efd43fd0ddeb5de3a63fef42df1d
BLAKE2b-256 checksum
How to use checksums
e35b2bc865abc120f4f6192450e7f7726d5504fbce6e7c2a1d5e996c4586e5ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for llama-index-postprocessor-rankllm-rerank 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page