Universal Reranker (flow)
AI-generatedSummary
Rerank documents against a query using an OpenAI‑compatible endpoint or the Cohere rerank API, returning the top‑K results that meet a relevance threshold.
Inputs
- query (required) — The search query to rerank documents against.
- documentsField (required) — Field name on each input item that holds the array of documents to rerank.
- service (required) — Reranking service to use: openai-compatible or cohere.
- endpoint — URL of the OpenAI‑compatible reranker endpoint (shown when service is openai-compatible).
- model — Model identifier for the OpenAI‑compatible reranker (shown when service is openai-compatible).
- enableCustomTemplates — Whether to use custom query/document templates for special models (shown when service is openai-compatible).
- templatePreset — Template preset to use when custom templates are enabled (shown when service is openai-compatible and enableCustomTemplates is true).
- instruction — Instruction used by the Qwen3 template (shown when service is openai-compatible, enableCustomTemplates is true and templatePreset is qwen3).
- queryPrefix — Text prepended to the query when using custom templates (shown when service is openai-compatible, enableCustomTemplates is true and templatePreset is custom).
- querySuffix — Text appended to the query when using custom templates (shown when service is openai-compatible, enableCustomTemplates is true and templatePreset is custom).
- documentPrefix — Text prepended to each document when using custom templates (shown when service is openai-compatible, enableCustomTemplates is true and templatePreset is custom).
- documentSuffix — Text appended to each document when using custom templates (shown when service is openai-compatible, enableCustomTemplates is true and templatePreset is custom).
- cohereModel — Cohere model to use (shown when service is cohere).
- cohereCustomModel — Custom Cohere model name when cohereModel is set to custom (shown when service is cohere).
- topK (required) — Maximum number of documents to return after reranking.
- threshold (required) — Minimum relevance score (0‑1) a document must have to be included in the output.
- includeOriginalScores (required) — Whether to keep the original document scores in the output.
- enableCache (required) — Whether to cache reranking results to speed up repeated queries.
- cacheTtl — Time‑to‑live for cached results in minutes (shown when enableCache is true).
Output shape
Each input item is returned with the following additional fields:
All original input fields are preserved; the node adds these properties: rerankedDocs (array of reranked documents), originalCount (number of documents before reranking), rerankedCount (number after applying topK and threshold), query (the query used for this operation).
Examples
Example 1: Rerank a list of search snippets against a user question using a local vLLM endpoint.
Set service to openai-compatible, endpoint to http://localhost:8000/v1/rerank, model to BAAI/bge-reranker-v2-m3, topK to 5, threshold to 0.3.
Example 2: Use Cohere’s multilingual reranker to reorder product descriptions.
Set service to cohere, cohereModel to rerank-multilingual-v3.0, provide your Cohere API key via credentials, topK to 10, threshold to 0.