guillaume-be / rust-bert

Rust native ready-to-use NLP pipelines and transformer-based models (BERT, DistilBERT, GPT2,...)
https://docs.rs/crate/rust-bert
Apache License 2.0
2.67k stars 216 forks source link

Translation API should allow for multiple source/target languages #394

Open mrjackbo opened 1 year ago

mrjackbo commented 1 year ago

Hi, thanks so much for the great project!

At the moment TranslationModel::translate takes a slice of texts to translate, a source language and a destination language and produces a slice of translated texts.

For models like m2m or nnlb, it would be convenient if there were an additional method, perhaps translate_multi_lang, that takes a slice of texts to translate, a slice of source languages and possibly a slice of destination languages. This way one could make use of the batched inference but for multiple source/destination pairs.

At least for multiple source languages, this would be very easy to implement.

guillaume-be commented 1 year ago

Hello @mrjackbo ,

Apologies for getting back to you with a delay. This may indeed be useful - would you like to draft a pull request? If not I will try to have a look at it this week-end.