tonytan48 / KD-DocRE

Implementation of Document-level Relation Extraction with Knowledge Distillation and Adaptive Focal Loss
110 stars 20 forks source link

ModuleNotFoundError: No module named 'multihead_attention' #6

Closed moh-yani closed 2 years ago

moh-yani commented 2 years ago

Dear Tony,

I found a new error when I run bash scripts/batch_roberta.sh: ModuleNotFoundError: No module named 'multihead_attention'

I changed from multihead_attention import MultiheadAttention to from torch_multi_head_attention import MultiHeadAttention

the error message above does not appear again but, a new error is found: File "train.py", line 398, in main │ model = DocREModel_KD(args, config, model, num_labels=args.num_labels) │ File "/home/yani/disertasi/kd-docre/model.py", line 93, in init │ self.multihead_attn = MultiHeadAttention(config.hidden_size, 16, kdim=conf│ ig.hidden_size, vdim=config.hidden_size) │ TypeError: init() got an unexpected keyword argument 'kdim'

Could I get any insights for this?

Best regards,

Mohammad

WatsonWangZh commented 2 years ago

the module can be found in fairseq repository: https://github.com/facebookresearch/fairseq/blob/main/fairseq/modules/multihead_attention.py

tonytan48 commented 2 years ago

Hi Mohammad,

Sorry for the late reply. I was working on some other work related to DocRE. This part was not used in the final experiments and I only used them for testing. Thanks for your comment.