BERT-pytorch
BERT-pytorch copied to clipboard
In Next Sentence Prediction task,the original code may choose the same line when you try to use the negative sample
def get_random_line(self):
...
return self.lines[random.randrange(len(self.lines))][1]
...
it should be changed to the following:
def get_random_line(self,index):
...
tmp = random.randrange(len(self.lines))
while(tmp == index):
tmp = random.randrange(len(self.lines))
return self.lines[random.randrange(len(self.lines))][1]
...