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 vocabulary gives sequence length warning #1533

Closed
callenilsson opened this issue Oct 16, 2019 · 4 comments
Closed

Add vocabulary gives sequence length warning #1533

callenilsson opened this issue Oct 16, 2019 · 4 comments
Labels

Comments

@callenilsson
Copy link

@callenilsson callenilsson commented Oct 16, 2019

Questions & Help

I'm trying to add extra vocabulary to RoBERTa using the tokenizer.add_tokens() function. However, when training I get the following warning message:

WARNING - transformers.tokenization_utils - Token indices sequence length is longer than the specified maximum sequence length for this model (751 > 512). Running this sequence through the model will result in indexing errors

What's going on here? Should I be concerned about this or should I ignore it? The function that calls this error is tokenizer.convert_tokens_to_ids().

@LysandreJik
Copy link
Member

@LysandreJik LysandreJik commented Oct 16, 2019

Hi, this warning means that the sequence you have encoded is longer than the maximum sequence length the model can handle. It isn't related to the tokens you have added.

RoBERTa can only handle sequences of a maximum of 512 tokens, so you should make sure you only pass sequences of a max length of 512 or else it will crash. You can truncate your sequence so that it fits, or you can use another model that can accept longer sequences.

@callenilsson
Copy link
Author

@callenilsson callenilsson commented Oct 17, 2019

Hi, this warning means that the sequence you have encoded is longer than the maximum sequence length the model can handle. It isn't related to the tokens you have added.

RoBERTa can only handle sequences of a maximum of 512 tokens, so you should make sure you only pass sequences of a max length of 512 or else it will crash. You can truncate your sequence so that it fits, or you can use another model that can accept longer sequences.

Thanks! My bad, completely misunderstood the warning, all fixed. However, my problem now seems to be that the function tokenizer.encode_plus() used in glue_convert_examples_to_features() gets exponentially slower the more words I add to the tokenizer's vocabulary.

For example, starting with a tokenizer vocabulary size of 50265, the tokenizer.encode_plus() takes ~0.00048 sec per call. If I add 1200 more words, giving me a tokenizer vocabulary size of 51465, the tokenizer.encode_plus() now takes ~0.05729 sec per call, which is ~120x slower. It gets even worse the more words I add, causing me waiting times up to 1h just to pre-process the dataset. What causes this exponential (or extreme linear) growth to happen? Is it possible to optimize it?

@iedmrc
Copy link
Contributor

@iedmrc iedmrc commented Dec 4, 2019

Hi, this warning means that the sequence you have encoded is longer than the maximum sequence length the model can handle. It isn't related to the tokens you have added.
RoBERTa can only handle sequences of a maximum of 512 tokens, so you should make sure you only pass sequences of a max length of 512 or else it will crash. You can truncate your sequence so that it fits, or you can use another model that can accept longer sequences.

Thanks! My bad, completely misunderstood the warning, all fixed. However, my problem now seems to be that the function tokenizer.encode_plus() used in glue_convert_examples_to_features() gets exponentially slower the more words I add to the tokenizer's vocabulary.

For example, starting with a tokenizer vocabulary size of 50265, the tokenizer.encode_plus() takes ~0.00048 sec per call. If I add 1200 more words, giving me a tokenizer vocabulary size of 51465, the tokenizer.encode_plus() now takes ~0.05729 sec per call, which is ~120x slower. It gets even worse the more words I add, causing me waiting times up to 1h just to pre-process the dataset. What causes this exponential (or extreme linear) growth to happen? Is it possible to optimize it?

Please see #1830 , #1621 and #1881

@stale
Copy link

@stale stale bot commented Feb 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Feb 2, 2020
@stale stale bot closed this as completed Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants