megagonlabs / ditto

Code for the paper "Deep Entity Matching with Pre-trained Language Models"
Apache License 2.0
259 stars 89 forks source link

ImportError: cannot import name 'LongformerModel' from 'transformers' (transformers=2.8) #11

Open y0uCeF opened 3 years ago

y0uCeF commented 3 years ago

I had an issue running the code after installing the required transformers==2.8 and sentencepiece==0.1.85. I got the error:

Traceback (most recent call last):
  File "train_ditto.py", line 90, in <module>
    from snippext.mixda import initialize_and_train
  File "Snippext_public/snippext/mixda.py", line 13, in <module>
    from .model import MultiTaskNet
  File "Snippext_public/snippext/model.py", line 3, in <module>
    from transformers import BertModel, AlbertModel, DistilBertModel, RobertaModel, XLNetModel, LongformerModel
ImportError: cannot import name 'LongformerModel' from 'transformers' (/home/youcef/.conda/envs/py37/lib/python3.7/site-packages/transformers/__init__.py)

I fixed it by installing transformers==3.1 instead, which introduced LongformerModel.

I recommend the requirements should be updated accordingly. https://github.com/megagonlabs/ditto/blob/6dcf10abf7a1ce208e35a3dad3c9eadb7a5ff742/requirements.txt#L11