Skip to main content

Module embeddings

Module embeddings 

Source
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§

EmbedError
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.
EmbeddingResponse
Response from an embedding request containing the embeddings and token usage.
EmbeddingsBuilder
Builder for creating embeddings from one or more documents of type T. Note: T can be any type that implements the Embed trait.
TextEmbedder
Accumulates string values that need to be embedded. Used by the Embed trait.
ToolSchema
Embeddable document that is used as an intermediate representation of a tool when RAGging tools.

Enums§

EmbeddingError
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.
EmbeddingModel
Trait for embedding models that can generate embeddings for documents.
ImageEmbeddingModel
Trait for embedding models that can generate embeddings for images.

Functions§

to_texts
Utility function that returns a vector of strings that need to be embedded for a given object that implements the Embed trait.