Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why exported gpt2.onnx has 1 inputs? #456

Open
shp776 opened this issue Aug 10, 2021 · 1 comment
Open

Why exported gpt2.onnx has 1 inputs? #456

shp776 opened this issue Aug 10, 2021 · 1 comment
Labels

Comments

@shp776
Copy link

shp776 commented Aug 10, 2021

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.

@wenbingl
Copy link
Member

check there for for a complete GPT-2 model inference example
https://github.com/microsoft/onnxruntime-extensions/blob/main/tutorials/gpt2bs.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants