Skip to main content

Contextual Reranker

This is a Llama_index package that calls Contextual's /rerank endpoint. It will rank a list of documents according to their relevance to a query.

The total request cannot exceed 400,000 tokens. The combined length of any document, instruction and the query must not exceed 4,000 tokens. Email rerank-feedback@contextual.ai with any feedback or questions.

Usage

from llama_index.postprocessor.contextual_rerank import ContextualRerank
from llama_index.core.schema import NodeWithScore, TextNode

nodes = [
    NodeWithScore(node=TextNode(text="the capital of france is paris")),
    NodeWithScore(
        node=TextNode(text="the capital of the United States is Washington DC")
    ),
]

query = "What is the capital of France?"

contextual_rerank = ContextualRerank(
    api_key="key-...",
    model="ctxl-rerank-en-v1-instruct",
    top_n=2,
)

response = contextual_rerank.postprocess_nodes(nodes, query_str=query)

for node in response:
    print(node)

Metadata

Release files for llama-index-postprocessor-contextual-rerank 0.5.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-contextual-rerank 0.5.0
File Size Uploaded Provenance Actions
llama_index_postprocessor_contextual_rerank-0.5.0.tar.gz 3.8 kB Without provenance Details for llama_index_postprocessor_contextual_rerank-0.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 8.2 kB

Release files / llama_index_postprocessor_contextual_rerank-0.5.0.tar.gz

Download URL llama_index_postprocessor_contextual_rerank-0.5.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7570ae3198c45b480f448f0f85af0f7dc4f2b79e6bedb513b640676556bd3736
BLAKE2b-256 checksum
How to use checksums
c74b46d529b2302087a368abdc5b3fd710ccb2ed1b8167329784073cd43ebcdc
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_contextual_rerank-0.5.0-py3-none-any.whl

Download URL llama_index_postprocessor_contextual_rerank-0.5.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab9d4c93202e7356bf94414806f41a28e49543ca7a2e64120891a50667fa8f83
BLAKE2b-256 checksum
How to use checksums
9ff9269cf53d1c3a391b8d6579f9a77e711aa86f6d65eee363aa0f76250a7cf5
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-contextual-rerank 0.5.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