symfonic.memory.backends.in_memory_vector¶
in_memory_vector ¶
In-memory VectorBackend and the brute-force similarity it searches with.
Split out of :mod:symfonic.memory.backends.in_memory (378 lines against the
300-line budget). That module implemented two unrelated protocols in one file:
GraphBackend, which stores nodes and edges, and VectorBackend, which
stores embeddings. Only the vector half ever used _cosine_similarity, so
the two leave with nothing shared between them.
in_memory re-exports both names, so existing imports are unchanged.
InMemoryVectorBackend ¶
In-memory implementation of the VectorBackend protocol.
Stores embeddings in a list and uses brute-force cosine similarity for search. Suitable for testing only.
Source code in src/symfonic/memory/backends/in_memory_vector.py
add
async
¶
add(scope: TenantScope, ids: list[str], embeddings: list[list[float]], metadatas: list[dict[str, Any]], documents: list[str]) -> None
Add vectors with metadata to the store.
v8.0: stamps the materialised scope_path into the metadata bag so
the prefix-isolation filter (§5.d) can run on every search.
Source code in src/symfonic/memory/backends/in_memory_vector.py
count
async
¶
delete
async
¶
Delete vectors by their IDs.
Source code in src/symfonic/memory/backends/in_memory_vector.py
search
async
¶
Brute-force cosine similarity search.
v8.0: ALWAYS-ON prefix-isolation (§5.d) — only entries whose stored
scope_path is a prefix of the query path are scored. Dual-reads
pre-v8.0 metadata (no scope_path) as a 1-level root path.