A reranking model rescores retrieved documents and promotes the most relevant results, improving search precision when initial retrieval prioritizes speed over accuracy.
When reranking adds the most value: Reranking works best when initial retrieval returns 20–100+ candidates with mixed relevance, and adds little when results are already precise (such as exact keyword matches). A typical RAG workflow retrieves 50–100 candidates with an embedding model, then reranks to select the top 5–10 for a large language model.
Prerequisites
Obtain an API key, set it as an environment variable, and install the SDK.
Rerank documents
Pass a query and a list of candidate documents to the API. The model returns the documents sorted by relevance.
Text reranking (qwen3-rerank)
- OpenAI compatible
- DashScope
Multimodal reranking (qwen3-vl-rerank)
The qwen3-vl-rerank model reranks text, images, and videos. The query can be text or an image, and documents can contain any combination of these modalities.
Multimodal reranking is available only through the DashScope SDK or API, not the OpenAI-compatible endpoint.
Python
Core features
Reranking with instructions (instruct)
The instruct parameter sets the ranking strategy. Write instructions in English.
-
Question answering retrieval (default):
"Given a web search query, retrieve relevant passages that answer the query."Focuses on finding answers. For "How to prevent a cold?", "Washing hands frequently can prevent colds" scores higher than "A cold is a common illness," which is topically relevant but not an answer. -
Semantic similarity:
"Retrieve semantically similar text."Focuses on semantic equivalence, robust to wording differences. "How do I change my password?" matches "What if I forgot my password?" — useful for FAQ deduplication.
OpenAI compatible
Return the top N results (top_n)
Use top_n to return only the highest-ranked documents. If top_n is not set, all documents are returned sorted by relevance. If top_n exceeds the input document count, all documents are returned.
Model overview
- Singapore
- Beijing
Model | Max documents | Max tokens per document | Max tokens per request | Supported languages | Use cases |
|---|---|---|---|---|---|
qwen3-rerank | 500 | 32,768 | 120,000 | 100+ languages | Semantic text search, RAG applications |
- Max tokens per document: Max tokens for a single query or document. Excess content is truncated, which may reduce accuracy.
- Max documents: Maximum documents per request. For qwen3-vl-rerank, this limit varies by document type (text, image, video, or mixed).
- Max tokens per request: Calculated as
Query Tokens × Number of Documents + Total Document Tokens.