DFKI-NLP / fewie

Few-shot named entity recognition
MIT License
11 stars 1 forks source link

Questions about how to make your code work #16

Open kimkyeonghun opened 1 year ago

kimkyeonghun commented 1 year ago

I was looking at your code and had a question, so I opened an issue.

I want to apply this code to a new dataset I created.

However, I saw that only evaluate.py exists. If you have a code like train.py, can you share it with us?

Thank you

leonhardhennig commented 1 year ago

Hi, there is no train.py, because we didn't do any training. Per few-shot batch, there is 'only', depending on the readout you configure, some fitting done. e.g. in src/fewie/evaluation/classifiers/logistic_regression.py we fit a LR function.

kimkyeonghun commented 1 year ago

Thank you for your quick response. I understand the answer well enough.

Looking at the paper, it appears that they used contrastive learning. Do you have any hints on how to use it? Or is it something that is already included in the pre-trained BERT?

leonhardhennig commented 1 year ago

@chen-yuxuan did we include the code for the contrastive learning in the repo?

chen-yuxuan commented 1 year ago

Thank you for your quick response. I understand the answer well enough.

Looking at the paper, it appears that they used contrastive learning. Do you have any hints on how to use it? Or is it something that is already included in the pre-trained BERT?

Hi, @kimkyeonghun and @leonhardhennig Yes, it is included in the contrastive-pre-training branch. I think after checking-out this branch, you can run it in quite the same way as for other encoders, since the configuration files for contrastive-variants are available here: https://github.com/DFKI-NLP/fewie/tree/contrastive-pretraining/config/encoder

Also we don't train for vanilla encoders, and don't train by ourselves for other-task/domain fine-tuned encoders (by just using the existing checkpoints from HF). However, we did train for contrastive learning, and in this case, the training logic is contained in the evaluate.py (calling https://github.com/DFKI-NLP/fewie/blob/68d7f12f5ced214414e231dd08772abfa744e1e8/src/fewie/evaluation/scenarios/few_shot_contrastive_training.py#L24) in this branch.

kimkyeonghun commented 1 year ago

Thank you for your quick and accurate response!