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.2.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_postprocessor_contextual_rerank-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e681ba4f1d55c24cdae18a99dd0838a71ad87d0204f2a4db79f43b426915d0c2
MD5 6553a21955e3272a60369a78fd51301f
BLAKE2b-256 bf852fe1b87d886ac29f6bf5a3b31e7ba2a444ef476f6025ac37ea3d62c605eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_postprocessor_contextual_rerank-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36e4741e132a1758400e0a08de58cb70eca0e9d83c76d7962dd8a94278e46a82
MD5 4f01852ac30aa2742b71bd89687cb8c9
BLAKE2b-256 1b91691a0e1b56f327b2a6c67b6a1740861800dade89670a8c6bef193295f620

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