agrag.embedding.fastembed_dense.FastEmbedEmbedder
FastEmbedEmbedder(*, settings:EmbeddingSettings | None = None, cache:EmbeddingCache | None = None, model:object | None = None, tracer:Tracer | None = None) -> None
Bases: Embedder
A dense embedder built on FastEmbed, which runs ONNX models on the CPU.
The model loads lazily on the first embed or dimensions call, so
constructing the embedder does not download weights. Each blocking call
into FastEmbed runs in a worker thread, which keeps the event loop free
for other work while a large batch encodes.
Functions:
- dimensions – Return the dimension the loaded model produces.
- embed – Embed a batch of texts, using the cache where possible.
- embed_one – Embed a single text.
Attributes:
- distance (
Distance) – Return the distance metric for vector indexes created for this embedder. - model (
str) – The configured model name.
Parameters:
- settings (
EmbeddingSettings | None) – Embedder configuration. Defaults toEmbeddingSettings(). FastEmbed ignoresdevice. - cache (
EmbeddingCache | None) – An optional content-addressed cache. Defaults to a no-op cache. - model (
object | None) – A pre-built FastEmbedTextEmbedding, for tests. When set,embedcalls this object instead of building one. - tracer (
Tracer | None) – Opens every span this embedder's methods produce.
dimensions
dimensions() -> int
Return the dimension the loaded model produces.
Calling this loads the model the first time, through the same locked
worker-thread path embed uses, so it is safe to call concurrently
with embed.
Returns:
int– The dimension of the vectors the loaded model produces.
distance
distance: Distance
Return the distance metric for vector indexes created for this embedder.
Defaults to cosine, which matches normalized sentence-transformer models. Concrete embedders can override when their vectors use a different metric.
embed
embed(texts:Sequence[str]) -> list[list[float]]
Embed a batch of texts, using the cache where possible.
Parameters:
- texts (
Sequence[str]) – The texts to embed, in order.
Returns:
list[list[float]]– One vector per input text, in the same order.
embed_one
embed_one(text:str) -> list[float]
Embed a single text.
Parameters:
- text (
str) – The text to embed.
Returns:
list[float]– The text's embedding vector.
model
model: str
The configured model name.
Returns:
str– The model name from the embedder settings.