CorpusIndexRetriever#

class scikitplot.mcp.CorpusIndexRetriever(embedder, index, *, match_mode='hybrid', strict=False)[source]#

Text-level retriever over a corpus RetrievalIndex: hybrid by default.

Parameters:
embedderEmbedder or None

Embeds the query for the dense leg — the same model that embedded the corpus. None only with match_mode='keyword'.

indexRetrievalIndex

A built corpus index. Its own configuration (fusion constant, weights, backend) is kept; only match_mode and top_k are set per query.

match_mode{‘hybrid’, ‘keyword’, ‘semantic’}, optional

Which evidence paths the corpus runs. Default 'hybrid': BM25 and dense, fused by rank inside the corpus.

strictbool, optional

Re-raise failures instead of reporting them as a failed leg.

Raises:
ValueError

If match_mode is not one of the offered modes, or no embedder is given for a mode that needs one.

Parameters:

Notes

User. Dense search blurs identifiers and error strings; keyword search misses paraphrase. Hybrid runs both and fuses them by rank, which is why a query such as roc_auc_score and one such as “area under the ROC curve” both find the right page.

Developer. The server’s Corpus+Annoy backend built an index that already holds a BM25 leg (RetrievalIndex.build always constructs it) and then used only the vector seam, so the MCP surface could never serve hybrid retrieval although every piece existed (finding CX-04). Fusion is not re-implemented here: corpus owns retrieval semantics, and its per-leg account is carried into RetrievalOutcome, so a hybrid query whose dense leg could not run is reported degraded rather than passed off as a complete result.

property match_mode: str#

The evidence paths every query runs.

Type:

str

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

Search the corpus index and map its hits and legs for MCP.

Parameters:
Return type:

list[RetrievedChunk]