# MBart50Tokenizer vs XLMRobertaTokenizer

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmbart50tokenizer-vs-xlmrobertatokenizer%2F8498%3E%5C
**Category:** 🤗Tokenizers\
**Created:** [July 19, 2021, 4:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmbart50tokenizer-vs-xlmrobertatokenizer%2F8498 "2021-07-19T16:15:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoshi](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yoshi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fyoshi)%5C
**Post date:** [July 19, 2021, 4:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmbart50tokenizer-vs-xlmrobertatokenizer%2F8498%2F1 "2021-07-19T16:15:31Z")

</div>

Hello,

I am currently working on the [MBART50 many-to-one](https://huggingface.co/facebook/mbart-large-50-many-to-one-mmt) model for translation. I noticed that the tokenizer took a long time to encode the input when the length of the sequence became relatively important (_cf attached picture_). So, instead of using the **MBart50TokenizerFast** I used to use the **XLMRobertaTokenizerFast**.

Actually, both are based on _sentencepiece.bpe.model_ and have almost the same vocabulary. Using XLMRobertaTokenizerFast, I got practically the same translation as if I had used MBart50TokenizerFast BUT with a much shorter execution time. **Does anyone have any idea why there is so much difference in execution time between these two tokenizers?** (One can find the evolution of the execution time - _encoding time_ - depending on the input-string length of the two tokenizers in attached picture)

Thank you !

* * *

Code used :  
`mbart_tokenizer = MBart50TokenizerFast.from_pretrained("facebook/mbart-large-50-many-to-one-mmt")`  
`xlm_tokenizer = XLMRobertaTokenizerFast.from_pretrained("xlm-roberta-base")`

`mbart_token = mbart_tokenizer(input, return_tensors='pt')`  
`xlm_token = xlm_tokenizer(input, return_tensors='pt')`

![téléchargement (1)](https://us1.discourse-cdn.com/hellohellohello/original/2X/5/5ab2147b20dc2a9c863fc96b22514a4544c071f3.png)
