--- library_name: transformers license: cc-by-nc-sa-4.0 pipeline_tag: text-ranking ---
[](https://contextual.ai/blog/rerank-v2)
[](https://huggingface.co/collections/ContextualAI/contextual-ai-reranker-v2)
For detailed benchmarks, see our [blog post](https://contextual.ai/blog/rerank-v2).
## Overview
- **Model Type**: Text Reranking
- **Supported Languages**: 100+
- **Parameters**: 1B
- **Precision**: NVFP4 (4-bit floating point)
- **Context Length**: up to 32K
## When to Use This Model
Use this reranker when you need to:
- Re-rank retrieved documents with custom instructions
- Handle conflicting information in retrieval results
- Prioritize documents by recency or other criteria
- Support multilingual search (100+ languages)
- Process long contexts (up to 32K tokens)
- **Maximize efficiency with 4-bit precision (NVFP4)**
## Quickstart
### Basic Usage
```python
# Requires vLLM==0.10.0 for NVFP4 support
# See full implementation below
model_path = "ContextualAI/ctxl-rerank-v2-instruct-multilingual-1b-nvfp4"
query = "What are the health benefits of exercise?"
instruction = "Prioritize recent medical research"
documents = [
"Regular exercise reduces risk of heart disease and improves mental health.",
"A 2024 study shows exercise enhances cognitive function in older adults.",
"Ancient Greeks valued physical fitness for military training."
]
infer_w_vllm(model_path, query, instruction, documents)
```
**Expected Output:**
```
Query: What are the health benefits of exercise?
Instruction: Prioritize recent medical research
Score: 0.8542 | Doc: A 2024 study shows exercise enhances cognitive function in older adults.
Score: 0.7891 | Doc: Regular exercise reduces risk of heart disease and improves mental health.
Score: 0.4123 | Doc: Ancient Greeks valued physical fitness for military training.
```
### vLLM Usage
Requires `vllm==0.10.0` for NVFP4 support.
```python
import os
os.environ['VLLM_USE_V1'] = '0' # v1 engine doesn't support logits processor yet
import torch
from vllm import LLM, SamplingParams
def logits_processor(_, scores):
"""Custom logits processor for vLLM reranking."""
index = scores[0].view(torch.uint16)
scores = torch.full_like(scores, float("-inf"))
scores[index] = 1
return scores
def format_prompts(query: str, instruction: str, documents: list[str]) -> list[str]:
"""Format query and documents into prompts for reranking."""
if instruction:
instruction = f" {instruction}"
prompts = []
for doc in documents:
prompt = f"Check whether a given document contains information helpful to answer the query.\n