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

feat: Add ComplEx KGE #6898

Merged
merged 18 commits into from
Mar 15, 2023
Merged

feat: Add ComplEx KGE #6898

merged 18 commits into from
Mar 15, 2023

Conversation

riyavsinha
Copy link
Contributor

Hello! we are hoping to add the ComplEx knowledge graph embedding to PyG as part of our CS224W final project at Stanford.

Our implementation largely follows that of TransE. We implemented complex vectors by breaking the real and imaginary components into separate vectors, but are open to other approaches.

We'd also like to seek input on whether an example is necessary like for TransE here, and if so, whether it would be preferred to be in the same file or a new one.

riyavsinha and others added 2 commits March 12, 2023 00:23
Co-authored-by: David Kuo <davidekuo@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Mar 12, 2023

Codecov Report

Merging #6898 (5092606) into master (688c754) will decrease coverage by 0.30%.
The diff coverage is 100.00%.

❗ Current head 5092606 differs from pull request most recent head 63b8896. Consider uploading reports for the commit 63b8896 to get more accurate results

@@            Coverage Diff             @@
##           master    #6898      +/-   ##
==========================================
- Coverage   91.80%   91.51%   -0.30%     
==========================================
  Files         428      429       +1     
  Lines       23254    23257       +3     
==========================================
- Hits        21348    21283      -65     
- Misses       1906     1974      +68     
Impacted Files Coverage Δ
torch_geometric/nn/kge/__init__.py 100.00% <100.00%> (ø)
torch_geometric/nn/kge/base.py 95.91% <100.00%> (-0.09%) ⬇️
torch_geometric/nn/kge/complex.py 100.00% <100.00%> (ø)
torch_geometric/nn/kge/transe.py 100.00% <100.00%> (ø)

... and 38 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Co-authored-by: David Kuo <davidekuo@users.noreply.github.com>
@riyavsinha riyavsinha changed the title feat: Add ComplEx KGE feat: Add ComplEx KGE Mar 12, 2023
Copy link
Member

@rusty1s rusty1s left a comment

Choose a reason for hiding this comment

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

This looks great. I suggest we add an argument parser to the initial TransE example to support a variety of models. Would that work for you?

Co-authored-by: David Kuo <davidekuo@users.noreply.github.com>
@riyavsinha riyavsinha removed their assignment Mar 12, 2023
@riyavsinha riyavsinha requested a review from rusty1s March 12, 2023 21:51
riyavsinha and others added 8 commits March 12, 2023 15:32
Adagrad as suggested by the paper worked significantly better than Adam. Achieves Hits@10 of ~.37. Record
on PapersWithCode for ComplEx Hits@10 for FB15k is .42.
Co-authored-by: David Kuo <davidekuo@users.noreply.github.com>
@riyavsinha
Copy link
Contributor Author

Hi Matthias! I think this is ready for review again. The PapersWithCode metric for ComplEx for Hits@10 on fb15k-237 is .42, and our current optimizer settings in the example are consistently about .36-37 (we didn't want to increase the hidden size when tuning though to keep it fast as an example). If you'd like us to find a better hyperparameter set please let us know!

In the current set, we used Adagrad which ended up performing much better than Adam and which was the suggested optimizer in the paper, and we added some L2 weight regularization as also suggested by the paper.

We have also updated the loss function to use BCELogits since that is more numerically stable

Copy link
Member

@rusty1s rusty1s left a comment

Choose a reason for hiding this comment

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

This is very clean. Thank you :)

@rusty1s rusty1s merged commit 2947af7 into pyg-team:master Mar 15, 2023
@rusty1s rusty1s added the cs224w label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants