onnx / onnx/models

Why exported gpt2.onnx has 1 inputs?

Open
#456 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Ask a Question

Question

I have two questions.

  1. https://github.com/onnx/models/tree/master/text/machine_comprehension/gpt-2
    The onnx file extracted from the link above appears to have only one input which is input_ids. Therefore, position_ids and attention_mask inputs seem to be not used. Is there any problem with this one_input_onnx_file performing text generation? I am asking you because the onnx_file used in the link below has 15 inputs.

https://github.com/microsoft/onnxruntime/blob/master/onnxruntime/python/tools/transformers/notebooks/Inference_GPT2_with_OnnxRuntime_on_CPU.ipynb

  1. You mentioned text generation code as below capture.
    image

Using the code you provided, text generation worked properly up to one sentence, but continuous sentence generation did not work properly. I wonder if this is because of the structure of the onnx model we used that does not handle past_inputs.

Additionally, the above code differs from the original sample.py code. Only dealing with outputs[0] and torch.multinomial(sampling) and top_k algorithms are missing. Is this due to the onnx model structure that considers only one input (not considering past_state) ?

Further information

Relevant Area (e.g. model usage, backend, best practices, pre-/post- processing, converters):

Is this issue related to a specific model?
Model name (e.g. mnist):
Model opset (e.g. 7):

Notes

Any additional information, code snippets.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the model in text/machine_comprehension/gpt-2 with the ONNX file used by Inference_GPT2_with_OnnxRuntime_on_CPU.ipynb, including their inputs and outputs. Check the referenced generation code and sample.py; a useful resolution would explain whether the exported model supports past inputs and why continuous generation differs.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook
Domain
machine-learning
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.