/rerank

Rerank

Rank a list of documents according to their relevance to a query and your custom instructions about how to prioritize retrievals. We evaluated the model on instructions for recency, document type, source, and metadata, and it can generalize to other instructions as well.

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

post/rerank

Request body

querystring required

The string against which documents will be ranked for relevance

documentsstring[] required

The texts to be reranked according to their relevance to the query and the optional instruction

modelstring required

The version of the reranker to use. Currently, we just have "ctxl-rerank-en-v1-instruct".

top_ninteger

The number of top-ranked results to return

instructionstring

Instructions that the reranker references when ranking retrievals. We evaluated the model on instructions for recency, document type, source, and metadata, and it can generalize to other instructions as well. Note that we do not guarantee that the reranker will follow these instructions exactly. Examples: "Prioritize internal sales documents over market analysis reports. More recent documents should be weighted higher. Enterprise portal content supersedes distributor communications." and "Emphasize forecasts from top-tier investment banks. Recent analysis should take precedence. Disregard aggregator sites and favor detailed research notes over news summaries."

metadatastring[]

Metadata for documents being passed to the reranker. Must be the same length as the documents list. If a document does not have metadata, add an empty string.

Response

Successful Response

Changes