Skip to main content

ImageEmbeddingModel

Trait ImageEmbeddingModel 

Source
pub trait ImageEmbeddingModel:
    Clone
    + WasmCompatSend
    + WasmCompatSync {
    const MAX_DOCUMENTS: usize;

    // Required methods
    fn ndims(&self) -> usize;
    fn embed_images(
        &self,
        images: impl IntoIterator<Item = Vec<u8>> + WasmCompatSend,
    ) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + WasmCompatSend;

    // Provided method
    fn embed_image<'a>(
        &'a self,
        bytes: &'a [u8],
    ) -> impl Future<Output = Result<Embedding, EmbeddingError>> + WasmCompatSend { ... }
}
Expand description

Trait for embedding models that can generate embeddings for images.

Required Associated Constants§

Source

const MAX_DOCUMENTS: usize

The maximum number of images the provider accepts in one request.

Required Methods§

Source

fn ndims(&self) -> usize

The number of dimensions in the embedding vector.

Source

fn embed_images( &self, images: impl IntoIterator<Item = Vec<u8>> + WasmCompatSend, ) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + WasmCompatSend

Embed a batch of images from their encoded file bytes.

Implementations must preserve input order in the returned embeddings. The returned Embedding::document should identify the input without retaining the raw image or a reversible encoding of it.

Provided Methods§

Source

fn embed_image<'a>( &'a self, bytes: &'a [u8], ) -> impl Future<Output = Result<Embedding, EmbeddingError>> + WasmCompatSend

Embed a single image from its encoded file bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§