Skip to content

Embed

Turn text into embedding vectors on your own machine and rank it by cosine similarity for semantic search and RAG

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/embed/index.md to help me query Embed 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.

Find the support articles that answer a question

Example output Β· captured
Connector release
v0.6.0
Engine
2.0.1
VGI protocol
3.4.0
WITH docs(id, body) AS (VALUES (1, 'Reset your password from the account settings page.'), (2, 'Our office is closed on public holidays.'), (3, 'Invoices are emailed on the first day of each month.'), (4, 'Forgot your login? Use the password recovery link to sign in again.')), q AS (SELECT embed.main.embed_query('how do I reset my password') AS v) SELECT d.id, d.body, ROUND(embed.main.similarity(q.v, embed.main.embed_passage(d.body)), 3) AS score
FROM docs AS d
CROSS JOIN q
ORDER BY score DESC, d.id
LIMIT 2
Result
id body score
1 Reset your password from the account settings page. 0.831
4 Forgot your login? Use the password recovery link to sign in again. 0.773

Quick start

Choose where to run Embed, 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 'embed' AS embed (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-embed-worker'
);

3. Run a query

query.sql
WITH docs(id, body) AS (VALUES (1, 'Reset your password from the account settings page.'), (2, 'Our office is closed on public holidays.'), (3, 'Invoices are emailed on the first day of each month.'), (4, 'Forgot your login? Use the password recovery link to sign in again.')), q AS (SELECT embed.main.embed_query('how do I reset my password') AS v) SELECT d.id, d.body, ROUND(embed.main.similarity(q.v, embed.main.embed_passage(d.body)), 3) AS score
FROM docs AS d
CROSS JOIN q
ORDER BY score DESC, d.id
LIMIT 2
More example queries β†’
Technical details
Verified connector release
v0.6.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 'embed' AS embed (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-embed-worker'
);

Overview

Local text embeddings (fastembed/ONNX) + cosine similarity for semantic search / RAG.

Catalog

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

embed 1 schema
main 1 view Β· 6 functions

Local text embeddings (fastembed/ONNX) + cosine similarity for SQL

Schema examples (9)
Examples (9)

Embed text into a FLOAT[] vector and check its length.

SELECT len(embed.main.embed('hello world')) AS dim;

Embed text with an explicitly chosen model.

SELECT len(embed.main.embed('hello world', 'BAAI/bge-base-en-v1.5')) AS dim;

Score how related two short texts are (rounded for stable output).

SELECT ROUND(embed.main.similarity(embed.main.embed('cat'), embed.main.embed('kitten')), 3) AS score;

Rank a passage against a search query (asymmetric retrieval).

SELECT ROUND(embed.main.similarity(embed.main.embed_query('how do I reset my password'), embed.main.embed_passage('Reset your password in account settings.')), 3) AS score;
5 more examples

Look up the default model's vector dimension.

SELECT embed.main.embedding_dim('BAAI/bge-small-en-v1.5') AS dim;

List the supported models and their dimensions.

SELECT model, dim FROM embed.main.supported_models() ORDER BY model;

Semantic search: embed the question once with embed_query, embed each corpus passage with embed_passage, rank by similarity and keep the top 2 (both password-help passages).

WITH docs(id, body) AS (VALUES (1, 'Reset your password from the account settings page.'), (2, 'Our office is closed on public holidays.'), (3, 'Invoices are emailed on the first day of each month.'), (4, 'Forgot your login? Use the password recovery link to sign in again.')), q AS (SELECT embed.main.embed_query('how do I reset my password') AS v) SELECT d.id, d.body, ROUND(embed.main.similarity(q.v, embed.main.embed_passage(d.body)), 3) AS score
FROM docs AS d
CROSS JOIN q
ORDER BY score DESC, d.id
LIMIT 2;
Result
id body score
1 Reset your password from the account settings page. 0.831
4 Forgot your login? Use the password recovery link to sign in again. 0.773

Zero-shot classification: embed each support ticket and each candidate label, then pick the label with the highest similarity per ticket (bug report / billing problem / feature request).

WITH tickets(ticket) AS (VALUES ('The app crashes every time I open the settings screen.'), ('I was charged twice for my subscription this month.'), ('Could you add a dark mode option?')), labels(label) AS (VALUES ('bug report'), ('billing problem'), ('feature request')) SELECT t.ticket, arg_max(l.label, embed.main.similarity(embed.main.embed(t.ticket), embed.main.embed(l.label))) AS label
FROM tickets AS t
CROSS JOIN labels AS l
GROUP BY t.ticket
ORDER BY t.ticket;

Near-duplicate detection: embed every title once, self-join the vectors and keep pairs whose similarity exceeds 0.8 (the two paraphrase pairs; the unrelated title matches nothing).

WITH titles(id, title) AS (VALUES (1, 'How to reset a forgotten password'), (2, 'Steps for resetting your lost password'), (3, 'Quarterly revenue grew by twelve percent'), (4, 'Revenue increased 12% this quarter'), (5, 'Best hiking trails near Denver')), v AS (SELECT id, title, embed.main.embed(title) AS vec FROM titles) SELECT a.title AS title_a, b.title AS title_b, ROUND(embed.main.similarity(a.vec, b.vec), 3) AS score
FROM v AS a
JOIN v AS b ON a.id < b.id
WHERE embed.main.similarity(a.vec, b.vec) > 0.8
ORDER BY score DESC, a.id;
Views
supported_models 2 examples2 cols

Discovery table of every (model, dim) the embed worker supports.

Columns
model VARCHAR
Model name to pass to embed(text, model) or embedding_dim(model).
dim INTEGER
Embedding dimension (FLOAT[] length) the model produces.
Examples (2)

List the supported embedding models and their dimensions.

SELECT model, dim FROM embed.main.supported_models ORDER BY model;

Dimension of the default model.

SELECT dim
FROM embed.main.supported_models
WHERE model = 'BAAI/bge-small-en-v1.5';
Link
Scalar functions
embed (text VARCHAR, model VARCHAR) +1 overload 4 examples

Embed text into a fixed-length FLOAT[] vector using the default model (BAAI/bge-small-en-v1.5, 384-dim). NULL/empty -> NULL.

Arguments
text VARCHAR
Text column to embed
model VARCHAR
Model name; see supported_models()
Overloads
embed(text VARCHAR) β†’ FLOAT[]embed(text VARCHAR, model VARCHAR) β†’ FLOAT[]
ReturnsFLOAT[]
Examples (4)

Embed a string into a 384-dim `FLOAT[]` with the default model.

SELECT len(embed.main.embed('hello world')) AS dim;

Embed text with an explicitly chosen model (768-dim `bge-base`).

SELECT len(embed.main.embed('hello world', 'BAAI/bge-base-en-v1.5')) AS dim;

Zero-shot classification: embed each support ticket and each candidate label, then pick the label with the highest similarity per ticket (bug report / billing problem / feature request).

WITH tickets(ticket) AS (VALUES ('The app crashes every time I open the settings screen.'), ('I was charged twice for my subscription this month.'), ('Could you add a dark mode option?')), labels(label) AS (VALUES ('bug report'), ('billing problem'), ('feature request')) SELECT t.ticket, arg_max(l.label, embed.main.similarity(embed.main.embed(t.ticket), embed.main.embed(l.label))) AS label
FROM tickets AS t
CROSS JOIN labels AS l
GROUP BY t.ticket
ORDER BY t.ticket;
1 more example
SELECT embed.main.embedding_dim('') AS dim;
Link
embed_passage (text VARCHAR, model VARCHAR) +1 overload 3 examples

Embed a document/passage with the default model. For bge retrieval models passages get NO instruction prefix (queries do); this mirrors that. NULL/empty -> NULL.

Arguments
text VARCHAR
Passage/document text to embed
model VARCHAR
Model name; see supported_models()
Overloads
embed_passage(text VARCHAR) β†’ FLOAT[]embed_passage(text VARCHAR, model VARCHAR) β†’ FLOAT[]
ReturnsFLOAT[]
Examples (3)

Embed a corpus passage with the default model and no query prefix.

SELECT len(embed.main.embed_passage('Reset your password from the account settings page.')) AS dim;

Embed a corpus passage with the same explicitly chosen model as the query.

SELECT len(embed.main.embed_passage('Reset your password in account settings.', 'BAAI/bge-base-en-v1.5')) AS dim;

Semantic search: embed the question once with embed_query, embed each corpus passage with embed_passage, rank by similarity and keep the top 2 (both password-help passages).

WITH docs(id, body) AS (VALUES (1, 'Reset your password from the account settings page.'), (2, 'Our office is closed on public holidays.'), (3, 'Invoices are emailed on the first day of each month.'), (4, 'Forgot your login? Use the password recovery link to sign in again.')), q AS (SELECT embed.main.embed_query('how do I reset my password') AS v) SELECT d.id, d.body, ROUND(embed.main.similarity(q.v, embed.main.embed_passage(d.body)), 3) AS score
FROM docs AS d
CROSS JOIN q
ORDER BY score DESC, d.id
LIMIT 2;
Result
id body score
1 Reset your password from the account settings page. 0.831
4 Forgot your login? Use the password recovery link to sign in again. 0.773
Link
embed_query (text VARCHAR, model VARCHAR) +1 overload 3 examples

Embed a search query with the default model, applying the model's recommended query instruction prefix (for bge: 'Represent this sentence for searching relevant passages: '). NULL/empty -> NULL.

Arguments
text VARCHAR
Search query to embed
model VARCHAR
Model name; see supported_models()
Overloads
embed_query(text VARCHAR) β†’ FLOAT[]embed_query(text VARCHAR, model VARCHAR) β†’ FLOAT[]
ReturnsFLOAT[]
Examples (3)

Embed a search query with the query-side instruction prefix.

SELECT len(embed.main.embed_query('how do I reset my password')) AS dim;

Embed a search query with an explicitly chosen model (768-dim `bge-base`).

SELECT len(embed.main.embed_query('how do I reset my password', 'BAAI/bge-base-en-v1.5')) AS dim;

Semantic search: embed the question once with embed_query, embed each corpus passage with embed_passage, rank by similarity and keep the top 2 (both password-help passages).

WITH docs(id, body) AS (VALUES (1, 'Reset your password from the account settings page.'), (2, 'Our office is closed on public holidays.'), (3, 'Invoices are emailed on the first day of each month.'), (4, 'Forgot your login? Use the password recovery link to sign in again.')), q AS (SELECT embed.main.embed_query('how do I reset my password') AS v) SELECT d.id, d.body, ROUND(embed.main.similarity(q.v, embed.main.embed_passage(d.body)), 3) AS score
FROM docs AS d
CROSS JOIN q
ORDER BY score DESC, d.id
LIMIT 2;
Result
id body score
1 Reset your password from the account settings page. 0.831
4 Forgot your login? Use the password recovery link to sign in again. 0.773
Link
embedding_dim (model VARCHAR) 1 example

Output dimension (vector length) for a model name; '' = default model

Arguments
model VARCHAR
Model name; '' or NULL = default model
ReturnsINTEGER
Example

Look up a model's output dimension without loading the model.

SELECT embed.main.embedding_dim('BAAI/bge-base-en-v1.5') AS dim;
Link
similarity (a FLOAT[], b FLOAT[]) 4 examples

Cosine similarity of two FLOAT[] vectors, in [-1, 1] (pure arithmetic, no model). NULL/empty/length-mismatch -> NULL.

Arguments
a FLOAT[]
First embedding vector to compare
b FLOAT[]
Second embedding vector, compared against the first
ReturnsDOUBLE
Examples (4)

Score how similar two embeddings are (rounded for stable output).

SELECT ROUND(embed.main.similarity(embed.main.embed('dog'), embed.main.embed('puppy')), 3) AS related;

Confirm a related pair ranks above an unrelated pair.

SELECT embed.main.similarity(embed.main.embed('dog'), embed.main.embed('puppy')) > embed.main.similarity(embed.main.embed('dog'), embed.main.embed('airplane')) AS related_wins;

Semantic search: embed the question once with embed_query, embed each corpus passage with embed_passage, rank by similarity and keep the top 2 (both password-help passages).

WITH docs(id, body) AS (VALUES (1, 'Reset your password from the account settings page.'), (2, 'Our office is closed on public holidays.'), (3, 'Invoices are emailed on the first day of each month.'), (4, 'Forgot your login? Use the password recovery link to sign in again.')), q AS (SELECT embed.main.embed_query('how do I reset my password') AS v) SELECT d.id, d.body, ROUND(embed.main.similarity(q.v, embed.main.embed_passage(d.body)), 3) AS score
FROM docs AS d
CROSS JOIN q
ORDER BY score DESC, d.id
LIMIT 2;
Result
id body score
1 Reset your password from the account settings page. 0.831
4 Forgot your login? Use the password recovery link to sign in again. 0.773
1 more example

Near-duplicate detection: embed every title once, self-join the vectors and keep pairs whose similarity exceeds 0.8 (the two paraphrase pairs; the unrelated title matches nothing).

WITH titles(id, title) AS (VALUES (1, 'How to reset a forgotten password'), (2, 'Steps for resetting your lost password'), (3, 'Quarterly revenue grew by twelve percent'), (4, 'Revenue increased 12% this quarter'), (5, 'Best hiking trails near Denver')), v AS (SELECT id, title, embed.main.embed(title) AS vec FROM titles) SELECT a.title AS title_a, b.title AS title_b, ROUND(embed.main.similarity(a.vec, b.vec), 3) AS score
FROM v AS a
JOIN v AS b ON a.id < b.id
WHERE embed.main.similarity(a.vec, b.vec) > 0.8
ORDER BY score DESC, a.id;
Link
Table functions
supported_models () 2 examples

Every (model, dim) the embed worker supports

No arguments
Returns columns
model VARCHAR
Model name to pass to embed(text, model) or embedding_dim(model).
dim INTEGER
Embedding dimension (FLOAT[] length) the model produces.
Examples (2)

List the supported embedding models and their dimensions.

SELECT model, dim FROM embed.main.supported_models() ORDER BY model;

Dimension of the default model.

SELECT dim
FROM embed.main.supported_models()
WHERE model = 'BAAI/bge-small-en-v1.5';
Link

Try these queries

Embed text into a FLOAT[] vector and check its length.

SELECT len(embed.main.embed('hello world')) AS dim

Uses embed

Rank a passage against a search query (asymmetric retrieval).

SELECT ROUND(embed.main.similarity(embed.main.embed_query('how do I reset my password'), embed.main.embed_passage('Reset your password in account settings.')), 3) AS score

Uses similarityembed_queryembed_passage

Look up the default model's vector dimension.

SELECT embed.main.embedding_dim('BAAI/bge-small-en-v1.5') AS dim

Uses embedding_dim

List the supported models and their dimensions.

SELECT model, dim FROM embed.main.supported_models() ORDER BY model

Uses supported_models

Embed a corpus passage with the default model and no query prefix.

SELECT len(embed.main.embed_passage('Reset your password from the account settings page.')) AS dim

Uses embed_passage

Embed a search query with the query-side instruction prefix.

SELECT len(embed.main.embed_query('how do I reset my password')) AS dim

Uses embed_query

13 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • The default model is BAAI/bge-small-en-v1.5. Does it produce 384-dimensional embedding vectors? Return a single boolean.
  • List the names of every embedding model this worker supports.
  • Is the word 'dog' more semantically similar to 'puppy' than to 'airplane'? Return a single boolean.
  • Does the model 'BAAI/bge-base-en-v1.5' produce 768-dimensional embedding vectors? Return a single boolean.

Embed 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.