You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File /miniconda3/envs/tmp/lib/python3.10/site-packages/transformers/models/canine/modeling_canine.py:1172, in CanineModel.forward(self, input_ids, attention_mask, token_type_ids, position_ids, head_mask, inputs_embeds, output_attentions, output_hidden_states, return_dict)
1162 input_char_embeddings = self.char_embeddings(
1163 input_ids=input_ids,
1164 position_ids=position_ids,
1165 token_type_ids=token_type_ids,
1166 inputs_embeds=inputs_embeds,
1167 )
1169 # Contextualize character embeddings using shallow Transformer.
1170 # We use a 3D attention mask for the local attention.
1171 # `input_char_encoding`: shape (batch_size, char_seq_len, char_dim)
-> 1172 char_attention_mask = self._create_3d_attention_mask_from_input_mask(input_ids, attention_mask)
1173 init_chars_encoder_outputs = self.initial_char_encoder(
1174 input_char_embeddings,
1175 attention_mask=char_attention_mask,
1176 output_attentions=output_attentions,
1177 output_hidden_states=output_hidden_states,
1178 )
1179 input_char_encoding = init_chars_encoder_outputs.last_hidden_state
File /miniconda3/envs/tmp/lib/python3.10/site-packages/transformers/models/canine/modeling_canine.py:1042, in CanineModel._create_3d_attention_mask_from_input_mask(self, from_tensor, to_mask)
1031 def _create_3d_attention_mask_from_input_mask(self, from_tensor, to_mask):
1032 """
1033 Create 3D attention mask from a 2D tensor mask.
1034
(...)
1040 float Tensor of shape [batch_size, from_seq_length, to_seq_length].
1041 """
-> 1042 batch_size, from_seq_length = from_tensor.shape[0], from_tensor.shape[1]
1044 to_seq_length = to_mask.shape[1]
1046 to_mask = torch.reshape(to_mask, (batch_size, 1, to_seq_length)).float()
AttributeError: 'NoneType' object has no attribute 'shape'
Expected behavior
According to doc, the forward should work with either input_ids or inputs_embeds provided. But it turns out input_ids is used for deriving other variables in the code in all cases.
The text was updated successfully, but these errors were encountered:
marcmk6
changed the title
CANINE requires input_ids anyway
CANINE unexpectedly requires input_ids anyway
Sep 20, 2023
System Info
transformers
version: 4.33.2Who can help?
@ArthurZucker and @younesbelkada
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
The error message
Expected behavior
According to doc, the forward should work with either
input_ids
orinputs_embeds
provided. But it turns outinput_ids
is used for deriving other variables in the code in all cases.The text was updated successfully, but these errors were encountered: