I am trying to train a Sentence Transformers model as explained here:
my_dataset = Dataset.from_pandas(df)
n_samples = my_dataset.num_rows
train_examples = [InputExample(texts=my_dataset[i]['text'], label=my_dataset[i]['labels']) for i in range(n_samples)]
my_loader = DataLoader(train_examples, batch_size=BS, shuffle=True)
model.fit(train_objectives=[(my_loader, losses.BatchHardTripletLoss(model=model))], epochs=3)
When I run the above code, I get this error:
IndexError: list index out of range
I have checked that the text and label field of the dataset have the same number of elements.
I suppose that the error concerns InputExample
, but I am not sure about it.