transformers documentation

Model outputs

Model outputs

All models have outputs that are instances of subclasses of ModelOutput. Those are data structures containing all the information returned by the model, but that can also be used as tuples or dictionaries.

Let’s see of this looks on an example:

from transformers import BertTokenizer, BertForSequenceClassification
import torch

tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = BertForSequenceClassification.from_pretrained('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)

The outputs object is a SequenceClassifierOutput, as we can see in the documentation of that class below, it means it has an optional loss, a logits an optional hidden_states and an optional attentions attribute. Here we have the loss since we passed along labels, but we don’t have hidden_states and attentions because we didn’t pass output_hidden_states=True or output_attentions=True.

You can access each attribute as you would usually do, and if that attribute has not been returned by the model, you will get None. Here for instance outputs.loss is the loss computed by the model, and outputs.attentions is None.

When considering our outputs object as tuple, it only considers the attributes that don’t have None values. Here for instance, it has two elements, loss then logits, so

outputs[:2]

will return the tuple (outputs.loss, outputs.logits) for instance.

When considering our outputs object as dictionary, it only considers the attributes that don’t have None values. Here for instance, it has two keys that are loss and logits.

We document here the generic model outputs that are used by more than one model type. Specific output types are documented on their corresponding model page.

ModelOutput

class transformers.file_utils.ModelOutput < > expand 

( )

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.

to_tuple < > expand 

( )

Convert self to a tuple containing all the attributes/keys that are not None.

BaseModelOutput

class transformers.modeling_outputs.BaseModelOutput < > expand 

( last_hidden_state: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for model’s outputs, with potential hidden states and attentions.

BaseModelOutputWithPooling

class transformers.modeling_outputs.BaseModelOutputWithPooling < > expand 

( last_hidden_state: FloatTensor = None pooler_output: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for model’s outputs that also contains a pooling of the last hidden states.

BaseModelOutputWithCrossAttentions

class transformers.modeling_outputs.BaseModelOutputWithCrossAttentions < > expand 

( last_hidden_state: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None cross_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for model’s outputs, with potential hidden states and attentions.

BaseModelOutputWithPoolingAndCrossAttentions

class transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions < > expand 

( last_hidden_state: FloatTensor = None pooler_output: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None cross_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for model’s outputs that also contains a pooling of the last hidden states.

BaseModelOutputWithPast

class transformers.modeling_outputs.BaseModelOutputWithPast < > expand 

( last_hidden_state: FloatTensor = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).

BaseModelOutputWithPastAndCrossAttentions

class transformers.modeling_outputs.BaseModelOutputWithPastAndCrossAttentions < > expand 

( last_hidden_state: FloatTensor = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None cross_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).

Seq2SeqModelOutput

class transformers.modeling_outputs.Seq2SeqModelOutput < > expand 

( last_hidden_state: FloatTensor = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None decoder_hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None decoder_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None cross_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None encoder_last_hidden_state: typing.Optional[torch.FloatTensor] = None encoder_hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None encoder_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for model encoder’s outputs that also contains : pre-computed hidden states that can speed up sequential decoding.

CausalLMOutput

class transformers.modeling_outputs.CausalLMOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for causal language model (or autoregressive) outputs.

CausalLMOutputWithCrossAttentions

class transformers.modeling_outputs.CausalLMOutputWithCrossAttentions < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None cross_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for causal language model (or autoregressive) outputs.

CausalLMOutputWithPast

class transformers.modeling_outputs.CausalLMOutputWithPast < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for causal language model (or autoregressive) outputs.

MaskedLMOutput

class transformers.modeling_outputs.MaskedLMOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for masked language models outputs.

Seq2SeqLMOutput

class transformers.modeling_outputs.Seq2SeqLMOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None decoder_hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None decoder_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None cross_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None encoder_last_hidden_state: typing.Optional[torch.FloatTensor] = None encoder_hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None encoder_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for sequence-to-sequence language models outputs.

NextSentencePredictorOutput

class transformers.modeling_outputs.NextSentencePredictorOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for outputs of models predicting if two sentences are consecutive or not.

SequenceClassifierOutput

class transformers.modeling_outputs.SequenceClassifierOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for outputs of sentence classification models.

Seq2SeqSequenceClassifierOutput

class transformers.modeling_outputs.Seq2SeqSequenceClassifierOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None decoder_hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None decoder_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None cross_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None encoder_last_hidden_state: typing.Optional[torch.FloatTensor] = None encoder_hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None encoder_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for outputs of sequence-to-sequence sentence classification models.

MultipleChoiceModelOutput

class transformers.modeling_outputs.MultipleChoiceModelOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for outputs of multiple choice models.

TokenClassifierOutput

class transformers.modeling_outputs.TokenClassifierOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None logits: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for outputs of token classification models.

QuestionAnsweringModelOutput

class transformers.modeling_outputs.QuestionAnsweringModelOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None start_logits: FloatTensor = None end_logits: FloatTensor = None hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for outputs of question answering models.

Seq2SeqQuestionAnsweringModelOutput

class transformers.modeling_outputs.Seq2SeqQuestionAnsweringModelOutput < > expand 

( loss: typing.Optional[torch.FloatTensor] = None start_logits: FloatTensor = None end_logits: FloatTensor = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[torch.FloatTensor]]] = None decoder_hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None decoder_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None cross_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None encoder_last_hidden_state: typing.Optional[torch.FloatTensor] = None encoder_hidden_states: typing.Optional[typing.Tuple[torch.FloatTensor]] = None encoder_attentions: typing.Optional[typing.Tuple[torch.FloatTensor]] = None )

Base class for outputs of sequence-to-sequence question answering models.

TFBaseModelOutput

class transformers.modeling_tf_outputs.TFBaseModelOutput < > expand 

( last_hidden_state: Tensor = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for model’s outputs, with potential hidden states and attentions.

TFBaseModelOutputWithPooling

class transformers.modeling_tf_outputs.TFBaseModelOutputWithPooling < > expand 

( last_hidden_state: Tensor = None pooler_output: Tensor = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for model’s outputs that also contains a pooling of the last hidden states.

TFBaseModelOutputWithPoolingAndCrossAttentions

class transformers.modeling_tf_outputs.TFBaseModelOutputWithPoolingAndCrossAttentions < > expand 

( last_hidden_state: Tensor = None pooler_output: Tensor = None past_key_values: typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None cross_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for model’s outputs that also contains a pooling of the last hidden states.

TFBaseModelOutputWithPast

class transformers.modeling_tf_outputs.TFBaseModelOutputWithPast < > expand 

( last_hidden_state: Tensor = None past_key_values: typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).

TFBaseModelOutputWithPastAndCrossAttentions

class transformers.modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions < > expand 

( last_hidden_state: Tensor = None past_key_values: typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None cross_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).

TFSeq2SeqModelOutput

class transformers.modeling_tf_outputs.TFSeq2SeqModelOutput < > expand 

( last_hidden_state: Tensor = None past_key_values: typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None decoder_hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None decoder_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None cross_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None encoder_last_hidden_state: typing.Optional[tensorflow.python.framework.ops.Tensor] = None encoder_hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None encoder_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for model encoder’s outputs that also contains : pre-computed hidden states that can speed up sequential decoding.

TFCausalLMOutput

class transformers.modeling_tf_outputs.TFCausalLMOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for causal language model (or autoregressive) outputs.

TFCausalLMOutputWithCrossAttentions

class transformers.modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None past_key_values: typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None cross_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for causal language model (or autoregressive) outputs.

TFCausalLMOutputWithPast

class transformers.modeling_tf_outputs.TFCausalLMOutputWithPast < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None past_key_values: typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for causal language model (or autoregressive) outputs.

TFMaskedLMOutput

class transformers.modeling_tf_outputs.TFMaskedLMOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for masked language models outputs.

TFSeq2SeqLMOutput

class transformers.modeling_tf_outputs.TFSeq2SeqLMOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None past_key_values: typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None decoder_hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None decoder_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None cross_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None encoder_last_hidden_state: typing.Optional[tensorflow.python.framework.ops.Tensor] = None encoder_hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None encoder_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for sequence-to-sequence language models outputs.

TFNextSentencePredictorOutput

class transformers.modeling_tf_outputs.TFNextSentencePredictorOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for outputs of models predicting if two sentences are consecutive or not.

TFSequenceClassifierOutput

class transformers.modeling_tf_outputs.TFSequenceClassifierOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for outputs of sentence classification models.

TFSeq2SeqSequenceClassifierOutput

class transformers.modeling_tf_outputs.TFSeq2SeqSequenceClassifierOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None past_key_values: typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None decoder_hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None decoder_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None encoder_last_hidden_state: typing.Optional[tensorflow.python.framework.ops.Tensor] = None encoder_hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None encoder_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for outputs of sequence-to-sequence sentence classification models.

TFMultipleChoiceModelOutput

class transformers.modeling_tf_outputs.TFMultipleChoiceModelOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for outputs of multiple choice models.

TFTokenClassifierOutput

class transformers.modeling_tf_outputs.TFTokenClassifierOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None logits: Tensor = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for outputs of token classification models.

TFQuestionAnsweringModelOutput

class transformers.modeling_tf_outputs.TFQuestionAnsweringModelOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None start_logits: Tensor = None end_logits: Tensor = None hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for outputs of question answering models.

TFSeq2SeqQuestionAnsweringModelOutput

class transformers.modeling_tf_outputs.TFSeq2SeqQuestionAnsweringModelOutput < > expand 

( loss: typing.Optional[tensorflow.python.framework.ops.Tensor] = None start_logits: Tensor = None end_logits: Tensor = None past_key_values: typing.Optional[typing.List[tensorflow.python.framework.ops.Tensor]] = None decoder_hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None decoder_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None encoder_last_hidden_state: typing.Optional[tensorflow.python.framework.ops.Tensor] = None encoder_hidden_states: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None encoder_attentions: typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None )

Base class for outputs of sequence-to-sequence question answering models.

FlaxBaseModelOutput

class transformers.modeling_flax_outputs.FlaxBaseModelOutput < > expand 

( last_hidden_state: ndarray = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for model’s outputs, with potential hidden states and attentions.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxBaseModelOutputWithPast

class transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPast < > expand 

( last_hidden_state: ndarray = None past_key_values: typing.Union[typing.Dict[str, jax._src.numpy.lax_numpy.ndarray], NoneType] = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for model’s outputs, with potential hidden states and attentions.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxBaseModelOutputWithPooling

class transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPooling < > expand 

( last_hidden_state: ndarray = None pooler_output: ndarray = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for model’s outputs that also contains a pooling of the last hidden states.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxBaseModelOutputWithPastAndCrossAttentions

class transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions < > expand 

( last_hidden_state: ndarray = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]]] = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None cross_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for model’s outputs that may also contain a past key/values (to speed up sequential decoding).

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxSeq2SeqModelOutput

class transformers.modeling_flax_outputs.FlaxSeq2SeqModelOutput < > expand 

( last_hidden_state: ndarray = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]]] = None decoder_hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None decoder_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None cross_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None encoder_last_hidden_state: typing.Optional[jax._src.numpy.lax_numpy.ndarray] = None encoder_hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None encoder_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for model encoder’s outputs that also contains : pre-computed hidden states that can speed up sequential decoding.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxCausalLMOutputWithCrossAttentions

class transformers.modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions < > expand 

( logits: ndarray = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]]] = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None cross_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for causal language model (or autoregressive) outputs.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxMaskedLMOutput

class transformers.modeling_flax_outputs.FlaxMaskedLMOutput < > expand 

( logits: ndarray = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for masked language models outputs.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxSeq2SeqLMOutput

class transformers.modeling_flax_outputs.FlaxSeq2SeqLMOutput < > expand 

( logits: ndarray = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]]] = None decoder_hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None decoder_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None cross_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None encoder_last_hidden_state: typing.Optional[jax._src.numpy.lax_numpy.ndarray] = None encoder_hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None encoder_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for sequence-to-sequence language models outputs.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxNextSentencePredictorOutput

class transformers.modeling_flax_outputs.FlaxNextSentencePredictorOutput < > expand 

( logits: ndarray = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for outputs of models predicting if two sentences are consecutive or not.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxSequenceClassifierOutput

class transformers.modeling_flax_outputs.FlaxSequenceClassifierOutput < > expand 

( logits: ndarray = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for outputs of sentence classification models.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxSeq2SeqSequenceClassifierOutput

class transformers.modeling_flax_outputs.FlaxSeq2SeqSequenceClassifierOutput < > expand 

( logits: ndarray = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]]] = None decoder_hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None decoder_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None cross_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None encoder_last_hidden_state: typing.Optional[jax._src.numpy.lax_numpy.ndarray] = None encoder_hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None encoder_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for outputs of sequence-to-sequence sentence classification models.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxMultipleChoiceModelOutput

class transformers.modeling_flax_outputs.FlaxMultipleChoiceModelOutput < > expand 

( logits: ndarray = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for outputs of multiple choice models.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxTokenClassifierOutput

class transformers.modeling_flax_outputs.FlaxTokenClassifierOutput < > expand 

( logits: ndarray = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for outputs of token classification models.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxQuestionAnsweringModelOutput

class transformers.modeling_flax_outputs.FlaxQuestionAnsweringModelOutput < > expand 

( start_logits: ndarray = None end_logits: ndarray = None hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for outputs of question answering models.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.

FlaxSeq2SeqQuestionAnsweringModelOutput

class transformers.modeling_flax_outputs.FlaxSeq2SeqQuestionAnsweringModelOutput < > expand 

( start_logits: ndarray = None end_logits: ndarray = None past_key_values: typing.Optional[typing.Tuple[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]]] = None decoder_hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None decoder_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None cross_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None encoder_last_hidden_state: typing.Optional[jax._src.numpy.lax_numpy.ndarray] = None encoder_hidden_states: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None encoder_attentions: typing.Optional[typing.Tuple[jax._src.numpy.lax_numpy.ndarray]] = None )

Base class for outputs of sequence-to-sequence question answering models.

replace < > expand 

( **updates )

“Returns a new object replacing the specified fields with new values.