Skip to main content

LocalEmbedder

Struct LocalEmbedder 

Source
pub struct LocalEmbedder { /* private fields */ }
Expand description

On-device embeddings from a LocalModel, for knowledge search with no network. Mean-pooled, L2-normalized vectors (the mean of the token rows); batches of at most 32 texts run off the async runtime.

Implementations§

Source§

impl LocalEmbedder

Source

pub fn new(model: Arc<dyn LocalModel>) -> Result<Self, LocalError>

Wraps a model that can embed. Input: the model. Output: the embedder, or Unsupported("embeddings") when its embedding size is 0.

Trait Implementations§

Source§

impl Debug for LocalEmbedder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Embedder for LocalEmbedder

Source§

fn dims(&self) -> usize

Source§

fn embed<'life0, 'life1, 'async_trait>( &'life0 self, texts: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Auto Trait Implementations§

§

impl !RefUnwindSafe for LocalEmbedder

§

impl !UnwindSafe for LocalEmbedder

§

impl Forget for LocalEmbedder

§

impl Freeze for LocalEmbedder
where *const ArcInner<dyn LocalModel> is !null: Freeze, PhantomData<ArcInner<dyn LocalModel>>: Freeze,

§

impl Move for LocalEmbedder

§

impl Send for LocalEmbedder
where Arc<dyn LocalModel>: Send,

§

impl Sync for LocalEmbedder
where Arc<dyn LocalModel>: Sync,

§

impl Unpin for LocalEmbedder
where Arc<dyn LocalModel>: Unpin,

§

impl UnsafeUnpin for LocalEmbedder
where *const ArcInner<dyn LocalModel> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn LocalModel>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.