pub struct DimReductionEmbeddingModel<M>where
M: EmbeddingModel,{ /* private fields */ }Expand description
降维 Embedding 模型适配器
包装一个内部 EmbeddingModel,通过截断或平均池化将输出向量降维到指定维度。 适用于需要将高维向量适配到低维索引的场景。
Implementations§
Source§impl<M> DimReductionEmbeddingModel<M>where
M: EmbeddingModel,
impl<M> DimReductionEmbeddingModel<M>where
M: EmbeddingModel,
Sourcepub fn new(
inner: M,
target_dimension: usize,
strategy: DimReductionStrategy,
) -> Self
pub fn new( inner: M, target_dimension: usize, strategy: DimReductionStrategy, ) -> Self
创建降维适配器
Sourcepub fn target_dimension(&self) -> usize
pub fn target_dimension(&self) -> usize
获取目标维度
Sourcepub fn strategy(&self) -> DimReductionStrategy
pub fn strategy(&self) -> DimReductionStrategy
获取降维策略
Trait Implementations§
Source§impl<M> EmbeddingModel for DimReductionEmbeddingModel<M>where
M: EmbeddingModel,
impl<M> EmbeddingModel for DimReductionEmbeddingModel<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 DimReductionEmbeddingModel<M>where
M: Freeze,
impl<M> RefUnwindSafe for DimReductionEmbeddingModel<M>where
M: RefUnwindSafe,
impl<M> Send for DimReductionEmbeddingModel<M>
impl<M> Sync for DimReductionEmbeddingModel<M>
impl<M> Unpin for DimReductionEmbeddingModel<M>where
M: Unpin,
impl<M> UnsafeUnpin for DimReductionEmbeddingModel<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for DimReductionEmbeddingModel<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