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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dirsql_plugin_embeddings-0.1.16.tar.gz.
File metadata
- Download URL: dirsql_plugin_embeddings-0.1.16.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3ded623981b89b0df56ced8a3a3d50925a67ea84de8f66688fb30b28850592b
|
|
| MD5 |
fa5ec6b3eaded77074e16cf258b77d7d
|
|
| BLAKE2b-256 |
e344d294daa4c7cc6d5655afcc07c9eda5e54b2beb82be6c781da409f385cc47
|
Provenance
The following attestation bundles were made for dirsql_plugin_embeddings-0.1.16.tar.gz:
Publisher:
release.yml on thekevinscott/dirsql
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirsql_plugin_embeddings-0.1.16.tar.gz -
Subject digest:
f3ded623981b89b0df56ced8a3a3d50925a67ea84de8f66688fb30b28850592b - Sigstore transparency entry: 2439283826
- Sigstore integration time:
-
Permalink:
thekevinscott/dirsql@f462b0de08c2cec9ec729ade87991f3306481a9d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/thekevinscott
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f462b0de08c2cec9ec729ade87991f3306481a9d -
Trigger Event:
push
-
Statement type:
File details
Details for the file dirsql_plugin_embeddings-0.1.16-py3-none-any.whl.
File metadata
- Download URL: dirsql_plugin_embeddings-0.1.16-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e26a4497c15acfd1e98a27d030560316c9908f2805601ed428a55f044aa2b8fd
|
|
| MD5 |
908cbecab7fc2888addd0f87f15af5b2
|
|
| BLAKE2b-256 |
821e65ebae9f86071d0c76f3eac29119f44b1fa18954c0147fe4c3db4655eba8
|
Provenance
The following attestation bundles were made for dirsql_plugin_embeddings-0.1.16-py3-none-any.whl:
Publisher:
release.yml on thekevinscott/dirsql
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirsql_plugin_embeddings-0.1.16-py3-none-any.whl -
Subject digest:
e26a4497c15acfd1e98a27d030560316c9908f2805601ed428a55f044aa2b8fd - Sigstore transparency entry: 2439283855
- Sigstore integration time:
-
Permalink:
thekevinscott/dirsql@f462b0de08c2cec9ec729ade87991f3306481a9d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/thekevinscott
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f462b0de08c2cec9ec729ade87991f3306481a9d -
Trigger Event:
push
-
Statement type: