I am trying to convert the Pegasus newsroom in HuggingFace's transformers model to the ONNX format. I followed this guide published by Huggingface. After installing the prereqs, I ran this code:
!rm -rf onnx/
from pathlib import Path
from transformers.convert_graph_to_onnx import convert
convert(framework="pt", model="google/pegasus-newsroom", output=Path("onnx/google/pegasus-newsroom.onnx"), opset=11)
and got these errors:
ValueError Traceback (most recent call last)
<ipython-input-9-3b37ed1ceda5> in <module>()
3 from transformers.convert_graph_to_onnx import convert
4
----> 5 convert(framework="pt", model="google/pegasus-newsroom", output=Path("onnx/google/pegasus-newsroom.onnx"), opset=11)
6
7
6 frames
/usr/local/lib/python3.6/dist-packages/transformers/models/pegasus/modeling_pegasus.py in forward(self, input_ids, attention_mask, encoder_hidden_states, encoder_attention_mask, head_mask, encoder_head_mask, past_key_values, inputs_embeds, use_cache, output_attentions, output_hidden_states, return_dict)
938 input_shape = inputs_embeds.size()[:-1]
939 else:
--> 940 raise ValueError("You have to specify either decoder_input_ids or decoder_inputs_embeds")
941
942 # past_key_values_length
ValueError: You have to specify either decoder_input_ids or decoder_inputs_embeds
I have never seen this error before. Any ideas?
torch.jit.save(torch.jit.trace(model, [myTokenBatch.input_ids, myTokenBatch.attention_mask]), "./t5-single.pt")
but it's throwing an error: "You have to specify either decoder_input_ids or decoder_inputs_embeds" . How should I approach this problem? Thanks in advance – Iminourea