Struct rust_bert::t5::T5ForSentenceEmbeddings
source · [−]pub struct T5ForSentenceEmbeddings { /* private fields */ }Expand description
T5 for sentence embeddings
Transformer usable in SentenceEmbeddingsModel.
Implementations
sourceimpl T5ForSentenceEmbeddings
impl T5ForSentenceEmbeddings
sourcepub fn new<'p, P>(p: P, config: &T5Config) -> Self where
P: Borrow<Path<'p>>,
pub fn new<'p, P>(p: P, config: &T5Config) -> Self where
P: Borrow<Path<'p>>,
Build a new T5ForSentenceEmbeddings
Arguments
p- Variable store path for the root of the BART modelconfig-T5Configobject 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:
Tensorof 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
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