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 SQLLIMITof the generated query — no other cutoff exists.--model <id>: templates the model id asembed()'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'sMATCH ... AND k = Nidiom belongs to itsvec0virtual table, whichdirsqldoes 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. 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), keyed by
the SHA-256 of the value bytes plus the model identifier — changing either
recomputes; switching models never serves stale vectors. 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
- Search documents by meaning — the guide to both invocation styles.
[[dirsql.function]]— the core mechanismembed()is built on.
Metadata
Release files for dirsql-plugin-embeddings 0.1.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dirsql_plugin_embeddings-0.1.19.tar.gz | 15.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dirsql_plugin_embeddings-0.1.19-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.9 kB
Release files / dirsql_plugin_embeddings-0.1.19.tar.gz
| Download URL | dirsql_plugin_embeddings-0.1.19.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81a177689dcffca7f811d52c54aa4fd156bd7fdd41733bffebcd82a4cb498b3f
|
|
BLAKE2b-256 checksum How to use checksums |
9e39fed27589db9383d209b71d9d548e9434706195f88baa346ad5f052bc09d8
|
| 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 Sep 5, 2026.
Transparency logRelease files / dirsql_plugin_embeddings-0.1.19-py3-none-any.whl
| Download URL | dirsql_plugin_embeddings-0.1.19-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c2cfd995699a75344af476de141409564edc2a22d1bcda3d5ea1e808a07cdd8
|
|
BLAKE2b-256 checksum How to use checksums |
0ac2e1a1e3dc15ab8fc45571f610c9f075cc33e74333cfb84fdcea5c85f6ec2a
|
| 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 Sep 5, 2026.
Transparency logSecurity for dirsql-plugin-embeddings 0.1.19
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.
Attestation for dirsql_plugin_embeddings-0.1.19.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 Sep 5, 2026.
Transparency logA 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.