I think you should refactor your code to read the docs file in the __init__ function and then grab from that variable instead of reading the file in the __getitem__ method.  For one, with negative sampling, you are doing 4x the number of reads because you are re-reading data then.  Also, you can check to make sure that every line has a tab character, which doesn’t seem to be the case here because the list created by self.f.readline().split is not a length of two.  It could be that the file gets locked during read so when you have too many workers reading the same file then it tries to read the file, but it’s locked and returns nothing.