Skip to content

Rerank

Score and reorder retrieved passages against a query with local cross-encoder models, for sharper RAG results

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/rerank/index.md to help me query Rerank with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Rank search passages by relevance

Example output Β· captured
Connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT doc
FROM (VALUES ('Reset your password from the account settings page.'), ('Our office is open from 9am to 5pm.')) AS t(doc)
ORDER BY rerank.main.rerank_score('how do I reset my password', doc) DESC;
Result
doc
Reset your password from the account settings page.
Our office is open from 9am to 5pm.

Quick start

Choose where to run Rerank, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'rerank' AS rerank (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-rerank-worker'
);

3. Run a query

query.sql
SELECT doc
FROM (VALUES ('Reset your password from the account settings page.'), ('Our office is open from 9am to 5pm.')) AS t(doc)
ORDER BY rerank.main.rerank_score('how do I reset my password', doc) DESC;
More example queries β†’
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'rerank' AS rerank (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-rerank-worker'
);

Overview

Local cross-encoder reranking (fastembed/ONNX) for second-stage RAG precision.

Catalog

Everything rerank exposes once attached β€” read straight from the worker's released build.

rerank 1 schema
main 1 table Β· 1 function

Local cross-encoder reranking (fastembed/ONNX) for second-stage RAG precision

Schema examples (2)
Examples (2)

Score a (query, document) pair with the default model.

SELECT rerank.main.rerank_score('how do I reset my password', 'Click the forgot password link to reset it.');

List the available reranker models and their licenses.

SELECT model, license FROM rerank.main.supported_models() ORDER BY model;
Tables
supported_models 4 examples2 cols

Every cross-encoder reranker model the worker can run, with the license of its weights.

Columns
model VARCHAR
Model name to pass to rerank_score(query, document, model).
licensenot null VARCHAR
SPDX-style license of the model weights (all permissive here).
ConstraintsPRIMARY KEY (model)
Examples (4)

List every supported reranker model and its license.

SELECT model, license FROM rerank.main.supported_models ORDER BY model;

Look up the license of the default model.

SELECT license
FROM rerank.main.supported_models
WHERE model = 'Xenova/ms-marco-MiniLM-L-6-v2';
SELECT model, license FROM rerank.main.supported_models() ORDER BY model;
1 more example
SELECT license
FROM rerank.main.supported_models()
WHERE model = 'Xenova/ms-marco-MiniLM-L-6-v2';
Link
Scalar functions
rerank_score (query VARCHAR, document VARCHAR, model VARCHAR) +1 overload 4 examples

Cross-encoder relevance score (DOUBLE) for a (query, document) pair using the default model (Xenova/ms-marco-MiniLM-L-6-v2). Higher = more relevant; the value is a raw logit, meaningful only RELATIVE to other documents for the SAME query. Intended for ORDER BY rerank_score(:q, doc) DESC LIMIT k over a top-K candidate set. NULL/empty query or document -> NULL.

Arguments
query VARCHAR
Search query (usually a constant broadcast across the rows)
document VARCHAR
Candidate document/passage to score against the query
model VARCHAR
Model name; see supported_models()
Overloads
rerank_score(query VARCHAR, document VARCHAR) β†’ DOUBLErerank_score(query VARCHAR, document VARCHAR, model VARCHAR) β†’ DOUBLE
ReturnsDOUBLE
Examples (4)

Score one (query, document) pair with the default model.

SELECT rerank.main.rerank_score('how do I reset my password', 'Click the forgot password link to reset it.');

Score a pair with an explicitly chosen reranker model.

SELECT rerank.main.rerank_score('reset password', 'Reset your password from the account settings page.', 'Xenova/ms-marco-MiniLM-L-6-v2');
SELECT rerank.main.rerank_score('how do I reset my password', 'Click the forgot password link to reset it.') AS score;
1 more example
SELECT doc
FROM (VALUES ('Reset your password from the account settings page.'), ('Our office is open from 9am to 5pm.')) AS t(doc)
ORDER BY rerank.main.rerank_score('how do I reset my password', doc) DESC;
Result
doc
Reset your password from the account settings page.
Our office is open from 9am to 5pm.
Link

Try these queries

Score a (query, document) pair with the default model.

SELECT rerank.main.rerank_score('how do I reset my password', 'Click the forgot password link to reset it.')

Uses rerank_score

List the available reranker models and their licenses.

SELECT model, license FROM rerank.main.supported_models() ORDER BY model

List every supported reranker model and its license.

SELECT model, license FROM rerank.main.supported_models ORDER BY model

Uses supported_models

Look up the license of the default model.

SELECT license
FROM rerank.main.supported_models
WHERE model = 'Xenova/ms-marco-MiniLM-L-6-v2'

Uses supported_models

Look up the license of the default model.

SELECT license
FROM rerank.main.supported_models()
WHERE model = 'Xenova/ms-marco-MiniLM-L-6-v2'

Score a pair with an explicitly chosen reranker model.

SELECT rerank.main.rerank_score('reset password', 'Reset your password from the account settings page.', 'Xenova/ms-marco-MiniLM-L-6-v2')

Uses rerank_score

1 more example in the Catalog, each listed under the table or function it uses.

Rerank is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.