# KGE
The Knowledge Graph Embedding (KGE) repository is an implementation of the state of the art techniques related to Statistical Relational Learning (SRL) to solve Link Prediction problems. These techniques map the structure of large knowledge graphs on models able to predict missing relationships in new triples [1-2]. The techniques implemented in this code include TransE, DistMult, RESCAL and ComplEx.
## Technical requirements
The system was develop in python 2.7. The code depends on rdflib, downhill and theano [3] packages. Install it, along with other dependencies with:
```
pip install rdflib downhill theano
```
## Example of use
The simplest way to generate and evaluate the models is calling the `run.py` script. The `model` parameter is the techniques available, the `data` is the full path of the dataset to be executed, the `k` is the dimension of the embedding vectors, the `epoch` is the number of epochs to be executed and the `folds` is the number of folds used in the k-fold cross-validation technique. The simplest way to execute the KGE techniques is:
```
python run.py evaluation --model Complex --data /tmp/wn18k.txt --k 200 --epoch 1000 --folds 5
```
The code can be executed in the x86 or using GPUs. To execute the code using GPUs you need to add the flag `DEVICE=cuda0` before calling the execution line. Additional parameters can be fitted: `lmbda` is the lambda value, `lr` is the learning rate, `bsize` is the number of examples in the batch, `negative` is the number of negative samples used and `folds` the number of folds in the cross-validation technique.
The output is the main information about the dataset, the stochastic gradient descent error and the average performance of the models for each fold. The performance is a vector where the values represent the evaluation metrics like the Mean Reciprocal Rank (MRR) and Hits at N, with N = {1, 3, 10}. The output is similar to that:
```python
MRR H@1 H@3 H@10
0.714 0.618 0.805 0.825
0.713 0.620 0.803 0.821
0.715 0.622 0.805 0.826
0.710 0.615 0.802 0.823
0.713 0.619 0.803 0.823
```
The best model generated after the cross-validation execution will be exported in the main folder with the name `model.txt`. To evaluate a new data, you should call the prediction function with the full path of the test data:
```
python run.py prediction --data /tmp/wn18k.txt
```
The output is a table called `out.csv` with the associated probability of each triple.
## Add more data
To run the techniques using your own data, you need to add the file in the subfolder `datasets` using csv or rdf format. In the csv format, the triples need to separated by tabs. After that, you only need to execute the techniques with the name of the dataset.
## Developer notes
To submit bugs and feature requests, report at [project issues](https://github.com/QROWD/KGE/issues).
## References
[1] Maximilian Nickel, Kevin Murphy, Volker Tresp and Evgeniy Gabrilovich. (2016). A review of relational machine learning for knowledge graphs. Proceedings of the IEEE, 104(1):11-33.
[2] Théo Trouillon, Johannes Welbl, Sebastian Riedel, Eric Gaussier and Guillaume Bouchard. (2016). Complex embeddings for simple link prediction. In International Conference on Machine Learning (ICML), 48:2071-2080.
[3] Theano Development Team. (2017). Theano: A Python framework for fast computation of mathematical expressions.
没有合适的资源?快使用搜索试试~ 我知道了~
KGE:知识图嵌入用于链接预测
共15个文件
py:8个
txt:2个
license:1个
需积分: 50 9 下载量 67 浏览量
2021-05-15
09:02:03
上传
评论 1
收藏 8.84MB ZIP 举报
温馨提示
凯格 知识图嵌入(KGE)库是与统计关系学习(SRL)有关的最新技术的一种实现,用于解决链接预测问题。 这些技术将大型知识图的结构映射到能够预测新三元组中缺失关系的模型上[1-2]。 此代码中实现的技术包括TransE,DistMult,RESCAL和ComplEx。 技术要求 该系统是在python 2.7中开发的。 该代码取决于rdflib,downhill和theano [3]软件包。 连同其他依赖项一起安装: pip install rdflib downhill theano 使用例 生成和评估模型的最简单方法是调用run.py脚本。 所述model参数是可用的技术中, data是将要执行的数据集的完整路径,所述k是嵌入向量的维数,所述epoch是历元将被执行的次数和folds使用的折叠的数量在k折交叉验证技术中。 执行KGE技术的最简单方法是: python run.p
资源详情
资源评论
资源推荐
收起资源包目录
KGE-master.zip (15个子文件)
KGE-master
run.py 3KB
datasets
fb15k.txt 43.97MB
wn18.txt 4.86MB
bicycleparking.nt 2.45MB
LICENSE 1KB
tensor
evaluation.py 1KB
experiment.py 637B
batching.py 1KB
__init__.py 0B
models.py 7KB
tools.py 1KB
read.py 1KB
README.md 3KB
pbs.sh 377B
.gitignore 5B
共 15 条
- 1
荒腔走兽
- 粉丝: 23
- 资源: 4663
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0