Training a relation extraction component

hi @stella,

You are getting this because there are no relations predicted in that example. The problem is likely you're not passing any entities with the example.

The original code Sofie provided only trained a relation component, not a ner component. Sofie stated in her video, her config file only trains the relations component, not the ner component (please watch this part: 19:12)

That is, in the default config file, it only has the tok2vec (or transformer) and the relations_extraction component:

pipeline = ["tok2vec", "relation_extractor"]

Since it doesn't have a ner component, it won't automatically train the ner component. But I think you previously created a separate ner which is covered in this spaCy GitHub issue:

if you want to train the ner and the relation_extraction component together, you'll need to set annotating_components = ["ner"] in your config. This will make the NER predictions available to the downstream relation extraction component, so it can use them to predict relations. Alternatively, you could train this in two steps, with two configs: 1 focusing only on the NER, and the second sourcing the trained NER model and then train the relation extraction.

If you want to train with both, make sure to add in the ner components too (not just add annotating_components = ["ner"]).

Sofie mentioned in an older post how to approach this:

But as she mentioned, a 2nd option is doing a two-step training with two configs: first for ner and second for relations (just be sure to source the trained NER model to train the relation extraction. This can be a 2nd option if you can't get the single config running.

Last, have you spent some time looking at the evaluate.py script?

You'll find how to predict relations when you know the entities.

Hope this helps!