简体   繁体   中英

Transformer: cannot import name 'AutoModelWithLMHead' from 'transformers'

I was referring to this answer from stackoverflow but I can't get any leads regarding my problem: [https://stackoverflow.com/questions/63141267/importerror-cannot-import-name-automodelwithlmhead-from-transformers][1]

This is the code that I ran:

import transformers
from transformers import AutoModelWithLMHead

Results:

cannot import name 'AutoModelWithLMHead' from 'transformers' (/Users/xev/opt/anaconda3/lib/python3.7/site-packages/transformers/__init__.py)

My transformer version is '3.0.2'. My import for AutoTokenizer is fine.

Would appreciate if there's anyone who can help regarding the Transformers package! [1]: ImportError: cannot import name 'AutoModelWithLMHead' from 'transformers'

请尝试,

from transformers.modeling_auto import AutoModelWithLMHead

just make sure you installed the transformers using its official git link

pip install git+https://github.com/huggingface/transformers

and not by using pypi

pip install transformers

coz there are few sub-libraries such as TFLayoutLMForSequenceClassification missing in pypi transformers version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM