pub struct NormalizedEmbeddingModel<M>where
M: EmbeddingModel,{ /* private fields */ }Expand description
归一化 Embedding 模型适配器
包装一个内部 EmbeddingModel,对输出向量进行 L2 归一化, 确保所有向量都是单位向量。适用于需要使用余弦相似度的场景。
Implementations§
Source§impl<M> NormalizedEmbeddingModel<M>where
M: EmbeddingModel,
impl<M> NormalizedEmbeddingModel<M>where
M: EmbeddingModel,
Trait Implementations§
Source§impl<M> EmbeddingModel for NormalizedEmbeddingModel<M>where
M: EmbeddingModel,
impl<M> EmbeddingModel for NormalizedEmbeddingModel<M>where
M: EmbeddingModel,
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, AiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, AiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn dimension(&self) -> usize
fn model_name(&self) -> &str
Auto Trait Implementations§
impl<M> Freeze for NormalizedEmbeddingModel<M>where
M: Freeze,
impl<M> RefUnwindSafe for NormalizedEmbeddingModel<M>where
M: RefUnwindSafe,
impl<M> Send for NormalizedEmbeddingModel<M>
impl<M> Sync for NormalizedEmbeddingModel<M>
impl<M> Unpin for NormalizedEmbeddingModel<M>where
M: Unpin,
impl<M> UnsafeUnpin for NormalizedEmbeddingModel<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for NormalizedEmbeddingModel<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more