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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_postprocessor_rankllm_rerank-0.7.0.tar.gz.

File metadata

  • Download URL: llama_index_postprocessor_rankllm_rerank-0.7.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_postprocessor_rankllm_rerank-0.7.0.tar.gz
Algorithm Hash digest
SHA256 b8719136114853c567bfc08a6a790d9d353abdce04665889818c558eec9422ea
MD5 4cf2ddd01d6296a1f665b1af10f6a6d8
BLAKE2b-256 df3f2f86e99baa6814d3f17a4a919f26230db669c0c138430d460c7797adc662

See more details on using hashes here.

File details

Details for the file llama_index_postprocessor_rankllm_rerank-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_postprocessor_rankllm_rerank-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_postprocessor_rankllm_rerank-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4e4138880ee7e11c7d9d7c710e0dd62ce4075ecc2483c36abde35d077092045
MD5 6ff1224c8c0d288366cf5aa9822e8d62
BLAKE2b-256 7af286e94119ac5a7e236191f3a0042e8d03e5faeed12b5c4cf5d97ec5ce6874

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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