(Not sure that it is a bug, but it is too easy to reproduce I think)
I couldn't run python -c 'from transformers import AutoModel', instead getting the error on the titile.
Steps to reproduce the behavior:
$ sudo docker run -it --rm python:3.6 bash# pip install tensorflow==2.0 transformers==2.8.0# python -c 'from transformers import AutoModel'Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'AutoModel'
Initially I got this error with transformers-cli download :
# transformers-cli download t5-large
Traceback (most recent call last):
File "/usr/local/bin/transformers-cli", line 32, in <module>
service.run()
File "/usr/local/lib/python3.6/site-packages/transformers/commands/download.py", line 29, in run
from transformers import AutoModel, AutoTokenizer
ImportError: cannot import name 'AutoModel'
no import error.
transformers version: 2.8.0Also tested on 3.6@Ubuntu 18.04, 3.8@Docker(python:3.8).
The Docker backend is Ubuntu 18.04.
Thank you.
Got the same result with 2.9.0, i.e. with # pip install tensorflow==2.0 transformers==2.9.0
AutoModel is the equivalent of TFAutoModel but for PyTorch model classes. If you don't have pytorch installed this is expected.
Use TFAutoModel instead =)
Thank you!
@julien-c
But there still is a problem with transformers-cli.
Now, people who want to use transformers-cli download are required to install PyTorch even when they use Tensorflow only.
edit:
It could be the problem specific to t5-large. I'll try it later.
Most helpful comment
AutoModelis the equivalent ofTFAutoModelbut for PyTorch model classes. If you don't have pytorch installed this is expected.Use
TFAutoModelinstead =)