agrag.embedding.base.Embedder
Bases: ABC
A component that turns text into dense embedding vectors.
Functions:
- dimensions – Return the dimension of the vectors this embedder produces.
- embed – Embed a batch of texts.
- embed_one – Embed a single text.
Attributes:
- distance (
Distance) – Return the distance metric for vector indexes created for this embedder. - model (
str) –
dimensions
dimensions() -> int
Return the dimension of the vectors this embedder produces.
Async because a lazily-loaded embedder can need to load its model to
answer. That load must go through the same worker-thread and lock
path embed uses rather than blocking the event loop.
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.
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