BERT-pytorch icon indicating copy to clipboard operation
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

Open Emir-Liu opened this issue 4 years ago • 0 comments

    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]
        ...

Emir-Liu avatar Dec 07 '20 05:12 Emir-Liu