Based on the error message it seems that the torchtext.data.Dataset is using a pandas.DataFrame internally and tries to index it directly with an integer, which creates the error (if I’m not mistaken, .iloc should be used instead). You could try to pass the data as a tensor to the dataset instead.