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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_postprocessor_contextual_rerank-0.1.0.tar.gz.
File metadata
- Download URL: llama_index_postprocessor_contextual_rerank-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e410514f30566fec7c3d2841d1c466d0fff821912a38c024e9c4aab072c62dac
|
|
| MD5 |
83fac12963a12f939483b27a5a361490
|
|
| BLAKE2b-256 |
e1c0160f364d5ef4c74065bcc9ff954b5f38593442881aba42dd95b1d59b4020
|
File details
Details for the file llama_index_postprocessor_contextual_rerank-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_postprocessor_contextual_rerank-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
578cb736dd4f22ddda50985b93f84936ef10a4e13ff334cefaa6b8df6893683f
|
|
| MD5 |
a706087e5db8c63545d9aad1e6530fc1
|
|
| BLAKE2b-256 |
9c3111b126161b64caa7fcdb2a6f2523b7cdb71cd2095a9fff44ad5c08294e87
|