所有模型的输出都是 ModelOutput 的子类的实例。这些是包含模型返回的所有信息的数据结构,但也可以用作元组或字典。
让我们看一个例子:
from transformers import BertTokenizer, BertForSequenceClassification
import torch
tokenizer = BertTokenizer.from_pretrained("google-bert/bert-base-uncased")
model = BertForSequenceClassification.from_pretrained("google-bert/bert-base-uncased")
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
labels = torch.tensor([1]).unsqueeze(0) # Batch size 1
outputs = model(**inputs, labels=labels)
outputs
对象是 SequenceClassifierOutput,如下面该类的文档中所示,它表示它有一个可选的 loss
,一个 logits
,一个可选的 hidden_states
和一个可选的 attentions
属性。在这里,我们有 loss
,因为我们传递了 labels
,但我们没有 hidden_states
和 attentions
,因为我们没有传递 output_hidden_states=True
或 output_attentions=True
。
当传递 output_hidden_states=True
时,您可能希望 outputs.hidden_states[-1]
与 outputs.last_hidden_states
完全匹配。然而,这并不总是成立。一些模型在返回最后的 hidden state时对其应用归一化或其他后续处理。
您可以像往常一样访问每个属性,如果模型未返回该属性,您将得到 None
。在这里,例如,outputs.loss
是模型计算的损失,而 outputs.attentions
是 None
。
当将我们的 outputs
对象视为元组时,它仅考虑那些没有 None
值的属性。例如这里它有两个元素,loss
和 logits
,所以
outputs[:2]
将返回元组 (outputs.loss, outputs.logits)
。
将我们的 outputs
对象视为字典时,它仅考虑那些没有 None
值的属性。例如在这里它有两个键,分别是 loss
和 logits
。
我们在这里记录了被多个类型模型使用的通用模型输出。特定输出类型在其相应的模型页面上有文档。
Base class for all model outputs as dataclass. Has a __getitem__
that allows indexing by integer or slice (like a
tuple) or strings (like a dictionary) that will ignore the None
attributes. Otherwise behaves like a regular
python dictionary.
You can’t unpack a ModelOutput
directly. Use the to_tuple() method to convert it to a tuple
before.
Convert self to a tuple containing all the attributes/keys that are not None
.
( last_hidden_state: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model’s outputs, with potential hidden states and attentions.
( last_hidden_state: FloatTensor = None pooler_output: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. torch.FloatTensor
of shape (batch_size, hidden_size)
) —
Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model’s outputs that also contains a pooling of the last hidden states.
( last_hidden_state: FloatTensor = None hidden_states: Optional = None attentions: Optional = None cross_attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
and config.add_cross_attention=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
Base class for model’s outputs, with potential hidden states and attentions.
( last_hidden_state: FloatTensor = None pooler_output: FloatTensor = None hidden_states: Optional = None past_key_values: Optional = None attentions: Optional = None cross_attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. torch.FloatTensor
of shape (batch_size, hidden_size)
) —
Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
and config.add_cross_attention=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and optionally if
config.is_encoder_decoder=True
2 additional tensors of shape (batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
config.is_encoder_decoder=True
in the cross-attention blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
Base class for model’s outputs that also contains a pooling of the last hidden states.
( last_hidden_state: FloatTensor = None past_key_values: Optional = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model.
If past_key_values
is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size)
is output.
tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and optionally if
config.is_encoder_decoder=True
2 additional tensors of shape (batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
config.is_encoder_decoder=True
in the cross-attention blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).
( last_hidden_state: FloatTensor = None past_key_values: Optional = None hidden_states: Optional = None attentions: Optional = None cross_attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model.
If past_key_values
is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size)
is output.
tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and optionally if
config.is_encoder_decoder=True
2 additional tensors of shape (batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
config.is_encoder_decoder=True
in the cross-attention blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
and config.add_cross_attention=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).
( last_hidden_state: FloatTensor = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the decoder of the model.
If past_key_values
is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size)
is output.
tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model encoder’s outputs that also contains : pre-computed hidden states that can speed up sequential decoding.
( loss: Optional = None logits: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Language modeling loss (for next-token prediction). torch.FloatTensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for causal language model (or autoregressive) outputs.
( loss: Optional = None logits: FloatTensor = None past_key_values: Optional = None hidden_states: Optional = None attentions: Optional = None cross_attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Language modeling loss (for next-token prediction). torch.FloatTensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Cross attentions weights after the attention softmax, used to compute the weighted average in the cross-attention heads.
tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of torch.FloatTensor
tuples of length config.n_layers
, with each tuple containing the cached key,
value states of the self-attention and the cross-attention layers if model is used in encoder-decoder
setting. Only relevant if config.is_decoder = True
.
Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
past_key_values
input) to speed up sequential decoding.
Base class for causal language model (or autoregressive) outputs.
( loss: Optional = None logits: FloatTensor = None past_key_values: Optional = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Language modeling loss (for next-token prediction). torch.FloatTensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
)
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for causal language model (or autoregressive) outputs.
( loss: Optional = None logits: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Masked language modeling (MLM) loss. torch.FloatTensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for masked language models outputs.
( loss: Optional = None logits: FloatTensor = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Language modeling loss. torch.FloatTensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for sequence-to-sequence language models outputs.
( loss: Optional = None logits: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when next_sentence_label
is provided) —
Next sequence prediction (classification) loss. torch.FloatTensor
of shape (batch_size, 2)
) —
Prediction scores of the next sequence prediction (classification) head (scores of True/False continuation
before SoftMax). tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of models predicting if two sentences are consecutive or not.
( loss: Optional = None logits: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Classification (or regression if config.num_labels==1) loss. torch.FloatTensor
of shape (batch_size, config.num_labels)
) —
Classification (or regression if config.num_labels==1) scores (before SoftMax). tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of sentence classification models.
( loss: Optional = None logits: FloatTensor = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when label
is provided) —
Classification (or regression if config.num_labels==1) loss. torch.FloatTensor
of shape (batch_size, config.num_labels)
) —
Classification (or regression if config.num_labels==1) scores (before SoftMax). tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of sequence-to-sequence sentence classification models.
( loss: Optional = None logits: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,), optional, returned when labels
is provided) —
Classification loss. torch.FloatTensor
of shape (batch_size, num_choices)
) —
num_choices is the second dimension of the input tensors. (see input_ids above).
Classification scores (before SoftMax).
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of multiple choice models.
( loss: Optional = None logits: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Classification loss. torch.FloatTensor
of shape (batch_size, sequence_length, config.num_labels)
) —
Classification scores (before SoftMax). tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of token classification models.
( loss: Optional = None start_logits: FloatTensor = None end_logits: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Total span extraction loss is the sum of a Cross-Entropy for the start and end positions. torch.FloatTensor
of shape (batch_size, sequence_length)
) —
Span-start scores (before SoftMax). torch.FloatTensor
of shape (batch_size, sequence_length)
) —
Span-end scores (before SoftMax). tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of question answering models.
( loss: Optional = None start_logits: FloatTensor = None end_logits: FloatTensor = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Total span extraction loss is the sum of a Cross-Entropy for the start and end positions. torch.FloatTensor
of shape (batch_size, sequence_length)
) —
Span-start scores (before SoftMax). torch.FloatTensor
of shape (batch_size, sequence_length)
) —
Span-end scores (before SoftMax). tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of sequence-to-sequence question answering models.
( loss: Optional = None spectrogram: FloatTensor = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Spectrogram generation loss. torch.FloatTensor
of shape (batch_size, sequence_length, num_bins)
) —
The predicted spectrogram. tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for sequence-to-sequence spectrogram outputs.
( loss: Optional = None logits: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Classification (or regression if config.num_labels==1) loss. torch.FloatTensor
of shape (batch_size, config.num_labels, logits_height, logits_width)
) —
Classification scores for each pixel.
The logits returned do not necessarily have the same size as the pixel_values
passed as inputs. This is
to avoid doing two interpolations and lose some quality when a user needs to resize the logits to the
original image size as post-processing. You should always check your logits shape and resize as needed.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, patch_size, hidden_size)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, patch_size, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of semantic segmentation models.
( loss: Optional = None logits: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Classification (or regression if config.num_labels==1) loss. torch.FloatTensor
of shape (batch_size, config.num_labels)
) —
Classification (or regression if config.num_labels==1) scores (before SoftMax). tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each stage) of shape (batch_size, sequence_length, hidden_size)
. Hidden-states
(also called feature maps) of the model at the output of each stage. tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, patch_size, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of image classification models.
( loss: Optional = None logits: FloatTensor = None hidden_states: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Classification (or regression if config.num_labels==1) loss. torch.FloatTensor
of shape (batch_size, config.num_labels)
) —
Classification (or regression if config.num_labels==1) scores (before SoftMax). tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each stage) of shape (batch_size, num_channels, height, width)
. Hidden-states (also
called feature maps) of the model at the output of each stage. Base class for outputs of image classification models.
( loss: Optional = None predicted_depth: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Classification (or regression if config.num_labels==1) loss. torch.FloatTensor
of shape (batch_size, height, width)
) —
Predicted depth for each pixel. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, num_channels, height, width)
.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, patch_size, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of depth estimation models.
( last_hidden_state: FloatTensor = None extract_features: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. torch.FloatTensor
of shape (batch_size, sequence_length, conv_dim[-1])
) —
Sequence of extracted feature vectors of the last convolutional layer of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings + one for the output of each layer) of
shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for models that have been trained with the Wav2Vec2 loss objective.
( loss: Optional = None logits: FloatTensor = None embeddings: FloatTensor = None hidden_states: Optional = None attentions: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when labels
is provided) —
Classification loss. torch.FloatTensor
of shape (batch_size, config.xvector_output_dim)
) —
Classification hidden states before AMSoftmax. torch.FloatTensor
of shape (batch_size, config.xvector_output_dim)
) —
Utterance embeddings used for vector similarity-based retrieval. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings + one for the output of each layer) of
shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Output type of Wav2Vec2ForXVector
.
( last_hidden_state: FloatTensor = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None loc: Optional = None scale: Optional = None static_features: Optional = None )
Parameters
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the decoder of the model.
If past_key_values
is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size)
is output.
tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the optional initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
torch.FloatTensor
of shape (batch_size,)
or (batch_size, input_size)
, optional) —
Shift values of each time series’ context window which is used to give the model inputs of the same
magnitude and then used to shift back to the original magnitude. torch.FloatTensor
of shape (batch_size,)
or (batch_size, input_size)
, optional) —
Scaling values of each time series’ context window which is used to give the model inputs of the same
magnitude and then used to rescale back to the original magnitude. torch.FloatTensor
of shape (batch_size, feature size)
, optional) —
Static features of each time series’ in a batch which are copied to the covariates at inference time. Base class for time series model’s encoder outputs that also contains pre-computed hidden states that can speed up sequential decoding.
( loss: Optional = None params: Optional = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None loc: Optional = None scale: Optional = None static_features: Optional = None )
Parameters
torch.FloatTensor
of shape (1,)
, optional, returned when a future_values
is provided) —
Distributional loss. torch.FloatTensor
of shape (batch_size, num_samples, num_params)
) —
Parameters of the chosen distribution. tuple(tuple(torch.FloatTensor))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(torch.FloatTensor)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
torch.FloatTensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(torch.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of torch.FloatTensor
(one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape (batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(torch.FloatTensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of torch.FloatTensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
torch.FloatTensor
of shape (batch_size,)
or (batch_size, input_size)
, optional) —
Shift values of each time series’ context window which is used to give the model inputs of the same
magnitude and then used to shift back to the original magnitude. torch.FloatTensor
of shape (batch_size,)
or (batch_size, input_size)
, optional) —
Scaling values of each time series’ context window which is used to give the model inputs of the same
magnitude and then used to rescale back to the original magnitude. torch.FloatTensor
of shape (batch_size, feature size)
, optional) —
Static features of each time series’ in a batch which are copied to the covariates at inference time. Base class for time series model’s decoder outputs that also contain the loss as well as the parameters of the chosen distribution.
( sequences: FloatTensor = None )
Base class for time series model’s predictions outputs that contains the sampled values from the chosen distribution.
( last_hidden_state: tf.Tensor = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. tuple(tf.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model’s outputs, with potential hidden states and attentions.
( last_hidden_state: tf.Tensor = None pooler_output: tf.Tensor = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. tf.Tensor
of shape (batch_size, hidden_size)
) —
Last layer hidden-state of the first token of the sequence (classification token) further processed by a
Linear layer and a Tanh activation function. The Linear layer weights are trained from the next sentence
prediction (classification) objective during pretraining.
This output is usually not a good summary of the semantic content of the input, you’re often better with averaging or pooling the sequence of hidden-states for the whole input sequence.
tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model’s outputs that also contains a pooling of the last hidden states.
( last_hidden_state: tf.Tensor = None pooler_output: tf.Tensor = None past_key_values: List[tf.Tensor] | None = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None cross_attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. tf.Tensor
of shape (batch_size, hidden_size)
) —
Last layer hidden-state of the first token of the sequence (classification token) further processed by a
Linear layer and a Tanh activation function. The Linear layer weights are trained from the next sentence
prediction (classification) objective during pretraining.
This output is usually not a good summary of the semantic content of the input, you’re often better with averaging or pooling the sequence of hidden-states for the whole input sequence.
List[tf.Tensor]
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
List of tf.Tensor
of length config.n_layers
, with each tensor of shape (2, batch_size, num_heads, sequence_length, embed_size_per_head)
).
Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
past_key_values
input) to speed up sequential decoding.
tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
Base class for model’s outputs that also contains a pooling of the last hidden states.
( last_hidden_state: tf.Tensor = None past_key_values: List[tf.Tensor] | None = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model.
If past_key_values
is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size)
is output.
List[tf.Tensor]
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
List of tf.Tensor
of length config.n_layers
, with each tensor of shape (2, batch_size, num_heads, sequence_length, embed_size_per_head)
).
Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
past_key_values
input) to speed up sequential decoding.
tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).
( last_hidden_state: tf.Tensor = None past_key_values: List[tf.Tensor] | None = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None cross_attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model.
If past_key_values
is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size)
is output.
List[tf.Tensor]
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
List of tf.Tensor
of length config.n_layers
, with each tensor of shape (2, batch_size, num_heads, sequence_length, embed_size_per_head)
).
Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
past_key_values
input) to speed up sequential decoding.
tuple(tf.FloatTensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).
( last_hidden_state: tf.Tensor = None past_key_values: List[tf.Tensor] | None = None decoder_hidden_states: Tuple[tf.Tensor] | None = None decoder_attentions: Tuple[tf.Tensor] | None = None cross_attentions: Tuple[tf.Tensor] | None = None encoder_last_hidden_state: tf.Tensor | None = None encoder_hidden_states: Tuple[tf.Tensor] | None = None encoder_attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the decoder of the model.
If past_key_values
is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size)
is output.
List[tf.Tensor]
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
List of tf.Tensor
of length config.n_layers
, with each tensor of shape (2, batch_size, num_heads, sequence_length, embed_size_per_head)
).
Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
used (see past_key_values
input) to speed up sequential decoding.
tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model encoder’s outputs that also contains : pre-computed hidden states that can speed up sequential decoding.
( loss: tf.Tensor | None = None logits: tf.Tensor = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (n,)
, optional, where n is the number of non-masked labels, returned when labels
is provided) —
Language modeling loss (for next-token prediction). tf.Tensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for causal language model (or autoregressive) outputs.
( loss: tf.Tensor | None = None logits: tf.Tensor = None past_key_values: List[tf.Tensor] | None = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None cross_attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (n,)
, optional, where n is the number of non-masked labels, returned when labels
is provided) —
Language modeling loss (for next-token prediction). tf.Tensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
List[tf.Tensor]
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
List of tf.Tensor
of length config.n_layers
, with each tensor of shape (2, batch_size, num_heads, sequence_length, embed_size_per_head)
).
Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
past_key_values
input) to speed up sequential decoding.
Base class for causal language model (or autoregressive) outputs.
( loss: tf.Tensor | None = None logits: tf.Tensor = None past_key_values: List[tf.Tensor] | None = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (n,)
, optional, where n is the number of non-masked labels, returned when labels
is provided) —
Language modeling loss (for next-token prediction). tf.Tensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). List[tf.Tensor]
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
List of tf.Tensor
of length config.n_layers
, with each tensor of shape (2, batch_size, num_heads, sequence_length, embed_size_per_head)
).
Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
past_key_values
input) to speed up sequential decoding.
tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for causal language model (or autoregressive) outputs.
( loss: tf.Tensor | None = None logits: tf.Tensor = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (n,)
, optional, where n is the number of non-masked labels, returned when labels
is provided) —
Masked language modeling (MLM) loss. tf.Tensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for masked language models outputs.
( loss: tf.Tensor | None = None logits: tf.Tensor = None past_key_values: List[tf.Tensor] | None = None decoder_hidden_states: Tuple[tf.Tensor] | None = None decoder_attentions: Tuple[tf.Tensor] | None = None cross_attentions: Tuple[tf.Tensor] | None = None encoder_last_hidden_state: tf.Tensor | None = None encoder_hidden_states: Tuple[tf.Tensor] | None = None encoder_attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (n,)
, optional, where n is the number of non-masked labels, returned when labels
is provided) —
Language modeling loss. tf.Tensor
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). List[tf.Tensor]
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
List of tf.Tensor
of length config.n_layers
, with each tensor of shape (2, batch_size, num_heads, sequence_length, embed_size_per_head)
).
Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
used (see past_key_values
input) to speed up sequential decoding.
tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for sequence-to-sequence language models outputs.
( loss: tf.Tensor | None = None logits: tf.Tensor = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (n,)
, optional, where n is the number of non-masked labels, returned when next_sentence_label
is provided) —
Next sentence prediction loss. tf.Tensor
of shape (batch_size, 2)
) —
Prediction scores of the next sequence prediction (classification) head (scores of True/False continuation
before SoftMax). tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of models predicting if two sentences are consecutive or not.
( loss: tf.Tensor | None = None logits: tf.Tensor = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (batch_size, )
, optional, returned when labels
is provided) —
Classification (or regression if config.num_labels==1) loss. tf.Tensor
of shape (batch_size, config.num_labels)
) —
Classification (or regression if config.num_labels==1) scores (before SoftMax). tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of sentence classification models.
( loss: tf.Tensor | None = None logits: tf.Tensor = None past_key_values: List[tf.Tensor] | None = None decoder_hidden_states: Tuple[tf.Tensor] | None = None decoder_attentions: Tuple[tf.Tensor] | None = None cross_attentions: Tuple[tf.Tensor] | None = None encoder_last_hidden_state: tf.Tensor | None = None encoder_hidden_states: Tuple[tf.Tensor] | None = None encoder_attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (1,)
, optional, returned when label
is provided) —
Classification (or regression if config.num_labels==1) loss. tf.Tensor
of shape (batch_size, config.num_labels)
) —
Classification (or regression if config.num_labels==1) scores (before SoftMax). List[tf.Tensor]
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
List of tf.Tensor
of length config.n_layers
, with each tensor of shape (2, batch_size, num_heads, sequence_length, embed_size_per_head)
).
Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
used (see past_key_values
input) to speed up sequential decoding.
tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of sequence-to-sequence sentence classification models.
( loss: tf.Tensor | None = None logits: tf.Tensor = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (batch_size, ), optional, returned when labels
is provided) —
Classification loss. tf.Tensor
of shape (batch_size, num_choices)
) —
num_choices is the second dimension of the input tensors. (see input_ids above).
Classification scores (before SoftMax).
tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of multiple choice models.
( loss: tf.Tensor | None = None logits: tf.Tensor = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (n,)
, optional, where n is the number of unmasked labels, returned when labels
is provided) —
Classification loss. tf.Tensor
of shape (batch_size, sequence_length, config.num_labels)
) —
Classification scores (before SoftMax). tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of token classification models.
( loss: tf.Tensor | None = None start_logits: tf.Tensor = None end_logits: tf.Tensor = None hidden_states: Tuple[tf.Tensor] | None = None attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (batch_size, )
, optional, returned when start_positions
and end_positions
are provided) —
Total span extraction loss is the sum of a Cross-Entropy for the start and end positions. tf.Tensor
of shape (batch_size, sequence_length)
) —
Span-start scores (before SoftMax). tf.Tensor
of shape (batch_size, sequence_length)
) —
Span-end scores (before SoftMax). tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of question answering models.
( loss: tf.Tensor | None = None start_logits: tf.Tensor = None end_logits: tf.Tensor = None past_key_values: List[tf.Tensor] | None = None decoder_hidden_states: Tuple[tf.Tensor] | None = None decoder_attentions: Tuple[tf.Tensor] | None = None encoder_last_hidden_state: tf.Tensor | None = None encoder_hidden_states: Tuple[tf.Tensor] | None = None encoder_attentions: Tuple[tf.Tensor] | None = None )
Parameters
tf.Tensor
of shape (1,)
, optional, returned when labels
is provided) —
Total span extraction loss is the sum of a Cross-Entropy for the start and end positions. tf.Tensor
of shape (batch_size, sequence_length)
) —
Span-start scores (before SoftMax). tf.Tensor
of shape (batch_size, sequence_length)
) —
Span-end scores (before SoftMax). List[tf.Tensor]
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
List of tf.Tensor
of length config.n_layers
, with each tensor of shape (2, batch_size, num_heads, sequence_length, embed_size_per_head)
).
Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
used (see past_key_values
input) to speed up sequential decoding.
tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tf.Tensor
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(tf.Tensor)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of tf.Tensor
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(tf.Tensor)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of tf.Tensor
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of sequence-to-sequence question answering models.
( last_hidden_state: Array = None hidden_states: Optional = None attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model’s outputs, with potential hidden states and attentions.
“Returns a new object replacing the specified fields with new values.
( last_hidden_state: Array = None past_key_values: Optional = None hidden_states: Optional = None attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. Dict[str, jnp.ndarray]
) —
Dictionary of pre-computed hidden-states (key and values in the attention blocks) that can be used for fast
auto-regressive decoding. Pre-computed key and value hidden-states are of shape [batch_size, max_length]. tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model’s outputs, with potential hidden states and attentions.
“Returns a new object replacing the specified fields with new values.
( last_hidden_state: Array = None pooler_output: Array = None hidden_states: Optional = None attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model. jnp.ndarray
of shape (batch_size, hidden_size)
) —
Last layer hidden-state of the first token of the sequence (classification token) further processed by a
Linear layer and a Tanh activation function. The Linear layer weights are trained from the next sentence
prediction (classification) objective during pretraining. tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model’s outputs that also contains a pooling of the last hidden states.
“Returns a new object replacing the specified fields with new values.
( last_hidden_state: Array = None past_key_values: Optional = None hidden_states: Optional = None attentions: Optional = None cross_attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the model.
If past_key_values
is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size)
is output.
tuple(tuple(jnp.ndarray))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(jnp.ndarray)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and optionally if
config.is_encoder_decoder=True
2 additional tensors of shape (batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
config.is_encoder_decoder=True
in the cross-attention blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
and config.add_cross_attention=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).
“Returns a new object replacing the specified fields with new values.
( last_hidden_state: Array = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length, hidden_size)
) —
Sequence of hidden-states at the output of the last layer of the decoder of the model.
If past_key_values
is used only the last hidden-state of the sequences of shape (batch_size, 1, hidden_size)
is output.
tuple(tuple(jnp.ndarray))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(jnp.ndarray)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
jnp.ndarray
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for model encoder’s outputs that also contains : pre-computed hidden states that can speed up sequential decoding.
“Returns a new object replacing the specified fields with new values.
( logits: Array = None past_key_values: Optional = None hidden_states: Optional = None attentions: Optional = None cross_attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Cross attentions weights after the attention softmax, used to compute the weighted average in the cross-attention heads.
tuple(tuple(jnp.ndarray))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of jnp.ndarray
tuples of length config.n_layers
, with each tuple containing the cached key, value
states of the self-attention and the cross-attention layers if model is used in encoder-decoder setting.
Only relevant if config.is_decoder = True
.
Contains pre-computed hidden-states (key and values in the attention blocks) that can be used (see
past_key_values
input) to speed up sequential decoding.
Base class for causal language model (or autoregressive) outputs.
“Returns a new object replacing the specified fields with new values.
( logits: Array = None hidden_states: Optional = None attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for masked language models outputs.
“Returns a new object replacing the specified fields with new values.
( logits: Array = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length, config.vocab_size)
) —
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax). tuple(tuple(jnp.ndarray))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(jnp.ndarray)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
jnp.ndarray
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for sequence-to-sequence language models outputs.
“Returns a new object replacing the specified fields with new values.
( logits: Array = None hidden_states: Optional = None attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, 2)
) —
Prediction scores of the next sequence prediction (classification) head (scores of True/False continuation
before SoftMax). tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of models predicting if two sentences are consecutive or not.
“Returns a new object replacing the specified fields with new values.
( logits: Array = None hidden_states: Optional = None attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, config.num_labels)
) —
Classification (or regression if config.num_labels==1) scores (before SoftMax). tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of sentence classification models.
“Returns a new object replacing the specified fields with new values.
( logits: Array = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, config.num_labels)
) —
Classification (or regression if config.num_labels==1) scores (before SoftMax). tuple(tuple(jnp.ndarray))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(jnp.ndarray)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
jnp.ndarray
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of sequence-to-sequence sentence classification models.
“Returns a new object replacing the specified fields with new values.
( logits: Array = None hidden_states: Optional = None attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, num_choices)
) —
num_choices is the second dimension of the input tensors. (see input_ids above).
Classification scores (before SoftMax).
tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of multiple choice models.
“Returns a new object replacing the specified fields with new values.
( logits: Array = None hidden_states: Optional = None attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length, config.num_labels)
) —
Classification scores (before SoftMax). tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of token classification models.
“Returns a new object replacing the specified fields with new values.
( start_logits: Array = None end_logits: Array = None hidden_states: Optional = None attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length)
) —
Span-start scores (before SoftMax). jnp.ndarray
of shape (batch_size, sequence_length)
) —
Span-end scores (before SoftMax). tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of question answering models.
“Returns a new object replacing the specified fields with new values.
( start_logits: Array = None end_logits: Array = None past_key_values: Optional = None decoder_hidden_states: Optional = None decoder_attentions: Optional = None cross_attentions: Optional = None encoder_last_hidden_state: Optional = None encoder_hidden_states: Optional = None encoder_attentions: Optional = None )
Parameters
jnp.ndarray
of shape (batch_size, sequence_length)
) —
Span-start scores (before SoftMax). jnp.ndarray
of shape (batch_size, sequence_length)
) —
Span-end scores (before SoftMax). tuple(tuple(jnp.ndarray))
, optional, returned when use_cache=True
is passed or when config.use_cache=True
) —
Tuple of tuple(jnp.ndarray)
of length config.n_layers
, with each tuple having 2 tensors of shape
(batch_size, num_heads, sequence_length, embed_size_per_head)
) and 2 additional tensors of shape
(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)
.
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
blocks) that can be used (see past_key_values
input) to speed up sequential decoding.
tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the decoder at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the decoder’s cross-attention layer, after the attention softmax, used to compute the weighted average in the cross-attention heads.
jnp.ndarray
of shape (batch_size, sequence_length, hidden_size)
, optional) —
Sequence of hidden-states at the output of the last layer of the encoder of the model. tuple(jnp.ndarray)
, optional, returned when output_hidden_states=True
is passed or when config.output_hidden_states=True
) —
Tuple of jnp.ndarray
(one for the output of the embeddings + one for the output of each layer) of shape
(batch_size, sequence_length, hidden_size)
.
Hidden-states of the encoder at the output of each layer plus the initial embedding outputs.
tuple(jnp.ndarray)
, optional, returned when output_attentions=True
is passed or when config.output_attentions=True
) —
Tuple of jnp.ndarray
(one for each layer) of shape (batch_size, num_heads, sequence_length, sequence_length)
.
Attentions weights of the encoder, after the attention softmax, used to compute the weighted average in the self-attention heads.
Base class for outputs of sequence-to-sequence question answering models.
“Returns a new object replacing the specified fields with new values.