Skip to main content

Module vector_search

Module vector_search 

Source
Expand description

In-memory vector search plugin.

Stores embeddings (Vec) per (entity, row_id) and exposes nearest-neighbour search via cosine similarity. The plugin itself does not compute embeddings — callers pass pre-computed vectors via index() (typically from an OpenAI/Anthropic/local embedding model). For production scale move to a dedicated vector store (pgvector, Qdrant, Turso libsql vector); this is the “good enough for thousands of rows” implementation.

Why not store vectors directly in SQLite? SQLite has no first-class vector support and naive blob storage means re-decoding every row per query. An in-memory index is far faster for small/medium datasets and survives via a snapshot-on-write to a JSON file (see persist_path).

Search complexity is O(n * d) per query. With 10k rows and 1024-dim vectors that’s ~10M float ops per query — well under 10ms on commodity hardware.

Structs§

VectorHit
VectorSearchPlugin