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

🦋 🏇 Label-based initialization #652

Merged
merged 49 commits into from
Dec 11, 2021
Merged

Conversation

mberr
Copy link
Member

@mberr mberr commented Nov 26, 2021

This PR adds label-based initialization and representations using pre-trained language models from the transformers library

  1. LabelBasedInitializer adds a new initializer, which computed vectors from the entities' labels. After initialization, the vectors may be trained and from that point lose its connection to the language model.
  2. LabelBasedTransformerRepresentation, in contrast, maintain the connection between the labels and the representations, but allow to fine-tune the language model behind it.

The second option requires significantly more memory and computational cost, since the parameters of the language model require gradients, too.

Typically, you would not directly pass the label-based representations to simple (functional) interaction functions, such as TransE, RotatE or DistMult, but rather prefer parametric ones, e.g., ERMLP ,which allow further projections into a more suitable space.

tests/test_nn/test_init.py Outdated Show resolved Hide resolved
@cthoyt cthoyt changed the title Label based initialization 🦋 🏇 Label-based initialization Nov 29, 2021
src/pykeen/nn/utils.py Outdated Show resolved Hide resolved
src/pykeen/nn/utils.py Outdated Show resolved Hide resolved
mberr and others added 2 commits December 9, 2021 22:41
Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>
@mberr mberr marked this pull request as ready for review December 9, 2021 21:42
@mberr mberr requested a review from cthoyt December 9, 2021 21:51
src/pykeen/nn/utils.py Outdated Show resolved Hide resolved
@mberr
Copy link
Member Author

mberr commented Dec 10, 2021

@cthoyt

what to do about the warning from here

Warning, treated as error:
/home/runner/work/pykeen/pykeen/.tox/docs/tmp/source/reference/nn/utils.rst:document isn't included in any toctree
ERROR: InvocationError for command /home/runner/work/pykeen/pykeen/.tox/docs/bin/python -m sphinx -W -b html -d /home/runner/work/pykeen/pykeen/.tox/docs/tmp/build/doctrees /home/runner/work/pykeen/pykeen/.tox/docs/tmp/source /home/runner/work/pykeen/pykeen/.tox/docs/tmp/build/html (exited with code 2)

@cthoyt
Copy link
Member

cthoyt commented Dec 10, 2021

@cthoyt

what to do about the warning from here

Warning, treated as error:
/home/runner/work/pykeen/pykeen/.tox/docs/tmp/source/reference/nn/utils.rst:document isn't included in any toctree
ERROR: InvocationError for command /home/runner/work/pykeen/pykeen/.tox/docs/bin/python -m sphinx -W -b html -d /home/runner/work/pykeen/pykeen/.tox/docs/tmp/build/doctrees /home/runner/work/pykeen/pykeen/.tox/docs/tmp/source /home/runner/work/pykeen/pykeen/.tox/docs/tmp/build/html (exited with code 2)

Fixed in 40cb229

@cthoyt
Copy link
Member

cthoyt commented Dec 11, 2021

@mberr thanks for adding the tutorial! is there anything else you're planning to add, or do you want me to clean it up and finish this PR?

src/pykeen/nn/utils.py Outdated Show resolved Hide resolved
@mberr mberr merged commit 19cc108 into master Dec 11, 2021
@mberr mberr deleted the label-based-representations branch December 11, 2021 16:13
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.

None yet

2 participants