Struct rust_bert::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) -> Selfwhere
P: Borrow<Path<'p>>,
pub fn new<'p, P>(p: P, config: &T5Config) -> Selfwhere
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