AttributeError: 'TrainOutput' object has no attribute 'metrics' when finetune custom dataset

I’m try to finetune Bert on sst2 dataset by using (
I randomly pick 1% train data and 10 validation data from sst2 original dataset, and build them as csv. file with label and sentence columns.

Here is my finetune setting:

But there is an error occurred:
Traceback (most recent call last):
File “”, line 432, in
File “”, line 356, in main
metrics = train_result.metrics
AttributeError: ‘TrainOutput’ object has no attribute ‘metrics’

I run all these scripts on colab pro


Could you post your transformers version. Also to run the examples you should install transformers from source.

Thanks for your reply!!
My transformers is the newest version 4.1.1.
And I think I figure out why the error occured, because my label column index is 0 and sentence column is 1, the default setting is that the label column index should be 1 and sentence column index should be 0.

The newest version can not be enough, you need a source install. In this case, the metrics have been added to the TrainiOutput very recently.