Contextual AI Rerank v2

Open weights + hosted API · Contextual AI ·

Instruction-followingWeights: non-commercialHosted API

Contextual AI Rerank v2 is built to take an instruction next to the query, such as “prioritise recent internal documents”, and rank by relevance first and the instruction second. It comes as open weights in three sizes (1B, 2B and 6B, 100+ languages, up to 32K tokens) under a non-commercial licence, and as a paid hosted API for commercial use.

Weights or API

RouteModelsLicence or priceLimits
Open weightsv2 in 1B, 2B and 6B sizes (for example ctxl-rerank-v2-instruct-multilingual-2b), plus quantised versionsCC BY-NC-SA 4.0: non-commercial onlyUp to 32K tokens
Hosted API, v2ctxl-rerank-v2-instruct-multilingual$0.05 per 1M tokens8,000 tokens for query, instruction and each document; 400,000 per request
Hosted API, v2-minictxl-rerank-v2-instruct-multilingual-mini$0.02 per 1M tokens

The API also still serves the older ctxl-rerank-v1-instruct. Contextual doesn’t say which open-weight size the API’s v2 and v2-mini correspond to, so don’t assume a benchmark of one carries over to the other.

Writing instructions

Contextual evaluated instructions about four things: recency, document type, source and metadata. Some practical points from their documentation:

For the general pattern and how to evaluate instruction rerankers, see instruction-following rerank.

Quick start

Open weights, with sentence-transformers

pip install sentence-transformers

import torch
from sentence_transformers import CrossEncoder

model = CrossEncoder(
    "ContextualAI/ctxl-rerank-v2-instruct-multilingual-2b",
    model_kwargs={"dtype": torch.bfloat16},
)
query = "What are the health benefits of exercise?"
documents = [
    "Regular exercise reduces risk of heart disease and improves mental health.",
    "A 2024 study shows exercise enhances cognitive function in older adults.",
]
rankings = model.rank(query, documents, prompt="Prioritize recent medical research")

The instruction goes in prompt and is optional. Scores are raw logits, higher meaning more relevant. For production serving the model card recommends vLLM.

Hosted API

curl https://api.contextual.ai/v1/rerank \
  -H "Authorization: Bearer $CONTEXTUAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "ctxl-rerank-v2-instruct-multilingual",
       "query": "What are the health benefits of exercise?",
       "instruction": "Prioritize recent medical research",
       "documents": ["...", "..."], "top_n": 5}'

Scores

Contextual publish their benchmark results only as charts, in their launch post: instruction-following, question answering, BEIR, multilingual and product search, each plotted against price. There is no table to cite, so this site shows no number for it. They also released the three instruction-following datasets they used, so you can rerun that part yourself.

When to pick Contextual AI

Pros and cons

Pros

  • Instruction-following, with metadata passed alongside documents
  • 100+ languages and up to 32K tokens
  • Three open sizes, plus quantised versions
  • Hosted API priced per token

Cons

  • Weights are non-commercial (CC BY-NC-SA 4.0)
  • Benchmarks only as charts, no table
  • The API’s models aren’t mapped to the open sizes
  • GPU required; too large for our in-browser demo

Test an instruction on your own data

Rerank the same candidates with and without an instruction, on labelled queries, and check the instruction moves the documents you meant it to.

Instruction rerank guide → All models →

Other models