Skip to main content

rerankSearchResults

Takes a list of vector search results and a query, then reorders them by relevance using either a dedicated reranker model (RunPod or Replicate) or an LLM-based scoring fallback. Returns the top-K results with both original similarity scores and new rerank scores.

Execution path:

  1. If use_dedicated_reranker is true and provider is not "llm", calls a dedicated reranker (RunPod / Replicate). Falls through to the LLM path on failure.
  2. Otherwise, computes relevance scores via qwen3-235b-a22b-instruct-2507 on Scaleway AI.
  3. If the LLM response cannot be parsed, the original similarity scores are used as-is.

An empty search_results input returns immediately with count: 0.

Parameters

ParamTypeRequiredDefaultDescription
search_resultsSearchResult[]YesList of results to rerank. Each item must have page_content, metadata, and score
querystringYesOriginal search query. Minimum length: 1
top_kintegerNo5Number of top results to return after reranking
rerank_modelstringNo"BAAI/bge-reranker-large"Model to use when using a dedicated reranker
providerstring?NonullForce a specific provider: runpod, replicate, or llm. Auto-detected from model when null
use_dedicated_rerankerbooleanNotrueWhen true, attempts dedicated reranker before falling back to LLM scoring

Output

FieldTypeDescription
ranked_resultsRankedResult[]Reranked results, ordered by rerank_score descending, truncated to top_k
countintegerNumber of results returned
providerstringProvider used: runpod, replicate, llm, none (empty input), or error
modelstringModel used for reranking

Each RankedResult:

FieldTypeDescription
page_contentstringText content of the chunk
metadataobjectDocument metadata
similarity_scorefloatOriginal similarity score from the vector search
rerank_scorefloatScore assigned by the reranker
final_rankinteger1-based position in the final ordered list

Example

{
"id": "rerank",
"type": "rerankSearchResults",
"data": {
"label": "Rerank Results",
"isExecuted": false,
"handles": ["inputs", "outputs"],
"schema": {},
"params": {
"search_results": { "value": "{{ @vectorSearch.documents }}", "isExpression": true, "isAttachedToInputNode": false },
"query": { "value": "{{ $input.query }}", "isExpression": true, "isAttachedToInputNode": false },
"top_k": { "value": 5, "isExpression": false, "isAttachedToInputNode": false },
"use_dedicated_reranker": { "value": true, "isExpression": false, "isAttachedToInputNode": false }
},
"inputs": [], "outputs": [], "errors": []
},
"position": { "x": 300, "y": 0 },
"isSelected": false,
"isDragging": false
}