Summarization of scientific literature with destilbart-cnn-12-6

#12
by aschmidt99 - opened

Hi all

I am trying to summarize scientific articles using distilbart-cnn-12-6
I tried it with a normal fictional book (Dorian Gray) to start with and it worked fine but as soon as I wanted to summarize a scientific article it came up with several error messages after a couple of minutes.
I don’t know what they mean and how to rectify them.
Does anyone have any suggestions?

Kind regards

Anders

IndexError Traceback (most recent call last)
in
1 for input in inputs:
----> 2 output = model.generate(**input)
3 print(tokenizer.decode(*output, skip_special_tokens=True))


8 frames


/usr/local/lib/python3.8/dist-packages/torch/autograd/grad_mode.py in decorate_context(*args, **kwargs)
25 def decorate_context(*args, **kwargs):
26 with self.clone():
---> 27 return func(*args, **kwargs)
28 return cast(F, decorate_context)
29

/usr/local/lib/python3.8/dist-packages/transformers/generation/utils.py in generate(self, inputs, generation_config, logits_processor, stopping_criteria, prefix_allowed_tokens_fn, synced_gpus, **kwargs)
1250 # if model is encoder decoder encoder_outputs are created
1251 # and added to model_kwargs
-> 1252 model_kwargs = self.prepare_encoder_decoder kwargs_for_generation(
1253 inputs_tensor, model_kwargs, model_input_name
1254 )

/usr/local/lib/python3.8/dist-packages/transformers/generation/utils.py in _prepare_encoder_decoder_kwargs_for_generation(self, inputs_tensor, model_kwargs, model_input_name)
615 encoder_kwargs["return_dict"] = True
616 encoder_kwargs[model_input_name] = inputs_tensor
--> 617 model_kwargs["encoder_outputs"]: ModelOutput = encoder(**encoder_kwargs)
618
619 return model_kwargs

/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
1192 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1193 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1194 return forward_call(*input, **kwargs)
1195 # Do not call functions when jit is used
1196 full_backward_hooks, non_full_backward_hooks = [], []

/usr/local/lib/python3.8/dist-packages/transformers/models/bart/modeling_bart.py in forward(self, input_ids, attention_mask, head_mask, inputs_embeds, output_attentions, output_hidden_states, return_dict)
808 inputs_embeds = self.embed_tokens(input_ids) * self.embed_scale
809
--> 810 embed_pos = self.embed_positions(input)
811 embed_pos = embed_pos.to(inputs_embeds.device)
812

/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
1192 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1193 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1194 return forward_call(*input, **kwargs)
1195 # Do not call functions when jit is used
1196 full_backward_hooks, non_full_backward_hooks = [], []

/usr/local/lib/python3.8/dist-packages/transformers/models/bart/modeling_bart.py in forward(self, input_ids, past_key_values_length)
136 ).expand(bsz, -1)
137
--> 138 return super().forward(positions + self.offset)
139
140

/usr/local/lib/python3.8/dist-packages/torch/nn/modules/sparse.py in forward(self, input)
158
159 def forward(self, input: Tensor) -> Tensor:
--> 160 return F.embedding(
161 input, self.weight, self.padding_idx, self.max_norm,
162 self.norm_type, self.scale_grad_by_freq, self.sparse)

/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse)
2208 # remove once script supports set_grad_enabled
2209 no_grad_embedding_renorm(weight, input, max_norm, norm_type)
-> 2210 return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
2211
2212

IndexError: index out of range in self

I see this error when I try to process more text than the limit of the model. Maybe try it with a few paragraphs first?

Thank you for the input. I will try that

Sign up or log in to comment