Skip to main content

Module semantic

Module semantic 

Source
Expand description

Semantic (embedding) search over schema records.

Embeds path + description + type per record and the query with a local all-MiniLM-L6-v2 model (pipeline borrowed from ae), compresses to 64-d Matryoshka vectors, and ranks by cosine. Falls back to a deterministic hash embedder when the model can’t be fetched, so it always runs.

v0 embeds every record per invocation (fine at schema scale). A persistent embedding cache keyed by schema hash — like ae’s SQLite store — is the follow-up for very large / federated schemas; the embed and rank steps are kept separable here so that cache drops in cleanly.

Functions§

clear_cache
Delete all cached embedding vector files; returns how many were removed.
is_cached
Whether the schema’s real (ONNX) vectors are cached, so the default combine path can run without a foreground embed. Deliberately ignores hash-fallback vectors: a run re-selects the embedder and keys the cache on its kind, so treating a stale hash cache as “warm” while the run picks onnx would trigger exactly the surprise foreground embed this gate exists to avoid. Checked without loading a model.
search
Embed the query and each record, rank by cosine. Returns (score, record) pairs, best first — the caller formats them exactly like fuzzy hits, so --json / --ndjson work identically in both modes.
warm
Embed + cache every record’s vector without running a real query — pre-warms the cache so the first search is instant. Returns the record count.