-
Notifications
You must be signed in to change notification settings - Fork 99
Description
Hi!
I'm trying to run MLuke on https://github.com/studio-ousia/luke/blob/master/notebooks/huggingface_conll_2003.ipynb by replacing studio-ousia/luke-large-finetuned-conll-2003 with studio-ousia/mluke-large-lite-finetuned-conll-2003 and changing LukeTokenizer to MLukeTokenizer.
Every thing looks find until the block:
batch_size = 2
all_logits = []for batch_start_idx in trange(0, len(test_examples), batch_size):
batch_examples = test_examples[batch_start_idx:batch_start_idx + batch_size]
texts = [example["text"] for example in batch_examples]
entity_spans = [example["entity_spans"] for example in batch_examples]inputs = tokenizer(texts, entity_spans=entity_spans, return_tensors="pt", padding=True) inputs = inputs.to("cuda") with torch.no_grad(): outputs = model(**inputs) all_logits.extend(outputs.logits.tolist())
The error is
AttributeError Traceback (most recent call last)
Cell In [8], line 12
10 inputs = inputs.to("cuda")
11 with torch.no_grad():
---> 12 outputs = model(**inputs)
13 all_logits.extend(outputs.logits.tolist())
File /opt/conda/envs/spacy_env/lib/python3.9/site-packages/torch/nn/modules/module.py:1102, in Module._call_impl(self, *input, **kwargs)
1098 # If we don't have any hooks, we want to skip the rest of the logic in
1099 # this function, and just call forward.
1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1101 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1102 return forward_call(*input, **kwargs)
1103 # Do not call functions when jit is used
1104 full_backward_hooks, non_full_backward_hooks = [], []
File /opt/conda/envs/spacy_env/lib/python3.9/site-packages/transformers/models/luke/modeling_luke.py:1588, in LukeForEntitySpanClassification.forward(self, input_ids, attention_mask, token_type_ids, position_ids, entity_ids, entity_attention_mask, entity_token_type_ids, entity_position_ids, entity_start_positions, entity_end_positions, head_mask, inputs_embeds, labels, output_attentions, output_hidden_states, return_dict)
1571 outputs = self.luke(
1572 input_ids=input_ids,
1573 attention_mask=attention_mask,
(...)
1584 return_dict=True,
1585 )
1586 hidden_size = outputs.last_hidden_state.size(-1)
-> 1588 entity_start_positions = entity_start_positions.unsqueeze(-1).expand(-1, -1, hidden_size)
1589 start_states = torch.gather(outputs.last_hidden_state, -2, entity_start_positions)
1590 entity_end_positions = entity_end_positions.unsqueeze(-1).expand(-1, -1, hidden_size)
AttributeError: 'NoneType' object has no attribute 'unsqueeze'
Thank you.