Skip to main content

EmbeddingModel

Trait EmbeddingModel 

Source
pub trait EmbeddingModel:
    Send
    + Sync
    + Debug {
    // Required methods
    fn embed<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        input: &'life1 [&'life2 str],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn model_info(&self) -> &EmbedModelInfo;
    fn max_batch_size(&self) -> usize;
    fn dimensions(&self) -> usize;

    // Provided method
    fn embed_single<'life0, 'life1, 'async_trait>(
        &'life0 self,
        text: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, EmbedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

统一的文本向量嵌入接口

Required Methods§

Source

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

核心嵌入方法。对一批文本生成向量。

Source

fn model_info(&self) -> &EmbedModelInfo

模型信息

Source

fn max_batch_size(&self) -> usize

最大批次大小

Source

fn dimensions(&self) -> usize

向量维度

Provided Methods§

Source

fn embed_single<'life0, 'life1, 'async_trait>( &'life0 self, text: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

便捷方法:对单个文本生成向量

Implementors§