plkmo / BERT-Relation-Extraction

PyTorch implementation for "Matching the Blanks: Distributional Similarity for Relation Learning" paper
Apache License 2.0
573 stars 133 forks source link

About fine tuning pre-trained MTB model #11

Closed kemalaraz closed 4 years ago

kemalaraz commented 4 years ago

Currently I am pre-training the bert model for MTB but how can I use that pre-trained model for fine-tuning for SemEval2010 Task 8? I saw that you gave information about how to fine-tune the actual bert model for SemEval2010 Task 8 however I couldn't find any information about how to fine tuned pre-trained MTB model? In addition to that after fine-tuning on SemEval2010 Task 8 should I do NER first or the model does that itself?

Thanks

plkmo commented 4 years ago

To use the pre-trained MTB model for fine-tuning for SemEval, set use_pretrained_blanks=1 in main_task.py.

For inference after fine-tuning on SemEval, please see inference section under readme. I did not provide a script for this, but rather as a python API package. For eg. you can write your own script in the project directory and import the package like this: from src.tasks.infer import infer_from_trained inferer = infer_from_trained(args, detect_entities=False) test = "The surprise [E1]visit[/E1] caused a [E2]frenzy[/E2] on the already chaotic trading floor."
inferer.infer_sentence(test, detect_entities=False)
If you want it to automatically detect entities using Spacy, set detect_entities=True