Relationship between named entities

This is a difficult question to answer, because it's not really trivial to recommend a generic approach for relation extraction that is bound to work in all domains.

However, we did recently create an example implementation for a REL component as a spaCy 3 project. You can find it here:

It contains a ML model implemented from scratch in Thinc, as well as a new trainable pipeline component rel that you can add to your pipeline. It requires the annotations to be encoded in the doc._.rel custom attribute. More background information can be found in the docs here: https://nightly.spacy.io/usage/layers-architectures#component-rel (still a bit under construction right now)

Note in particular that the project example contains a config file for training the new model on a CPU with a Tok2Vec layer, as well as an alternative to use a Transformer (on a GPU).

This approach should really be regarded as a first baseline approach, and it's currently run on a very small toy dataset with biomolecular interactions. You can check it out and play with it though, replace the data with your own annotations, perhaps add more features and/or tune the model architecture & parameters. Have fun experimenting :wink:

5 Likes