Closed VictorCallejas closed 4 years ago
Thanks for your question. Please try to provide a minimal reproducing example so that we can identify the issue better. It is unclear whether this error is caused by our code. From my personal experience, this type of error usually appears when you try to input a invalid index to a tensor, for example, the embedding.
Okay, so some ids from the text tokenizer are greater the the model embedding.
But I am using the same tokenizer and function
from pytorch_pretrained_bert import BertTokenizer
def bert_tokenize(tokenizer, text):
ids = []
for word in text.strip().split():
ws = tokenizer.tokenize(word)
if not ws:
# some special char
continue
ids.extend(tokenizer.convert_tokens_to_ids(ws))
return ids
The solution is to modify the vocab size in the config file
For the record, if you have an RuntimeError: CUDA error: device-side assert triggered, it's good to execute the code with CUDA_LAUNCH_BLOCKING=1 python ....
By the way, thanks for making public these incredible models @ChenRocks !
@VictorCallejas which tokenizer did you use? Our vocab size matches that of bert-base-cased
and bert-large-cased
(the 2 should be identical). If you do not use one of them, the token ids won't be correctly matching the embeddings in UNITER pretrained models.
My bad, I was using 'bert-base-uncased'
!pip install pytorch_pretrained_bert
from pytorch_pretrained_bert import BertTokenizer
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
def bert_tokenize(tokenizer, text):
ids = []
for word in text.strip().split():
ws = tokenizer.tokenize(word)
if not ws:
# some special char
continue
ids.extend(tokenizer.convert_tokens_to_ids(ws))
return ids
Thank you very much @ChenRocks
Hi everyone,
I am creating a UNITER model for a classification task, but after a few steps of training it launches the error
Have you encounter this error before?
If I try to make a forward pass before training the outputs are correct
The model