InMemoryBm25Retriever#
- class scikitplot.mcp.InMemoryBm25Retriever(documents, *, k1=1.5, b=0.75, title_weight=2.0)[source]#
A compact BM25 implementation suitable for demos and small corpora.
The index is immutable after construction, making concurrent reads safe. Search complexity is linear in the number of documents; production-scale deployments should use FTS5, a dedicated search engine, or the hybrid corpus/Annoy adapters instead.
- Parameters:
documents (Iterable[DemoDocument])
k1 (float)
b (float)
title_weight (float)
- classmethod from_jsonl(path)[source]#
Load bounded UTF-8 JSON Lines records.
Each line must contain
doc_idandtext. Optional fields aresource_uri,title, andanchor. The loader rejects duplicate IDs and oversized inputs instead of partially accepting ambiguous data.- Parameters:
- Return type:
- get(doc_id)[source]#
Return a document by stable identifier for the MCP resource layer.
- Parameters:
doc_id (str)
- Return type:
RetrievedChunk | None