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
- Query Farm hosting
- Available Β· $10/month organization minimum
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
| 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.
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;
INSTALL vgi FROM community;
LOAD vgi;
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'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'embed' AS embed (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-embed:0.6.0'
);
3. Run a query
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
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connectorβs deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
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;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'embed' AS embed
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
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
Query Farm operates Embed for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
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;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use embed as the catalog alias for the query below.
4. Run a query
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
Technical details
- Verified connector release
- v0.6.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
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'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'embed' AS embed (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-embed:0.6.0'
);
Overview
Local text embeddings (fastembed/ONNX) + cosine similarity for semantic search / RAG.

Turn text into vector embeddings directly in DuckDB SQL β generate fixed-length FLOAT[] embedding vectors and score them with cosine similarity for semantic search, retrieval-augmented generation (RAG), and nearest-neighbor ranking, all without leaving your query and without sending a single byte to an external API.
The embed extension brings sentence-transformer text embeddings to SQL for data engineers, RAG builders, and search teams who want vector search inside the database instead of a separate embedding service. Embeddings are computed entirely in-process and offline β there is no torch dependency, no GPU requirement, and no network call after the one-time model download β so the same query runs identically on a laptop, in CI, and in production.
Under the hood it is powered by fastembed from Qdrant (Apache-2.0), which runs quantized sentence-transformer models through ONNX Runtime (source). The configured default model is BAAI/bge-small-en-v1.5 (384-dimensional), downloaded on first use and cached locally. Set VGI_EMBED_DEFAULT_MODEL before startup to change it, or pass a model as the second argument to each embedding function. Use the same model for queries and documents. Vectors are returned over Apache Arrow as native DuckDB FLOAT[] lists, ready to index and rank with the DuckDB VSS extension.
How it works
There are two embedding modes. Symmetric embedding maps any text to a vector for text-to-text comparison (dedup, clustering, classification). Asymmetric retrieval follows the query/passage convention these models are trained on: a short search query and a longer document are embedded with slightly different instruction prefixes so they land in the same space, which improves recall over plain symmetric embedding. Ranking is then just cosine similarity between vectors -- pure arithmetic, no model load. Model discovery and dimension lookups let you size a vector column or VSS index ahead of time.
-- A sentence is more similar to itself than to an unrelated one
SELECT embed.similarity(embed.embed('cat'), embed.embed('kitten')) AS score;NULL or empty input text yields a NULL vector, and the model is loaded once and amortized across every row in a scan.
Catalog
Everything embed exposes once attached β read straight from the worker's
released build.
main 1 view Β· 6 functions
Local text embeddings (fastembed/ONNX) + cosine similarity for SQL
Schema 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;
| 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;
supported_models
Discovery table of every (model, dim) the embed worker supports.
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';
embed (text VARCHAR, model VARCHAR) +1 overload
Embed text into a fixed-length FLOAT[] vector using the default model (BAAI/bge-small-en-v1.5, 384-dim). NULL/empty -> NULL.
embed(text VARCHAR) β FLOAT[]embed(text VARCHAR, model VARCHAR) β FLOAT[]
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;
embed_passage (text VARCHAR, model VARCHAR) +1 overload
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.
embed_passage(text VARCHAR) β FLOAT[]embed_passage(text VARCHAR, model VARCHAR) β FLOAT[]
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;
| 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 |
embed_query (text VARCHAR, model VARCHAR) +1 overload
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.
embed_query(text VARCHAR) β FLOAT[]embed_query(text VARCHAR, model VARCHAR) β FLOAT[]
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;
| 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 |
embedding_dim (model VARCHAR)
Output dimension (vector length) for a model name; '' = default model
Look up a model's output dimension without loading the model.
SELECT embed.main.embedding_dim('BAAI/bge-base-en-v1.5') AS dim;
similarity (a FLOAT[], b FLOAT[])
Cosine similarity of two FLOAT[] vectors, in [-1, 1] (pure arithmetic, no model). NULL/empty/length-mismatch -> NULL.
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;
| 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;
supported_models ()
Every (model, dim) the embed worker supports
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';
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
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.
Related workers
Rerank
AI & language
Score and reorder retrieved passages against a query with local cross-encoder models, for sharper RAG results
LLM
AI & language
Call LLMs from SQL β Anthropic, OpenAI, OpenRouter or local Ollama β plus local embeddings
tiktoken
AI & language
Count, tokenize, truncate and chunk text using exact OpenAI BPE token counts