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:
classmethod from_jsonl(path)[source]#

Load bounded UTF-8 JSON Lines records.

Each line must contain doc_id and text. Optional fields are source_uri, title, and anchor. The loader rejects duplicate IDs and oversized inputs instead of partially accepting ambiguous data.

Parameters:

path (str | PathLike[str])

Return type:

InMemoryBm25Retriever

get(doc_id)[source]#

Return a document by stable identifier for the MCP resource layer.

Parameters:

doc_id (str)

Return type:

RetrievedChunk | None

search(query, k=5)[source]#
Parameters:
Return type:

list[RetrievedChunk]