embed
Embedding client wrapper: doc/query prompts + Matryoshka truncation.
Embedder
Doc/query prompt formatting + truncation over an OpenAI-style embeddings client.
embed_document(title, text)
Embed for storage, with DOC_PROMPT.
The doc and query prompts are asymmetric on purpose (see the module docstring): indexing and searching with the same prompt is the common embedding-search mistake this wrapper exists to prevent.
embed_query(text)
Embed a search query, with QUERY_PROMPT -- see embed_document.
truncate_normalize(vec, dims=None)
Slice a Matryoshka embedding to dims and renormalise to unit length.
Applied before every store or comparison: a raw vector's later dims carry finer distinctions a shorter, EMBED_DIMS-sized index deliberately drops, and slicing without renormalising would leave stored vectors at the wrong scale for cosine similarity. A model returning fewer dims than configured raises rather than silently zero-padding, which would fabricate signal.