Git Product home page Git Product logo

rsn's Introduction

RSN

Lingbing Guo, Zequn Sun, Wei Hu*. Learning to Exploit Long-term Relational Dependencies in Knowledge Graphs. In: ICML 2019

INSTALLATION

  1. Please first install Python 3.5+, and then unpack data.7z.

  2. Type pip install -r requirements in shell to install required packages. Note that, when using Tensorflow 1.2+, the learning rate has to be re-adjusted. We suggest using tensorflow-gpu = 1.1.

RUNNING

  1. Run jupyter by typing jupyter notebook in shell.

  2. In the opened browser, click RSN4EA.ipynb for entity alignment, or RSN4KGC.ipynb for KG completion.

  3. The files RSN4EA.ipynb and RSN4KGC.ipynb record the latest results on DBP-WD (normal) and FB15K, respectively.

  4. You can also click 'Toolbar -> Kernel -> Restart&Run All' to run these two experiments.

DATA

  1. Limited by the space, we only uploaded FB15K for KG completion. For WN18 and FB15K-237, you can easily download them from the Internet.

  2. Change options.data_path or other options.* to run RSN on different datasets with different settings.

  3. For RSN4KGC.ipynb, we adopt a matrix filter method for evaluation, which may use more than 64GB memory.

  4. For entity alignment, V1 denotes the normal datasets, and V2 denotes the dense ones. Please use first 10% data of ref_ent_ids for validation.

  5. entity-alignment-full-data.7z provides a complete version of the EA datasets, including attribute files and datasets with different proportions.

CITATION

If you find our work useful, please kindly cite it as follows:

@inproceedings{RSN,
  author    = {Lingbing Guo and Zequn Sun and Wei Hu},
  title     = {Learning to Exploit Long-term Relational Dependencies in Knowledge Graphs},
  booktitle = {ICML},
  pages     = {2505--2514},
  year      = {2019}
}

rsn's People

Contributors

guolingbing avatar sunzequn avatar whu2015 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rsn's Issues

Save and restore the model?

Hello, as far as I can see there are no ways to save and restore a model when the training is over. It would be nice to have that feature :)

Why is the depth biased calculated differently from what's described in the paper?

In the sampler, the 'pre' column is used to represent the previous entity in the path. However, it doesn't change with the length of the path so far. It's always set to be the first entity in the path.
This is done in initializing the 'pre' column in line: curr.loc[:, 'pre'] = hrt[:, 0]
This line puts the first entity in the path in the pre column.

For example, if the path so far is:
e1, r1, e2, r2, e3, r3, e4
and we are computing the depth bias for the entities that are neighbors to e4, then we will find for each candidate entity ei the bias between (e1, ei) rather than the bias between (e3, ei).

In the paper, its described as such that we calculate the bias between (ei-1, e+1) rather than (e1, ei+1). Can you please explain why this is happenning?

Thanks,

Type-based NCE

Hi,

I found you used type-based noise-constrained estimation (NCE) for negative sampling, which is very interesting. Could you please tell me which part of your code is for the NCE?

Best regards
Sirui

"min" method in cal_ranks function: scoring ties in RSN

Hi, thanks for developing RSN.
I believe this is a ground-breaking model.

I am writing because I saw that the function cal_ranks you use to compute ranks in evaluation function accepts a method parameter that is "min" by default.

If I get it correctly, this conveys the policy for handling ties.
If some entities have the same score as the target one (so if there is a tie) the "min" policy will still give to the target entity the minimum rank. Otherwise, other policies can be applied, e.g. average, or max.

I was wondering how the choice of this policy affects the performances computed for RSN.
Of course, it depends on how many ties RSN generates in evaluation.
In your experience, is this something that happens very often?

Concerning the attribute files of the datasets

Hi, thank you for sharing the code. It has been really helpful! However, I cannot find the attribute files, which should be essential for implementing JAPE and GCN-Align. I wonder whether you can provide these files, or am I missing something?

Many thanks,
Weixin.

Sampler doesn't work

There are multiple bugs in the code.

model.sample_paths() is wrong because sample_paths() is not a method of the class model. I fixed this bug and found another bug in the function sample_paths() in line:
rt_x = rtailkb.loc[hrt[:, 2]].apply(perform_random, axis=1)
The error was:
File "kgc.py", line 448, in sample_paths
rt_x = rtailkb.loc[hrt[:, 2]].apply(perform_random, axis=1)
File "/home/local/QCRI/ahmohamed/anaconda3/envs/rsn/lib/python3.6/site-packages/pandas/core/indexing.py", line 1767, in getitem
return self._getitem_axis(maybe_callable, axis=axis)
File "/home/local/QCRI/ahmohamed/anaconda3/envs/rsn/lib/python3.6/site-packages/pandas/core/indexing.py", line 1953, in _getitem_axis
return self._getitem_iterable(key, axis=axis)
File "/home/local/QCRI/ahmohamed/anaconda3/envs/rsn/lib/python3.6/site-packages/pandas/core/indexing.py", line 1594, in _getitem_iterable
keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
File "/home/local/QCRI/ahmohamed/anaconda3/envs/rsn/lib/python3.6/site-packages/pandas/core/indexing.py", line 1552, in _get_listlike_indexer
keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
File "/home/local/QCRI/ahmohamed/anaconda3/envs/rsn/lib/python3.6/site-packages/pandas/core/indexing.py", line 1654, in _validate_read_indexer
"Passing list-likes to .loc or [] with any missing labels "
KeyError: 'Passing list-likes to .loc or [] with any missing labels is no longer supported, see https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.