pub trait SparseEmbeddingModel: ModelInfo {
// Required methods
fn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<SparseEmbedResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn vocab_size(&self) -> u32;
// Provided method
fn warmup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}Expand description
A model that produces learned-sparse term-weight vectors from text.
Use cases include SPLADE-style retrieval and the BGE-M3 sparse head for
hybrid dense + sparse search. One SparseVector is returned per input
text. For scoring two sparse vectors, see
sparse_dot.
Required Methods§
Sourcefn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<SparseEmbedResult>> + 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,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<SparseEmbedResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Embed a batch of text strings into learned-sparse vectors.
Returns one SparseVector per input, in input order.
§Errors
Returns an error if tokenization fails, the model session errors, or the upstream API rejects the request.
Sourcefn vocab_size(&self) -> u32
fn vocab_size(&self) -> u32
The size of the term space the produced term_ids index into.
For SPLADE this is the model’s full vocabulary (term expansion); for the BGE-M3 lexical head it is the tokenizer vocabulary the input tokens map to.
Provided Methods§
Sourcefn warmup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn warmup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Optional warmup hook (e.g. load weights into memory on first access). The default is a no-op.
§Errors
Returns an error if the underlying model fails to initialize.