Open wailoktam opened 4 years ago
Are you using a different bert model? I got an error like this when I used a smaller bert model to train on a dataset that was preprocessed using a larger bert model. (I forgot to change the model before preprocessing)
Thanks a lot for getting back to me promptly. This is what I have got in model builder used during training following the pull request for Japanese you suggest.
class Bert(nn.Module):
def __init__(self, large, temp_dir, finetune=False):
super(Bert, self).__init__()
if(large):
self.model = BertModel.from_pretrained('bert-base-multilingual-cased', cache_dir=temp_dir)
else:
self.model = BertModel.from_pretrained('bert-base-uncased', cache_dir=temp_dir)
self.finetune = finetune
This is what I get in data builder used during preprocessing, again following the pull request you suggest:
class BertData():
def __init__(self, args):
self.args = args
self.tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-cased', do_lower_case=True)
self.sep_token = '[SEP]'
self.cls_token = '[CLS]'
self.pad_token = '[PAD]'
self.tgt_bos = '[unused7]'
self.tgt_eos = '[unused1]'
self.tgt_sent_split = '[unused2]'
self.sep_vid = self.tokenizer.vocab[self.sep_token]
self.cls_vid = self.tokenizer.vocab[self.cls_token]
self.pad_vid = self.tokenizer.vocab[self.pad_token]
This line printed when trianing looked suspicious as it indicates it is not the multilingual bert model being used?
[2020-07-03 10:13:37,788 INFO] loading weights file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-pytorch_model.bin from cache at /content/drive/My Drive/PresummJaTemp/aa1ef1aede4482d0dbcd4d52baad8ae300e60902e88fcb0bebdec09afd232066.36ca03ab34a1a5d5fa7bc3d03d55c4fa650fed07220e2eeebc06ce58d0e9a157
Any suggestion would be welcomed. I am completely clueless about what to do, except for reading textbooks teaching pytorch.
I believe your issue might be that you have preprocessed the data using the bert_multilingual, but you are trying to train on bert_base-uncased - It all depends on if you are using the parameter -large true when training. If not then you should change this part of the code:
if(large)
self.model = BertModel.from_pretrained('bert-base-multilingual-cased', cache_dir=temp_dir)
else:
self.model = BertModel.from_pretrained('bert-base-uncased', cache_dir=temp_dir)
To this:
if(large):
self.model = BertModel.from_pretrained('bert-base-multilingual-cased', cache_dir=temp_dir)
else:
self.model = BertModel.from_pretrained('bert-base-multilingual-cased', cache_dir=temp_dir)
Thanks a lot. It works like a charm!
I am new to torch although I have some experience with debugging tensorflow and keras. I wonder how should I start with the following error message:
IndexError Traceback (most recent call last)