# Named Entity Relations - beginner questions

**URL:** <https://support.prodi.gy/t/named-entity-relations-beginner-questions/3402>\
**Category:** Uncategorized\
**Tags:** usage, relations\
**Created:** [September 16, 2020, 5:13am UTC](https://support.prodi.gy/t/named-entity-relations-beginner-questions/3402 "2020-09-16T05:13:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Onyoursix](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/onyoursix/32/1579_2.png) [@Onyoursix](https://support.prodi.gy/u/Onyoursix)\
**Post date:** [September 16, 2020, 5:13am UTC](https://support.prodi.gy/t/named-entity-relations-beginner-questions/3402/1 "2020-09-16T05:13:07Z")

</div>

I've created an NER model that seems to be working very well. Now I would like to do the relations between the entities.

I'm curious on a few things that I'm ignorant on and can't seem to find an answer that suffices me.

1. When I'm done annotating the relations can I train a model using "prodigy train parser my\_rel\_dataset....."? Or should that strictly be used for the dependency parsing? I trained one relation model doing this and it seemed to work quite well, however I'm questioning myself if this is the right way to do it.

2. Many of my relations are between multiple people and one action, like "Jerry, Jim, and Pam competed in the race" Where I want to link each person to "race". Should I do a many to one relation or a one to many relation? Does it matter if a child has multiple heads or if a head has multiple children?

3. When annotating, I have a lot of named entities but I only really care about the relationship between two of them. Is it more beneficial to annotate all relations for training purposes or just focus on the one I care about?

4. Can you display relations with displaCy? I tried to do this once after a test and it only showed one of my labels linking back in on itself for each word, I assumed I just messed up somewhere.

Thanks!

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 16, 2020, 6:51pm UTC](https://support.prodi.gy/t/named-entity-relations-beginner-questions/3402/2 "2020-09-16T18:51:12Z")

</div>

Hi! The relations workflow in Prodigy is still very new and it's important to note that spaCy currently doesn't have a built-in out-of-the-box model implementation for predicting relations between entities – so you'd have to bring your own. Some related threads:

- [Relationship between named entities](https://support.prodi.gy/t/relationship-between-named-entities/3171)  
[Training spacy dependency parser using relations custom recipe](https://support.prodi.gy/t/training-spacy-dependency-parser-using-relations-custom-recipe/3103)

> [@Onyoursix](#):
>
> When I'm done annotating the relations can I train a model using "prodigy train parser my\_rel\_dataset....."? Or should that strictly be used for the dependency parsing?

Yes, the parser is designed specifically for dependency parsing, so using it in this way wouldn't really work. The task of dependency parsing and the assumptions a parser makes are quite different from what you're going for.

> [@Onyoursix](#):
>
> Should I do a many to one relation or a one to many relation? Does it matter if a child has multiple heads or if a head has multiple children?

There's no definitive answer for that and it will depend on the model you're using and what exactly you want to predict.

> [@Onyoursix](#):
>
> When annotating, I have a lot of named entities but I only really care about the relationship between two of them. Is it more beneficial to annotate all relations for training purposes or just focus on the one I care about?

Since the relation prediction task would happen in a separate step, I think it's fine to just focus on the entities you're interested in and only run your relation extraction logic if an entity type `PERSON` is found, etc.

> [@Onyoursix](#):
>
> Can you display relations with displaCy? I tried to do this once after a test and it only showed one of my labels linking back in on itself for each word, I assumed I just messed up somewhere.

The built-in `dep` visualizer can visualize `Doc` objects using their `token.head` and `token.dep_` values. So if those are set (which you can also do manually), you'll be able to visualize it. If you want to visualize relations between spans like entities, one easy option would be to merge them into one token (using `Doc.retokenize`) beforehand.

(If you tried to render a visualization and all tokens were attached to themselves, this usually indicates that the heads weren't set and the default values were used.)

---

<div class="post-metadata">

**Author:** ![Onyoursix](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/onyoursix/32/1579_2.png) [@Onyoursix](https://support.prodi.gy/u/Onyoursix)\
**Post date:** [September 16, 2020, 7:13pm UTC](https://support.prodi.gy/t/named-entity-relations-beginner-questions/3402/3 "2020-09-16T19:13:30Z")

</div>

@ines thank you for taking the time to answer all my questions, this was very helpful and informative!
