Train a relation extraction model with spaCy #10930
-
Hi! :) I'm working on Relation Extraction, specifically the extraction of drug-drug interactions from text documents. Do I need a NER model to identify the drugs (my entities) in the first place? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes, the relex component uses existing entity annotations to find potential relations, so you need something that sets entities. Usually that would be an NER model, though it could be rule-based (an EntityRuler).
You need to make a |
Beta Was this translation helpful? Give feedback.
-
Is there a way to just train the model for the selected relations or entities that are included in the training set? Or do we always have to train it for all the entities and relations? For example if I annotate documents for category x and y and relationship i and j can I then just train the model for relationship i and check the accuracy just for i? Or can I train the model for i and j and then check the accuracy for each category separately? |
Beta Was this translation helpful? Give feedback.
Yes, the relex component uses existing entity annotations to find potential relations, so you need something that sets entities. Usually that would be an NER model, though it could be rule-based (an EntityRuler).
You need to make a
.spacy
file that has Docs that look like you want your output to look - they should have the right entities and the right relation data in thedoc._.rel
attribute. The preprocessing script in the demo project builds a file like that (it's theDocBin
). In this datatoken_start
andtoken_end
are the token indices of the te…