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

Issue with the BertTokenizer - add_tokens() method is missing #61

Open
andreabac3 opened this issue Mar 13, 2021 · 0 comments
Open

Issue with the BertTokenizer - add_tokens() method is missing #61

andreabac3 opened this issue Mar 13, 2021 · 0 comments

Comments

@andreabac3
Copy link

I have a need similar of @LittlePea13 (see issue #58 ) on the SQUAD task. I want add some tokens at training time in the vocabulary of the language model. But the BertTokenizer (SpanBertcode/pytorch_pretrained_bert/tokenization.py) don't load the following file 'added_tokens.json' and the class has no method to load it.

A naive solution is move from:

from pytorch_pretrained_bert.tokenization import (BasicTokenizer, BertTokenizer, whitespace_tokenize)
tokenizer = BertTokenizer.from_pretrained(
        args.model, do_lower_case=args.do_lower_case)
# to
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(
        args.model, do_lower_case=args.do_lower_case)

It is equal?
In this way the method from_pretrained() load correctly my custom tokenizer and the AutoTokenizer has the method add_tokens()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant