Fix bug ORTModelForFeatureExtraction#2267
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 <[email protected]>
echarlaix
left a comment
There was a problem hiding this comment.
Thanks a lot for the fix @Abdennacer-Badaoui !
* Fix bug ORTModelForFeatureExtraction * Update optimum/onnxruntime/modeling_ort.py Co-authored-by: Ilyas Moutawwakil <[email protected]> * 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 <[email protected]>
|
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'sforwardmethod to accept**kwargs, ensuring better compatibility with Hugging Face Transformers' conventions. In particular, it adds proper support for thereturn_dictargument: 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