pub struct SentenceEmbeddingsModel { /* private fields */ }Expand description
SentenceEmbeddingsModel to perform sentence embeddings
It is made of the following blocks:
transformer: Base transformer modelpooling: Pooling layerdense(optional): Linear (feed forward) layernormalization(optional): Embeddings normalization
Implementations
sourceimpl SentenceEmbeddingsModel
impl SentenceEmbeddingsModel
sourcepub fn new(config: SentenceEmbeddingsConfig) -> Result<Self, RustBertError>
pub fn new(config: SentenceEmbeddingsConfig) -> Result<Self, RustBertError>
Build a new SentenceEmbeddingsModel
Arguments
config-SentenceEmbeddingsConfigobject containing the resource references (model, vocabulary, configuration) and device placement (CPU/GPU)
sourcepub fn set_tokenizer_truncation(
&mut self,
truncation_strategy: TruncationStrategy
)
pub fn set_tokenizer_truncation(
&mut self,
truncation_strategy: TruncationStrategy
)
Sets the tokenizer’s truncation strategy
sourcepub fn tokenize<S>(&self, inputs: &[S]) -> SentenceEmbeddingsTokenizerOuput where
S: AsRef<str> + Sync,
pub fn tokenize<S>(&self, inputs: &[S]) -> SentenceEmbeddingsTokenizerOuput where
S: AsRef<str> + Sync,
Tokenizes the inputs
sourcepub fn encode_as_tensor<S>(
&self,
inputs: &[S]
) -> Result<SentenceEmbeddingsModelOuput, RustBertError> where
S: AsRef<str> + Sync,
pub fn encode_as_tensor<S>(
&self,
inputs: &[S]
) -> Result<SentenceEmbeddingsModelOuput, RustBertError> where
S: AsRef<str> + Sync,
Computes sentence embeddings, outputs Tensor.
sourcepub fn encode<S>(&self, inputs: &[S]) -> Result<Vec<Embedding>, RustBertError> where
S: AsRef<str> + Sync,
pub fn encode<S>(&self, inputs: &[S]) -> Result<Vec<Embedding>, RustBertError> where
S: AsRef<str> + Sync,
Computes sentence embeddings.
sourcepub fn encode_with_attention<S>(
&self,
inputs: &[S]
) -> Result<(Vec<Embedding>, Vec<AttentionOutput>), RustBertError> where
S: AsRef<str> + Sync,
pub fn encode_with_attention<S>(
&self,
inputs: &[S]
) -> Result<(Vec<Embedding>, Vec<AttentionOutput>), RustBertError> where
S: AsRef<str> + Sync,
Computes sentence embeddings, also outputs AttentionOutputs.
Auto Trait Implementations
impl RefUnwindSafe for SentenceEmbeddingsModel
impl Send for SentenceEmbeddingsModel
impl !Sync for SentenceEmbeddingsModel
impl Unpin for SentenceEmbeddingsModel
impl UnwindSafe for SentenceEmbeddingsModel
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more