all2md.search.bm25

BM25 keyword search index backed by rank-bm25.

class all2md.search.bm25.KeywordIndexConfig

Bases: object

Configuration settings for BM25 indexing.

k1: float = 1.5
b: float = 0.75
__init__(k1: float = 1.5, b: float = 0.75) None
class all2md.search.bm25.BM25Index

Bases: BaseIndex

Keyword search implementation using BM25 scoring.

Initialise the BM25 index with optional configuration and tokenizer override.

backend_name = 'bm25'
__init__(*, config: KeywordIndexConfig | None = None, tokenizer: Callable[[str], Sequence[str]] | None = None, index_id: str | None = None, options_snapshot: Mapping[str, object] | None = None) None

Initialise the BM25 index with optional configuration and tokenizer override.

search(query: SearchQuery, *, top_k: int = 10) list[SearchResult]

Return the top top_k chunks ranked by BM25 score for query.

save(directory: Path) None

Persist BM25 corpus, chunks, and configuration to directory.

classmethod load(directory: Path) BM25Index

Restore a BM25 index that was previously saved to directory.