Closed itssimon closed 3 years ago
Hey @itssimon
From a quick look at your code, it seems that the fairseq model is on GPU, but the transformers model is on CPU, which could explain the huge speed difference. Could you try running it on GPU ?
Oh dear, how embarassing. That's it! Thanks!
π Faster batch translation with FSMT model
Currently, generating translations for multiple inputs at once is very slow using Transformers'
FSMTForConditionalGeneration
implementation. In fact it's about 10x slower than using the original FairSeq library. Can we speed this up by improving the implementation, potentially leaning on the original FairSeq approach?Motivation
I'm using FairSeq models for back translation as a way to augment text data. I've implemented this using the original FairSeq model (from PyTorch Hub) and Transformers.
FairSeq implementation
Transformers implementation
Both of these functions generate comparable results, but using Transformers it takes about 10x longer.
In my use case I need back translations for hundreds of thousands of text snippets, which unfortunately makes the Transformers implementation unfeasible. I'd love to use Transformers though, as it is much easier to install and deploy (as we use Transformers for text classification anyway).