Skip to main content

EmbeddingModel

Trait EmbeddingModel 

Source
pub trait EmbeddingModel: Send + Sync {
    // Required methods
    fn embed<'life0, 'life1, 'async_trait>(
        &'life0 self,
        text: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<f32>>> + 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 = Layer3Result<Vec<Vec<f32>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn dimension(&self) -> usize;
    fn model_name(&self) -> &str;
}
Expand description

Embedding 模型 trait

Required Methods§

Source

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

生成文本嵌入向量

Source

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

批量生成嵌入向量

Source

fn dimension(&self) -> usize

获取向量维度

Source

fn model_name(&self) -> &str

模型名称

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§