Function get_embeddings_parallel

Source
pub fn get_embeddings_parallel(
    model: &MPNetModel,
    tokenizer: &Tokenizer,
    pooler: Option<&MPNetPooler>,
    sentences: &[&str],
    chunksize: usize,
) -> Result<Tensor>
Expand description

Computes embeddings for the given sentences in parallel chunks.

This function takes a model, a tokenizer, an optional pooler, a vector of sentences, and a chunk size, and computes embeddings for the sentences in parallel chunks.

§Arguments

  • model - A reference to an instance of MPNetModel.
  • tokenizer - A reference to an instance of Tokenizer.
  • pooler - An optional reference to an instance of MPNetPooler.
  • sentences - A reference to a vector of sentences.
  • chunksize - The size of each chunk for parallel processing.

§Returns

  • Result<Tensor> - A Result which is Ok if the embeddings could be computed successfully. The Err variant contains an error message.

§Errors

This function will return an error if the tokenization or the forward pass of the model fails.