Bm25Retriever#

class scikitplot.mcp.Bm25Retriever(fts_search, doc_lookup, *, strict=False)[source]#

Lexical retriever (FTS/BM25) leg backed by a full-text search seam.

Parameters:
fts_searchcallable

(query, k) -> list[(doc_id, score)] — BM25-ranked hits. In production this wraps scikitplot.corpus.SQLiteStorage FTS5 (whose default rank is BM25).

doc_lookupcallable

doc_id -> mapping with at least text and source_uri.

Parameters:

Notes

BM25 complements dense retrieval on exact tokens — API symbols, flags, error messages — that embeddings often blur.

classmethod from_corpus_sqlite(storage_path, *, strict=False)[source]#

Build from a corpus SQLite/FTS5 store (import-guarded).

Wires scikitplot.corpus.SQLiteStorage.search_text: BM25-ranked retrieval over free text. Raises RuntimeError with an actionable message if corpus is absent.

Notes

Developer. This leg used to pass the query to StorageQuery.full_text, which reached FTS5 MATCH verbatim as an expression and required every word: roc_auc_score(), C++, random-state and any pasted error message were FTS5 syntax errors, and a plain question returned nothing, so hybrid search quietly ran on its dense leg alone (finding CX-01). search_text never reads the query as syntax, matches any word, and returns the BM25 score itself rather than 1 / rank.

Parameters:
Return type:

Bm25Retriever

search(query, k=5)[source]#

Run FTS5/BM25 and map hits to RetrievedChunk.

Parameters:
Return type:

list[RetrievedChunk]