KeyError: in convert_tokens_to_ids()
See original GitHub issueIn BertTokenizer’s, convert_tokens_to_ids function gives KeyError. So, I suggest to modify the for loop in the function as follows.
for token in tokens:
ids.append(self.vocab.get(token, self.vocab['[UNK]']))
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Python KeyError Exceptions and How to Handle Them
In this tutorial, you'll learn how to handle Python KeyError exceptions. They are often caused by a bad key lookup in a dictionary,...
Read more >How to Fix KeyError Exceptions in Python - Rollbar
The Python KeyError is an exception that occurs when an attempt is made to access an item in a dictionary that does not...
Read more >I'm getting Key error in python - Stack Overflow
A KeyError generally means the key doesn't exist. So, are you sure the path key exists? From the official python docs: exception KeyError....
Read more >How to fix Python KeyError Exceptions in simple steps?
The KeyError is raised when the item 'Eraser' is being accessed which is not present in prices. Whenever an exception is raised in...
Read more >What is KeyError in Python? Dictionary and Handling Them
This article will provide you with a detailed and comprehensive knowledge of how to resolve KeyError in Python in Dictionary.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@congjianluo you should not tokenize the sentence your self but use Bert tokenizer. Please follow the usage example in the readme. In your case:
@wasiahmad ok then I’m closing this issue. Feel free to re-open it if you have a (reproductible) example of such issue.