Skip to content
Advertisement

ValueError: You have to specify either decoder_input_ids or decoder_inputs_embeds

Trying to convert a question-generation t5 model to torchscript model, while doing that Running into this error

ValueError: You have to specify either decoder_input_ids or decoder_inputs_embeds

here’s the code that I ran on colab.

JavaScript

got this error

JavaScript

how to resolve this issue? or is there a better way for converting the t5 model to torchscript.

thank you.

Advertisement

Answer

Update: refer to this answer and if you are exporting t5 to onnx, it can be done easily using the fastT5 library.

I figured out what was causing the issue. Since the above model is sequential, it has both an encoder and a decoder. We need to pass the features into the encoder and labels (targets) into the decoder.

JavaScript

the decoder_input_ids is tokenized ids of the question (here the question is a label).

Even though the torchscript model is created, it does not have the generate() method as the huggingface’ t5 do.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement