ImportError: cannot import name 'MODEL_WITH_LM_HEAD_MAPPING' from 'transformers' (C:\Users\
Model I am using (Bert, XLNet ...): GPT2
Language I am using the model on (English, Chinese ...): English
The problem arises when using:
[x] the official example scripts: (give details below)
a necessary package does not exist for import
The tasks I am working on is:
[x] my own task or dataset: (give details below)
I am trying to finetune the GPT2 library to work with recipes
Steps to reproduce the behavior:
LOG:
python run_language_modeling.py
2020-06-01 23:53:43.603759: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
Traceback (most recent call last):
File "run_language_modeling.py", line 29, in <module>
from transformers import (
ImportError: cannot import name 'MODEL_WITH_LM_HEAD_MAPPING' from 'transformers' (C:\Users\<name>\anaconda3\envs\tensorflow\lib\site-packages\transformers\__init__.py)
There should be an error with not receiving variables or no output at all. If you were to insert data it would train an instance of GPT2 and save it to the output directory
transformers version: 2.10.0It would be nice to figure out what the issue is. I am aware that there are 3 questions similar to this, but they all use torch while I am using tensorflow. All of the solutions I have tried (reinstalling tensorflow, reinstalling transformers, updating packages, reformatting code, etc.) have not worked. Thanks.
This might help: #3444
MODEL_WITH_LM_HEAD_MAPPING is a mapping containing all the Pytorch models that have an LM head. Since you don't have PyTorch installed, you can't import them.
With TensorFlow you're probably looking for TF_MODEL_WITH_LM_HEAD_MAPPING.
Please note that the run_language_modeling.py script is currently PyTorch only. A TensorFlow version will be available in the future.
Most helpful comment
MODEL_WITH_LM_HEAD_MAPPINGis a mapping containing all the Pytorch models that have an LM head. Since you don't have PyTorch installed, you can't import them.With TensorFlow you're probably looking for
TF_MODEL_WITH_LM_HEAD_MAPPING.Please note that the
run_language_modeling.pyscript is currently PyTorch only. A TensorFlow version will be available in the future.