本仓库代码是在KALE基础上修改的,加入了多嵌入空间。建议先阅读KALE的源代码,非常简单,建议看懂。多嵌入空间的实现,由于时间紧张,有很多不足的地方,有必要的话,可以参考本仓库的代码自己去实现。
涉及到的论文:
jointly embedding knowledge graphs and logical rules
,这个是KALE相关的论文,有开源代码,地址
Non-Parametric Estimation of Multiple Embeddings
,这个是嵌入空间的论文,没有开源代码,需要自己实现数据流部分可能会涉及到CSPARQL-engine,地址,可以自己去查询相关资料
官方地址:https://github.com/streamreasoning/CSPARQL-engine
本文修改过的CSPARQL-engine代码:https://gitee.com/ygtao/csparql-engine,可以参考。建议直接阅读官方的示例代码比较好。
--------------------------------------------------------以下是KALE的README--------------------------------------------------------
OUTLINE:
The codes in the folder KALE/ are used for jointly embedding knowledge graphs and logical rules. We peovide how to run the experiments of Link Prediction task in the following.
To run the experiments, you need to preprocess datasets in the folder datasets/ following the steps below: (1) Change data form: call the program ConvertDataForm.java in the folder src/basic/dataProcess to convert the string form of original data into digital form, and get resultant files “train/valid/test.txt” in the folder datasets/ (2) Propositionalize logic rules: call the program GroundAllRules.java in folder src\basic\dataProcess to propositionalize logic rules in the folder datasets/, and get a resultant file “groundings.txt”
To train a model, you need to follow the steps below: (1) Export KALEProgram.java in the folder src/kale/joint as runnable JAR file, for example, termed as KALE.jar (2) Call the program KALE.jar with parameters, for example, as follows:
java -jar KALE.jar -train datasets\wn18\train.txt -valid datasets\wn18\valid.txt -test datasets\wn18\test.txt -rule datasets\wn18\groundings.txt -m 18 -n 40943 -w 0.1 -k 50 -d 0.2 -ge 0.1 -gr 0.1 -# 1000 -skip 50
You can also change the parameters when running RUGE.jar:
The program will train a model with the input parameters, and output 5 files:
***Please note that in this new implementation version, KALE is optimized by a new mode, using SGD with AdaGrad and gradient normalization.
To evaluate on the test datasets, you need call the program Eval_LinkPrediction.java in the folder src/test
You can also change the input parameters when running:
The program will evaluate on testing data, and report the metrics of MRR, MED, and Hits@N (raw and filtered setting).
When using this data, one should cite the original paper:
@inproceedings{guo2016:KALE,
title = {Jointly Embedding Knowledge Graphs and Logical Rules},
author = {Shu Guo and Quan Wang and Lihong Wang and Bin Wang and Li Guo},
booktitle = {Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing},
year = {2016},
page = {192-202}
}
For all remarks or questions please contact Quan Wang: wangquan (at) iie (dot) ac (dot) cn .
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。