faiss_backend
diapason.tools.storage.faiss_backend
¶
FAISS dense retrieval memory backend.
Uses cosine similarity via inner-product search on L2-normalised
vectors. Requires faiss-cpu (or faiss-gpu) and numpy.
FAISSMemory
¶
Bases: MemoryBackend
Dense retrieval backend powered by FAISS.
Stores document embeddings in a faiss.IndexFlatIP index
(inner-product, which equals cosine similarity when vectors
are L2-normalised before insertion/search).
clear()
¶
Reset the index and all internal storage.
delete(doc_id)
¶
Soft-delete doc_id. Return True if it existed.
retrieve(query, *, top_k=5, **kwargs)
¶
Embed query and return the top-k most similar docs.
store(content, *, source='', metadata=None)
¶
Embed and store content, returning a unique doc id.