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§
Sourcefn 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 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,
核心嵌入方法。对一批文本生成向量。
Sourcefn model_info(&self) -> &EmbedModelInfo
fn model_info(&self) -> &EmbedModelInfo
模型信息
Sourcefn max_batch_size(&self) -> usize
fn max_batch_size(&self) -> usize
最大批次大小
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
向量维度