Embed multiple text values efficiently with automatic batching and retry logic.
embed_many
is the primary embedding function for processing multiple text values efficiently. It provides automatic batching respecting the provider’s max_batch_size
limit, retry logic with exponential back-off, and unified return objects.
Name | Type | Required | Description |
---|---|---|---|
model | EmbeddingModel | ✓ | Provider instance created via e.g. openai.embedding() |
values | List[str] | ✓ | List of texts to embed |
max_retries | int | 3 | Maximum number of retry attempts |
**kwargs | provider-specific | – | Forwarded verbatim to the underlying SDK |
EmbedManyResult
exposes:
embeddings
: List of embedding vectors (list of lists of floats)values
: The original input textsusage
: Token usage statistics (if available)provider_metadata
: Provider-specific metadataEmbeddingModel
ABC to bring your own model:
embed_many
automatically batches requests based on the provider’s max_batch_size
cosine_similarity(vec_a, vec_b)
for quick similarity checks between embeddings.