Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌯 🌪️ Encapsulate inverse relations #752

Open
wants to merge 80 commits into
base: master
Choose a base branch
from

Conversation

mberr
Copy link
Member

@mberr mberr commented Jan 25, 2022

Fixes #749

Tasks:

  • remove inverse_triples flags from TriplesFactory and Datasets.
  • add inverse triples handling to Model
  • update training loop / instances

Dependencies

New Structure

  • abstract:
    • score_hrt(h, r, t)
    • score_h(r, t, slice_size)
    • score_r(h, t, slice_size)
    • score_t(h, r, slice_size)
  • wrapper (abstract + inverse relation handling):
    • score_hrt_extended(h, r, t, invert_relation)
    • score_h_extended(r, t, slice_size, invert_relation)
    • score_r_extended(h, t, slice_size, invert_relation)
    • score_t_extended(h, r, slice_size, invert_relation)
  • predict (eval + wrapper + switch to score_h):
    • predict_hrt(h, r, t, invert_relation)
    • predict_h(r, t, slice_size, invert_relation)
    • predict_r(h, t, slice_size, invert_relation)
    • predict_t(h, r, slice_size, invert_relation)
  • score_{hrt,h,t}_inverse -> move to prediction workflows?

@cthoyt
Copy link
Member

cthoyt commented Jan 30, 2022

What's the roadmap for this PR?

I think that it's fine to keep score_{hrt,h,t}_inverse inside the model - it would only appear in the base Model class, right?

@cthoyt cthoyt marked this pull request as ready for review January 15, 2023 18:38
@@ -339,6 +339,11 @@ def __init__(
triples_factory=triples_factory,
representations=relation_representations,
representations_kwargs=relation_representations_kwargs,
# TODO: check this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: check this

@@ -651,10 +657,13 @@ def _get_representations(
h: Optional[torch.LongTensor],
r: Optional[torch.LongTensor],
t: Optional[torch.LongTensor],
invert_relation: bool = False, # TODO: do we need this here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be necessary if we had a separate Representation module for inverse relations 🤔

elif self.target == 1:
self.score_method = self.model.score_r # type: ignore
elif self.target == 2:
self.supports_slicing = self.model.can_slice_r
elif self.target == 2: # TODO: inverse relations?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO what about inverse relations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encapsulate inverse relations inside Model
2 participants