Trait Encoder

Source
pub trait Encoder {
    // Required method
    fn forward_t(
        &self,
        piece_ids: &Tensor,
        attention_mask: &AttentionMask,
        positions: Option<&Tensor>,
        type_ids: Option<&Tensor>,
        train: bool,
    ) -> Result<EncoderOutput, BoxedError>;
}
Expand description

Trait for encoders.

Required Methods§

Source

fn forward_t( &self, piece_ids: &Tensor, attention_mask: &AttentionMask, positions: Option<&Tensor>, type_ids: Option<&Tensor>, train: bool, ) -> Result<EncoderOutput, BoxedError>

Encode an input sequence.

Returns the encoder output.

  • piece_ids - Input sequence. Shape: (batch_size, seq_len)
  • attention_mask - Attention mask. Sequence elements for which the corresponding mask element is set to false are ignored during attention calculation. Shape: (batch_size, seq_len)
  • positions - Input positions. Shape: (batch_size, seq_len)
  • type_ids - Input type ids. Shape: (batch_size, seq_len)
  • train - Whether to train the layer.

Implementors§