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.4.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.4.0
File Size Uploaded Provenance Actions
llama_index_postprocessor_contextual_rerank-0.4.0.tar.gz 3.8 kB Without provenance Details for llama_index_postprocessor_contextual_rerank-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 8.2 kB

Release files / llama_index_postprocessor_contextual_rerank-0.4.0.tar.gz

Download URL llama_index_postprocessor_contextual_rerank-0.4.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5026db0673b039903eb1408c2524a1e95e5376f408c1dc41f3813dca1812d053
BLAKE2b-256 checksum
How to use checksums
22a766826f633bbbed1a29d53ba612079e1aaa6c51f26863502ecc1ac32c7849
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / llama_index_postprocessor_contextual_rerank-0.4.0-py3-none-any.whl

Download URL llama_index_postprocessor_contextual_rerank-0.4.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0ace3d8325f9a6e3112d2f9d35a9dba4c304139ab3c29842414f5f4cf3b5e7e
BLAKE2b-256 checksum
How to use checksums
389538695133572f3cb5e494820306f28c2dfabb9b3fc28321efa30f47517039
Upload date
Uploaded using Trusted Publishing?
What is 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}

Security for llama-index-postprocessor-contextual-rerank 0.4.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