-
Notifications
You must be signed in to change notification settings - Fork 574
Fix bug ORTModelForFeatureExtraction #2267
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
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Co-authored-by: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the fix @Abdennacer-Badaoui !
* Fix bug ORTModelForFeatureExtraction * Update optimum/onnxruntime/modeling_ort.py Co-authored-by: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com> * Update optimum/onnxruntime/modeling_ort.py * return_dict support for ORTModelForxxx * Add _warn_on_unhandled_inputs helper method to ORTModel * Add test for the return_dict feature * fix style --------- Co-authored-by: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com>
Is this really fixing the underlying issue? With this PR, native Python dicts are returned. However, transformers uses ModelOutput, or? At least for me I have this issue now: When using a sentence-transformers ONNX model, inference fails at this point: https://github.com/UKPLab/sentence-transformers/blob/master/sentence_transformers/models/Transformer.py#L449-L450
|
oh wow ! so transformers doesn't return a dict when return_dict is True, and returns a tuple when it's False 😵 |
What does this PR do?
This PR updates the
ORTModelForFeatureExtraction
'sforward
method to accept**kwargs
, ensuring better compatibility with Hugging Face Transformers' conventions. In particular, it adds proper support for thereturn_dict
argument: when explicitly passed, the output is returned as a plain dictionary instead of being wrapped in aModelOutput
. Additionally, any unused keyword arguments are logged with a warning to help users identify unsupported inputs while maintaining backward compatibility.Fixes issue : #2266