Skip to main content

llama-index postprocessor contextual rerank integration

Project description

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)

Project details


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_contextual_rerank-0.3.0.tar.gz.

File metadata

  • Download URL: llama_index_postprocessor_contextual_rerank-0.3.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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_contextual_rerank-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2fd5eaf1f02b0c871fe5877ce4ca2f2c12927797b3a7737267fe55b16b91c5fb
MD5 30397d616fd755793c6ea413a078266f
BLAKE2b-256 2a9cedc732ddcdd1df3ed9ad8a407d425d39991230099148cffa48e563da5f12

See more details on using hashes here.

File details

Details for the file llama_index_postprocessor_contextual_rerank-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_postprocessor_contextual_rerank-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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_contextual_rerank-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33431204e541f592538cddb3c69382d50e36b2d91e549c74773fa1265971bb2c
MD5 88f3200bd72ba7f2fbd87bf350372a22
BLAKE2b-256 f4e7e0af65c1c7f89504f56ec92677310c00df2dcbb2dc0774670566df2ea447

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page