Relation Extraction with a different NE component

Hi everybody,
I want to use the relation extraction component you have published on Github (projects/tutorials/rel_component at v3 · explosion/projects · GitHub) with my custom NE component.
Here is the pipeline:

  1. Annotate documents in Prodigy with entities and relations (Done)
  2. Train my own NER component on the annotated documents and store it(Done)
  3. Train the relation extractor you made available in Github on the same annotated documents and store it (Done)
  4. Take a new text document and annotate it with my NE model at 2., and store it as a .spacy document (Done)
  5. Use the ".spacy" document annotated with entities at 4., and pass it to the relation extractor model at 3.
    I can't figure out how to solve point 5. Please, let me know if you have any ideas.

Thanks!
Eduard

Hi!

Apologies for the late follow-up.

You say you've trained both your NER and REL models, so I assume these are two separate model folders?

Ideally then, you should be able to compose a new pipeline with these two models in it, using source in your config file:

 [nlp]
 pipeline = ["ner", "rel"]

[components.ner]
source = "path/to/trained_ner_model"
component = "ner"

[components.rel]
source = "path/to/trained_rel_model"
component = "rel"

The assemble CLI tool might help you compile these components into one final model.

Let me know if that helps or you have more questions!

1 Like