Expand description
Provider-agnostic embedding abstractions.
Embeddings are numerical representations of text or other inputs. Rig uses
EmbeddingModel to generate vectors, Embed to select which text from a
Rust value should be embedded, and EmbeddingsBuilder to batch embedding
requests for vector stores or retrieval workflows.
Modules§
- builder
- The module defines the EmbeddingsBuilder struct which accumulates objects to be embedded and batch generates the embeddings for each object when built. Only types that implement the Embed trait can be added to the EmbeddingsBuilder.
- distance
- Distance and similarity helpers for embedding vectors.
- embed
- The module defines the Embed trait, which must be implemented for types that can be embedded by the crate::embeddings::EmbeddingsBuilder.
- embedding
- The module defines the EmbeddingModel trait, which represents an embedding model that can generate embeddings for documents.
- tool
- The module defines the ToolSchema struct, which is used to embed an object that implements crate::tool::PortableToolEmbedding
Structs§
- Embed
Error - Error type used for when the Embed::embed method of the Embed trait fails. Used by default implementations of Embed for common types.
- Embedding
- Struct that holds a single document and its embedding.
- Embedding
Response - Response from an embedding request containing the embeddings and token usage.
- Embeddings
Builder - Builder for creating embeddings from one or more documents of type
T. Note:Tcan be any type that implements the Embed trait. - Text
Embedder - Accumulates string values that need to be embedded. Used by the Embed trait.
- Tool
Schema - Embeddable document that is used as an intermediate representation of a tool when RAGging tools.
Enums§
- Embedding
Error - Errors returned by embedding models.
Traits§
- Embed
- Derive this trait for objects that need to be converted to vector embeddings. The Embed::embed method accumulates string values that need to be embedded by adding them to the TextEmbedder. If an error occurs, the method should return EmbedError.
- Embedding
Model - Trait for embedding models that can generate embeddings for documents.
- Image
Embedding Model - Trait for embedding models that can generate embeddings for images.