pub trait EmbedderCacheExt: Embedder {
// Provided method
fn cached(self, cache_size: NonZeroUsize) -> CachedEmbeddingModel<Self>
where Self: Sized { ... }
}
Expand description
An extension trait for Embedder
that allows for caching embeddings.
Provided Methods§
Sourcefn cached(self, cache_size: NonZeroUsize) -> CachedEmbeddingModel<Self>where
Self: Sized,
fn cached(self, cache_size: NonZeroUsize) -> CachedEmbeddingModel<Self>where
Self: Sized,
Wrap the embedder with a cache for previously computed embeddings.
§Example
let bert = Bert::builder()
.build()
.await.unwrap()
// You can call the `.cached` method on any embedder to cache the results of the embedding in a LRU cache with the given capacity.
.cached(NonZeroUsize::new(1000).unwrap());
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.