Skip to main content

dirsql-plugin-embeddings

A first-party dirsql plugin for semantic search over files.

Installing the plugin loads the sqlite-vec extension (for vec_distance_cosine() and friends) and declares an embed() SQL scalar function that turns TEXT or BLOB values into embedding vectors:

uvx --with dirsql-plugin-embeddings dirsql "
  SELECT path
  FROM (SELECT path, embed(content ->> 'abstract') AS emb
        FROM './arxiv-firehose/data/**/metadata.json')
  WHERE emb IS NOT NULL
  ORDER BY vec_distance_cosine(emb, embed('local private models'))
  LIMIT 10"

WHERE emb IS NOT NULL is not optional bookkeeping: a file that is unreadable or not valid UTF-8 has NULL content, so its distance is NULL, and SQLite sorts NULLs first ascending — without the guard those files take the top slots.

For the common case — one glob, one question, top-k paths — the package is also its own command, generating and running exactly that SQL:

uvx dirsql-plugin-embeddings '**/*.md' "local private models" -k 10
  • Corpus glob: required first positional. The plugin never picks a default corpus; you always say which files are in scope. A bare glob is fine here — the command normalizes it to the ./-relative form the SQL layer requires (**/*.md → ./**/*.md).
  • Query text: second positional. Query text, model id, and glob are SQL-escaped into the generated query.
  • -k / --limit (both spellings, default 10): the number of results. It is exactly the SQL LIMIT of the generated query — no other cutoff exists.
  • --model <id>: templates the model id as embed()'s second argument in the generated SQL (see Model).

Results print one path<TAB>distance line per match, closest first.

Top-k is LIMIT k. sqlite-vec's MATCH ... AND k = N idiom belongs to its vec0 virtual table, which dirsql does not use. For plain expressions, sqlite-vec's own documented pattern is the one above: ORDER BY vec_distance_cosine(...) LIMIT k.

Zero cost when unused

embed() is inert until a query calls it: no worker process is spawned and no model is loaded for queries that never use it. On the first call, dirsql spawns the plugin's worker process (dirsql-plugin-embeddings worker), which serves every call of the invocation over stdin/stdout. A statement's values reach the worker in batches of up to 4096, each encoded in one model call. Only the values the query actually selects are embedded — the worker receives values, not paths, and never opens files itself.

Model

Embeddings come from model2vec (static embeddings — numpy + tokenizers, no torch), defaulting to minishlab/potion-retrieval-32M. The model downloads to the standard Hugging Face cache on the first ever run (on the order of a hundred megabytes — seconds to a few minutes depending on your connection), with progress on stderr when stderr is a TTY; every later run loads it from disk.

An optional second argument overrides the model per call — the id must be model2vec-loadable (sentence-transformers/torch models are out of scope):

SELECT embed('some text', 'minishlab/potion-base-8M')

The one-liner's --model flag templates the same second argument.

Vector cache

Computed vectors are cached at ~/.cache/dirsql/embeddings/ (or $XDG_CACHE_HOME/dirsql/embeddings/ when XDG_CACHE_HOME is set): one SQLite database per model identifier, each row keyed by the SHA-256 of the value bytes. Changing the value or the model recomputes; switching models never serves stale vectors. A batch is looked up in one query and its misses written in one transaction. There is no eviction: the directory is safe to wipe at any time; the only cost is re-embedding. The cache never lives inside a queried tree — the worker receives values, not paths, and writes nothing anywhere else.

Docs

Metadata

Release files for dirsql-plugin-embeddings 0.1.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dirsql-plugin-embeddings 0.1.21
File Size Uploaded Provenance
dirsql_plugin_embeddings-0.1.21.tar.gz 19.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dirsql-plugin-embeddings 0.1.21
File Interpreter ABI Platform
dirsql_plugin_embeddings-0.1.21-py3-none-any.whl Python 3 none any Details

Total release size: 35.2 kB

Release files / dirsql_plugin_embeddings-0.1.21.tar.gz

Download URL dirsql_plugin_embeddings-0.1.21.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2f60ebef8793888732ec4ef24804a67856c2370223c4871fa7e7672ce705a30d
BLAKE2b-256 checksum
How to use checksums
c81bc716e71cc122054ac9b3bbe7c73369e8f5fe54fdf07c315a764969f8f93e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / dirsql_plugin_embeddings-0.1.21-py3-none-any.whl

Download URL dirsql_plugin_embeddings-0.1.21-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b942254ee9bcbeacb8e8f783e1a1341f7365f04b019ece6cf73b519a0600d2c
BLAKE2b-256 checksum
How to use checksums
337d4e80c0a0b869a778617e0b5a83e9df4e75e2bfb3aca64170f58811d06050
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Security for dirsql-plugin-embeddings 0.1.21

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dirsql_plugin_embeddings-0.1.21.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page