bm25
diapason.tools.storage.bm25
¶
BM25 memory backend — classic term-frequency retrieval.
BM25Memory
¶
Bases: MemoryBackend
In-memory BM25 (Okapi) retrieval backend.
Uses the rank_bm25 library to score documents against a query
using the classic BM25 probabilistic ranking function. All data
lives in memory — there is no persistence across restarts.
clear()
¶
Remove all stored documents — always via Rust backend.
count()
¶
Return the number of stored documents — always via Rust backend.
delete(doc_id)
¶
Delete a document by id — always via Rust backend.
retrieve(query, *, top_k=5, **kwargs)
¶
Search for query and return the top-k results — always via Rust backend.
store(content, *, source='', metadata=None)
¶
Persist content and return a unique document id.