Feature request: m2m100_418M support on onnx
Author: Jourdelune
Pull request: no

# 🚀 Feature request

Hi, it would be great if onnx could support the facebook M2M100 418M multilingual translation model! 

## Motivation

I would like to run m2m100 with reduced translation time on cpu. For this I discovered onnx which reduces the translation time up to 3 times (perfect).So I ran this command I found on the hugging face doc that I adapted for M2M100: 
`python -m transformers.onnx --model=facebook/m2m100_418M m2m100.oonx` 

however it returned this error:

`task='sequence-classification')}} are supported. If you want to support (m2m_100) please propose a PR or open up an issue.`

Only I don't have the skills to post a PR (I'm a total beginner in this field, not even a professional, I've been looking into offline translation to avoid google translation).

So if someone could make onnx support m2m100 418M that would be great!

Finally I think that it would not only benefit me because this model is really great (ratio performance/quality translation is really not bad) and to be able to run it faster would be extremely convenient for the 50 000 people who download this model every month.

## Your contribution

I want to try to contribute but I really don't have the skills to do so.

Comments:
Gently pinging @michaelbenayoun @lewtun :)

Hi, should I ping them? or did you.


Hey @Jourdelune thanks for the feature request - I agree that M2M100 is a great model to support for ONNX :) 

Just so you know, exporting the model will only be the first step. In order to generate the translations you'll have to implement your own `generate()` function with e.g. beam search. We have plans in our `optimum` [library](https://github.com/huggingface/optimum) to support this, but you might have to wait a bit until that feature is available.

In the meantime, I'm happy to work on the ONNX export of M2M100!

Thank you for accepting the request features!
I can wait as long as it takes :D

(I have to close the issue?).

Hey @Jourdelune no need to close the issue - we close them when the pull request is merged (and you'll see a link back to this issue when it's being reviewed) :)

okay, thanks!

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.

Re-opening since @michaelbenayoun is currently working on this :)

ah ah yes, thanks for doing it :D

Hey @lewtun and @michaelbenayoun, I am also interested in exporting M2M100 to onnx. Is there anything I can do to support you? I am also working on exporting `BartForConditionalGeneration`, and the task here is quite similar as well. Once done, I would love to write a blog post about it (you can host it in your blog if you feel like it), as this is a recurring and hot problem. Thank you for your consideration!

Hey @jbesomi thanks for the offer! 

@michaelbenayoun has a PR open [here](https://github.com/huggingface/transformers/pull/15193) for the export, but ran into an issue with exporting the large variant of M2M100. If Michael agrees, one idea would be to create a new branch off [`michaelbenayoun:m2m_100_onnx`](https://github.com/michaelbenayoun/transformers/tree/m2m_100_onnx) and see if you resolve it. Then you could open a PR from your new branch into his, and we could proceed from there.

I think the remaining issue is very very minor, I just need to take the time to solve it. 

Thanks to all those who work for the support of onnx! [jbesomi](https://github.com/jbesomi) I would love to be able to read the blog post which I think would be very useful for many people.

Yes @jbesomi we would be very happy to host your blog post on https://huggingface.co/blog 😍 ! I also agree that text generation with ONNX models is a popular topic that would get a lot of traction in the community

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

Closed by #15193