Ollama Reranker Workflow
AI-generatedSummary
Rerank a set of documents based on their relevance to a given query using an Ollama reranker model, a custom rerank API, or a VL Classifier API, returning the top-ranked documents with associated scores and optional complexity metadata.
Inputs
- model (required) — Select the reranker model loaded from the configured Ollama or custom API.
- apiType — Choose the API endpoint to use for reranking: Custom Rerank API (recommended for true cross-encoder scoring), VL Classifier API for document complexity classification, or the experimental Ollama Generate API (heuristic scoring).
- query (required) — The query string against which documents are scored and reranked.
- documentsSource (required) — Specify source of documents: use all input items as documents, extract from a specific field containing documents array, or use a custom expression.
- documentField — When extracting documents from a field, name of the field containing the document array.
- documentsExpression — Expression to evaluate to get the documents array when using an expression as documents source.
- contentField — Field name containing document text when input items are used as documents.
- topK — Maximum number of top documents to return after reranking.
- threshold — Minimum relevance score (0-1) a document must have to be included in results.
- instruction — Custom instruction guiding the reranking task, sent to the model as part of the prompt.
- additionalOptions — Collection of optional settings including whether to include original document scores; request timeout; batch size for concurrent processing; output format (full documents with scores or simple array of document contents); and, if using Vision-Language classification API, options to enable classification, set classification strategy (filter, metadata, or both), and filter by document complexity level.
Output shape
A list of reranked document objects or a simple array of their contents, paired one-to-one with input items processed individually.
Processes each input item independently, applying reranking based on selected model and API. Returns results matched to input items, including documents with rerank scores and optional metadata. If no documents provided for an item, returns an empty array with a message. Supports output as full objects with metadata or simplified array of content strings. Errors per item are handled depending on node's continueOnFail setting.
Examples
Example 1: Reranking documents from input items
Configure the node with a selected model, set Documents Source to 'From Input Items', specify the content field name containing the text, provide the query expression, and adjust Top K and threshold as needed. The node processes each input item as a document, sending batch requests to rerank them and outputs the top relevant documents.