ImportError: cannot import name 'TFTrainer' from 'transformers' on Colab

223 Views Asked by At

so confused why i couldn't import TFTraniner in colab

I've tried : !pip install TFTranier !pip --upgrade transformers and reinstall transformers

but still failed to import TFTranier in colab like in the screenshot Image

I was trying to follow the code from other people,they successfully import TFTranier from transformersOrigianl code

1

There are 1 best solutions below

2
Saladin On

TFTrainer is a separate package that your are trying to import through transformers.

Here an example of how you can import from TFTrainer:

from tftrainer import TrainArgument, Trainer

https://github.com/Nam-SW/TFTrainer

Edit

tftrainer is no longer supported in latest version of transfomers, try using an older version.

I tried one and it worked:

!pip install transformers==4.18.0

Now, import TFTrainer like this:

from transformers.trainer_tf import TFTrainer