Skip to main content

Module embed

Module embed 

Source
Expand description

Embeddings: embed for one value, embed_many for several (split into provider calls by the model’s limits) and cosine_similarity.

Design: docs/01-architecture/11-other-modalities.md §1.

Lifecycle behavior is derived from the Vercel AI SDK (Apache-2.0, Copyright 2023 Vercel, Inc.), translated to Rust and modified; see NOTICE.

Structs§

Embed
Builder returned by embed; .await runs the call.
EmbedCallEndEvent
Event after all chunks and retries of an embedding operation succeed.
EmbedCallStartEvent
Event before any provider attempt of an embedding operation.
EmbedMany
Builder returned by embed_many; .await runs the calls.
EmbedManyResult
Result of embed_many.
EmbedResult
Result of embed.
EmbeddingUsage
Token usage of embedding calls; None when the provider reported none.

Enums§

EmbeddingInput
Input shape of an embedding operation.
EmbeddingOutput
Output shape of an embedding operation.
EmbeddingResponse
Response metadata shape of an embedding operation.

Functions§

cosine_similarity
Cosine similarity of two vectors; 0.0 when either has zero length.
embed
Embeds one value.
embed_many
Embeds several values, splitting them into provider calls by the model’s limits and running the calls concurrently when the model allows it.

Type Aliases§

Embedding
An embedding vector.