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

Add OnnxConfig for ConvBERT #16859

Merged
merged 5 commits into from
Apr 22, 2022
Merged

Conversation

chainyo
Copy link
Contributor

@chainyo chainyo commented Apr 20, 2022

What does this PR do?

I have added OnnxConfig for ConvBERT model. I have checked all features available (which are the same as DistilBERT), so the features list seems to be good.

Who can review?

Models:

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 20, 2022

The documentation is not available anymore as the PR was closed or merged.

@chainyo
Copy link
Contributor Author

chainyo commented Apr 20, 2022

The conversion is working as demonstrated by the fact I successfully converted a base model and uploaded it on the hub.

Check the model here

Here is the command I have used:

$ python -m transformers.onnx --model=mrm8488/convbert-base-spanish --feature=default onnx/

> Validating ONNX model...
> 	-[✓] ONNX model output names match reference model ({'last_hidden_state'})
> 	- Validating ONNX Model output "last_hidden_state":
>		-[✓] (2, 8, 768) matches (2, 8, 768)
>		-[✓] all values close (atol: 1e-05)
> All good, model saved at: onnx/model.onnx

@LysandreJik LysandreJik requested a review from lewtun April 20, 2022 21:29
Copy link
Member

@lewtun lewtun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this very clean PR @chainyo! Apart from a small change about adding a # Copied from comment, this LGTM 🚀

Did you also check that the slow tests pass with

RUN_SLOW=1 pytest tests/onnx/test_onnx_v2.py -k "convbert"

Gently pinging @sgugger for final approval

@lewtun
Copy link
Member

lewtun commented Apr 21, 2022

The conversion is working as demonstrated by the fact I successfully converted a base model and uploaded it on the hub.

Check the model here

Awesome job on pushing this to the Hub! We have a PR in optimum coming soon that will allow you to also download these checkpoints directly as ONNX model objects: huggingface/optimum#113

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR! LGTM with @lewtun 's nit.

@chainyo
Copy link
Contributor Author

chainyo commented Apr 21, 2022

Awesome job on pushing this to the Hub! We have a PR in optimum coming soon that will allow you to also download these checkpoints directly as ONNX model objects: huggingface/optimum#113

I dreamed about this and wanted to give it a shot if I had time (spoiler: not in the past months) but someone did it!!!

Btw the tests seem to pass!

@chainyo
Copy link
Contributor Author

chainyo commented Apr 22, 2022

I saw on another onnx config contribution that I could add the model to onnx tests, is it mandatory ?
Check : #16887

@lewtun
Copy link
Member

lewtun commented Apr 22, 2022

I saw on another onnx config contribution that I could add the model to onnx tests, is it mandatory ? Check : #16887

Ah yes, well spotted! You can pick one of the checkpoints from here and add it to the test: https://huggingface.co/models?search=convbert

This will ensure this export is tested as part of our daily CI with the slow tests :)

@lewtun
Copy link
Member

lewtun commented Apr 22, 2022

Thanks for including the test case - looks great!

@lewtun lewtun merged commit ec81c11 into huggingface:main Apr 22, 2022
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
* add OnnxConfig for ConvBert

Co-authored-by: ChainYo <t.chaigneau.tc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants