AI · 08 — Rerank (best results first)

Search gave you four candidate snippets — the ◈-wired Rerank has a local model JUDGE which ones actually answer the query and keeps the top two. This is the quality step between retrieval and the final prompt.

What’s inside

5 nodes — every type links to its full reference page.

StepNodeType
Search results Inject input.inject
Rerank AI Rerank ai.rerank
Ollama (local) AI Model ai.model
Format JavaScript utility.javascript
Ranked Console utility.console

Import it

  1. Studio → Import — paste the JSON below (or the URL /docs/templates/ai-08-rerank-best-results-first.json).
  2. Or ask the AI Copilot with the JSON pasted after the phrase:
    import this workflow json into a new workflow named "AI · 08 — Rerank (best results first)"
  3. Any credentials the nodes need are ${credential.…} references — add them once in Admin → Credentials and the template picks them up. Nothing secret ships in a template.
The workflow document (flowdrome.workflow.v1, 5 node types)
{
  "schemaVersion": "flowdrome.workflow.v1",
  "id": "",
  "name": "AI · 08 — Rerank (best results first)",
  "version": "0",
  "status": "draft",
  "nodes": [
    {
      "id": "seed",
      "type": "input.inject",
      "label": "Search results",
      "category": "trigger",
      "config": {
        "contentType": "application/json",
        "payload": {
          "query": "password reset emails are not arriving",
          "matches": [
            {
              "text": "How to change your profile picture"
            },
            {
              "text": "Fixing email delivery for password reset messages"
            },
            {
              "text": "Billing FAQ: invoices and receipts"
            },
            {
              "text": "Troubleshooting SMTP configuration for outbound mail"
            }
          ]
        }
      },
      "position": {
        "x": 0,
        "y": 0
      }
    },
    {
      "id": "rank",
      "type": "ai.rerank",
      "label": "Rerank",
      "category": "ai",
      "config": {
        "provider": "llm",
        "judgeProvider": "ollama",
        "baseUrl": "",
        "apiKey": "",
        "model": "qwen2.5:1.5b",
        "queryField": "query",
        "documentsField": "matches",
        "topK": 2,
        "timeoutMs": 120000
      },
      "position": {
        "x": 530,
        "y": 0
      },
      "attachments": {
        "model": "llm"
      }
    },
    {
      "id": "llm",
      "type": "ai.model",
      "label": "Ollama (local)",
      "category": "ai",
      "config": {
        "provider": "ollama",
        "baseUrl": "",
        "apiKey": "",
        "model": "qwen2.5:1.5b",
        "models": [],
        "temperature": 0.2,
        "maxTokens": 512
      },
      "position": {
        "x": 530,
        "y": 222
      }
    },
    {
      "id": "fmt",
      "type": "utility.javascript",
      "label": "Format",
      "category": "script",
      "config": {
        "code": "return { ranked: (input.matches || []).map(function (m, i) { return (i + 1) + '. ' + m.text; }).join('  |  ') };",
        "outputs": [
          "output"
        ]
      },
      "position": {
        "x": 1060,
        "y": 0
      }
    },
    {
      "id": "out",
      "type": "utility.console",
      "label": "Ranked",
      "category": "utility",
      "config": {
        "message": "Top matches → {{ $json.ranked }}"
      },
      "position": {
        "x": 1590,
        "y": 0
      }
    }
  ],
  "edges": [
    {
      "id": "e0",
      "sourceNodeId": "seed",
      "sourcePort": "output",
      "targetNodeId": "rank",
      "targetPort": "input"
    },
    {
      "id": "e1",
      "sourceNodeId": "rank",
      "sourcePort": "output",
      "targetNodeId": "fmt",
      "targetPort": "input"
    },
    {
      "id": "e2",
      "sourceNodeId": "fmt",
      "sourcePort": "output",
      "targetNodeId": "out",
      "targetPort": "input"
    }
  ],
  "triggers": [
    {
      "id": "t0",
      "nodeId": "seed"
    }
  ],
  "meta": {
    "snippets": [],
    "source": "template-gallery",
    "description": "Search gave you four candidate snippets — the ◈-wired Rerank has a local model JUDGE which ones actually answer the query and keeps the top two. This is the quality step between retrieval and the final prompt."
  }
}

Generated from the verified demo corpus — this exact document seeds and runs on a fresh Flowdrome. Raw JSON: ai-08-rerank-best-results-first.json.