Base class for model's outputs that also contains a pooling of the last hidden states. Args: hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`): Sequence of hidden-states at the output of the last layer of the model. attenti
| 94 | |
| 95 | @dataclass |
| 96 | class TextEncoderModelOutput(ModelOutput): |
| 97 | """ |
| 98 | Base class for model's outputs that also contains a pooling of the last hidden states. |
| 99 | |
| 100 | Args: |
| 101 | hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`): |
| 102 | Sequence of hidden-states at the output of the last layer of the model. |
| 103 | attention_mask (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*): |
| 104 | Mask to avoid performing attention on padding token indices. Mask values selected in ``[0, 1]``: |
| 105 | hidden_states_list (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed): |
| 106 | Tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, + |
| 107 | one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`. |
| 108 | Hidden-states of the model at the output of each layer plus the optional initial embedding outputs. |
| 109 | text_outputs (`list`, *optional*, returned when `return_texts=True` is passed): |
| 110 | List of decoded texts. |
| 111 | """ |
| 112 | |
| 113 | hidden_state: torch.FloatTensor = None |
| 114 | attention_mask: Optional[torch.LongTensor] = None |
| 115 | hidden_states_list: Optional[Tuple[torch.FloatTensor, ...]] = None |
| 116 | text_outputs: Optional[list] = None |
| 117 | |
| 118 | |
| 119 | class TextEncoder(nn.Module): |