agrag.embedding.fastembed_bm25.FastEmbedBM25Embedder
FastEmbedBM25Embedder(*, model:str | None = None, tracer:Tracer | None = None) -> None
Bases: SparseEmbedder
A sparse BM25 embedder built on FastEmbed.
The model loads lazily on first embed, so constructing the embedder
does not download weights. Each blocking call into FastEmbed runs in a
worker thread, keeping the event loop free.
Functions:
- embed – Embed a batch of documents into BM25 sparse vectors.
- query_embed – Embed a batch of search queries into BM25 sparse vectors.
Attributes:
- model (
str) – The configured model name, or the FastEmbed default when unset.
Parameters:
- model (
str | None) – The FastEmbed BM25 model name. Defaults to FastEmbed's built-in BM25 model. - tracer (
Tracer | None) – Opens every span this embedder's methods produce.
embed
embed(texts:Sequence[str]) -> list[SparseVector]
Embed a batch of documents into BM25 sparse vectors.
Applies FastEmbed's document-side term-frequency and length
normalization weighting. Use query_embed for search queries.
Parameters:
- texts (
Sequence[str]) – The document texts to embed, in order.
Returns:
list[SparseVector]– One sparse vector per input text, in the same order.
model
model: str
The configured model name, or the FastEmbed default when unset.
query_embed
query_embed(texts:Sequence[str]) -> list[SparseVector]
Embed a batch of search queries into BM25 sparse vectors.
Uses FastEmbed's query_embed, which assigns each unique query
term a uniform weight of 1.0 rather than the document-side
term-frequency and length-normalization weighting that embed
applies. IDF weighting is applied separately by the sparse index via
Modifier.IDF at query time.
Parameters:
- texts (
Sequence[str]) – The query texts to embed, in order.
Returns:
list[SparseVector]– One sparse vector per input text, in the same order.