pub struct T5ForSentenceEmbeddings { /* private fields */ }
Expand description
§T5 for sentence embeddings
Transformer usable in SentenceEmbeddingsModel
.
Implementations§
Source§impl T5ForSentenceEmbeddings
impl T5ForSentenceEmbeddings
Sourcepub fn new<'p, P>(p: P, config: &T5Config) -> Self
pub fn new<'p, P>(p: P, config: &T5Config) -> Self
Build a new T5ForSentenceEmbeddings
§Arguments
p
- Variable store path for the root of the BART modelconfig
-T5Config
object defining the model architecture
It consists of only an encoder (there is no decoder).
Sourcepub fn forward(
&self,
input_ids: &Tensor,
mask: &Tensor,
) -> Result<(Tensor, Option<Vec<Tensor>>), RustBertError>
pub fn forward( &self, input_ids: &Tensor, mask: &Tensor, ) -> Result<(Tensor, Option<Vec<Tensor>>), RustBertError>
Forward pass through the model
§Arguments
input_ids
- Input of shape (batch size, source_sequence_length).mask
- Attention mask of shape (batch size, source_sequence_length) for the encoder positions. Positions with a mask with value 0 will be masked.
§Returns
- Tuple containing:
Tensor
of shape (batch size, target_sequence_length, hidden_size) representing the activations of the last encoder hidden stateOption<Vec<Tensor>>
of length num_encoder_layers of shape (batch size, target_sequence_length, hidden_size) representing attention weights for all layers of the encoder
Auto Trait Implementations§
impl Freeze for T5ForSentenceEmbeddings
impl RefUnwindSafe for T5ForSentenceEmbeddings
impl Send for T5ForSentenceEmbeddings
impl !Sync for T5ForSentenceEmbeddings
impl Unpin for T5ForSentenceEmbeddings
impl UnwindSafe for T5ForSentenceEmbeddings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more