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
[ORT] Filter out invalid inputs in ORTModelForXXX forward pass #225
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
I am not sure that we should add an additional check on each forward pass if the input keys are the same then the one the model expects. |
When the tokenizers return |
In the implementation of DeBERTa there exists a control flow to decide whether the embedding will be instantiated, in the case of |
@philschmid I agree with the fact that we shall not add it in the ORTModel if it introduces any impact on the latency, all in all, the case of DeBERTa is a very edge case. But maybe we can add a tool to help users clean their inputs somewhere else. |
How is transformers and regular pipeline currently handling this situation? Is there a way to commit the |
I don't think that the pipeline in transformers handles this case, as |
Maybe adjusting/configuring the tokenizer to output |
It makes sense to me! Though the case is a little tricky for users, you are right that it is hacky to introduce it into ORTModel which has a bad impact on the speed. And for the configuration of the tokenizer for the inference,
tokenizer = {processor_class}.from_pretrained("{checkpoint}")
model = {model_class}.from_pretrained("{checkpoint}")
-inputs = tokenizer("My name is Philipp and I live in Germany.", return_tensors="pt")
+inputs = tokenizer("My name is Philipp and I live in Germany.", return_tensors="pt", return_token_type_ids=False)
outputs = model(**inputs)
In this case, as users can't configure Possible solution: |
I think you can open an issue with explaining the situation for DeBERTa and the solution you propose in transformers to start the conversation about making the changes/ what changes would be needed. |
Issue opened in transformers to continue the discussion. Thanks @philschmid! |
Close as this should be a work in transformers. |
Context
TL;DR
Transformers #17617
Long story to tell...
For DeBERTa model, the tokenizer gives out
token_type_ids
by default. However, the exported IR might not containtoken_type_ids
(eg. the case whenconfig.type_vocab_size=0
if exported bytransformers.onnx.export
). In this situation:Considering the user experience, I think that we shall add this filter directly in the ORTModelForXXX.
What does this PR do?
Fixes #207