API documentation for embeddings module.
Classes
AlloyDBEmbedding
AlloyDBEmbedding(engine: AlloyDBEngine, model_id: str, embed_batch_size: int = 10, num_workers: Optional[int] = 4, *, model_name: str = 'unknown', callback_manager: llama_index.core.callbacks.base.CallbackManager = <factory>, embeddings_cache: typing.Optional[typing.Any] = None, rate_limiter: typing.Optional[typing.Any] = None)Embedding model that generates embeddings inside AlloyDB.
Texts are embedded with the AlloyDB AI embedding(model_id, content)
function, so model_id must be a model registered with model endpoint
management, for example text-embedding-005. Each batch of
embed_batch_size texts is one SQL statement, and embedding() runs
once per row, so a larger batch saves round trips but not model calls.
An empty string raises ValueError. The batch methods check their whole
input, because LlamaIndex passes the hooks one batch at a time, so a hook
could not name the text's position.
The async batch methods embed num_workers batches at a time, each on its
own pool connection. DEFAULT_NUM_WORKERS (4) fits the engine's default
pool. More workers than the pool allows, or None, 0 or 1 (no limit in
llama-index-core), can fail with sqlalchemy.exc.TimeoutError. The sync
methods need an engine with a background event loop, such as one from
AlloyDBEngine.from_instance or AlloyDBEngine.afrom_instance.