psunlpgroup / CONTaiNER

Code for ACL 2022 paper "CONTaiNER: Few-Shot Named Entity Recognition via Contrastive Learning"
MIT License
110 stars 17 forks source link

I'm not sure but may I ask some code problems #2

Closed MingHong1019 closed 2 years ago

MingHong1019 commented 2 years ago

in line 129, 130,131, 115 of file utils.py

  1. for line 115, assert a tuple will return none value and will not report error.

  2. in line 129, 130,131, 115, the filtered_embedding/repeated_output_embeddings are repeted by 'len(output_embedding_mu)/filtered_instances_nos' times. So these tensors can not be reshape as (filtered_instances_nos, filtered_instances_nos), I change that to (filtered_instances_nos, -1) and code works.

I'm not realy sure about these problems, could you please help me for that?

https://github.com/psunlpgroup/CONTaiNER/blob/main/src/utils.py#L129

Sarathismg commented 2 years ago

Hi, thanks a lot for pointing out the issues. This is still a very early version of the code and will be cleaned up more in the coming days.

  1. You are correct about that. This line shouldn't exist in the first place as the checking is done in the later stages anyway (as you mentioned in issue 2).
  2. With (filtered_instances_nos, -1) as the index, anything will work. Reshaping into (filtered_instances_nos, filtered_instances_nos) works here as an extra step of dimension checking. I have checked it and it does not seem to cause that issue with me. Can you please verify if you have --consider_mutual_O argument enabled while calling container.py? If that is not enabled it can cause this error. For now please enable this. In future this will be enabled by default.
MingHong1019 commented 2 years ago

Thanks a lot for suggestion "--consider_mutual_O", and I have add that argument and it works. By the way, the paper said that you have fine-tuning in the target domain using the label like ORG and LOCATION in Ontonotes dataset. However, I couldn't find any fine-tuning step during testing on the FewNerd dataset in the code.

Sarathismg commented 2 years ago

If you carefully follow the code at container.py source file, you'll notice this line. Whenever do_finetune_support_only is enabled, it will finetune the model with the support set.