Constrain relation labels with entity types
mainTo improve extraction accuracy, you can constrain relations by defining which entity types are allowed to serve as the head and/or tail of a relationship. Use a dictionary with the key glirel_labels containing your relation definitions.
Schema:
relation_name:{"allowed_head": ["TYPE1", ...], "allowed_tail": ["TYPE2", ...]}- For a relation with no constraints, use an empty dictionary
{}.
labels = {"glirel_labels": {
'co-founder': {"allowed_head": ["PERSON"], "allowed_tail": ["ORG"]},
'no relation': {}, # head and tail can be any entity type
'country of origin': {"allowed_head": ["PERSON", "ORG"], "allowed_tail": ["LOC", "GPE"]},
'parent': {"allowed_head": ["PERSON"], "allowed_tail": ["PERSON"]},
# ...
}}