Struct rust_bert::models::t5::T5ForSentenceEmbeddings
source · 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 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