《计算机应用》唯一官方网站 ›› 2025, Vol. 45 ›› Issue (4): 1148-1156.DOI: 10.11772/j.issn.1001-9081.2024030321
收稿日期:
2024-03-21
修回日期:
2024-04-28
接受日期:
2024-04-29
发布日期:
2024-06-04
出版日期:
2025-04-10
通讯作者:
杨晴
作者简介:
翟社平(1971—),男,陕西宝鸡人,教授,博士,CCF高级会员,主要研究方向:语义计算、区块链基金资助:
Sheping ZHAI1,2, Qing YANG1(), Yan HUANG1, Rui YANG1
Received:
2024-03-21
Revised:
2024-04-28
Accepted:
2024-04-29
Online:
2024-06-04
Published:
2025-04-10
Contact:
Qing YANG
About author:
ZHAI Sheping, born in 1971, Ph. D., professor. His research interests include semantic computing, blockchain.Supported by:
摘要:
已有的知识图谱补全(KGC)方法大多未充分挖掘三元组结构中的关系路径,仅考虑了图结构信息;同时现有模型在实体聚合过程中着重考虑邻域信息,对关系的学习相对简单。针对以上问题,提出融合有向关系和关系路径的图注意力模型DRPGAT。首先,将常规三元组转换为有向关系三元组,并引入注意力机制对不同的有向关系赋予不同的权重,从而完成实体信息的聚合,同时,建立关系路径模型,通过将关系位置嵌入路径信息区分不同位置之间的关系,并过滤无关路径得到有用的路径信息;其次,使用注意力机制对路径信息进行深度学习,以实现关系的聚合;最后,将实体与关系送入解码器,训练得到最终的补全结果。在2个真实数据集上进行链接预测实验,以验证所提模型的有效性。实验结果表明,在FB15k-237数据集上,相较于基线模型中的最优结果,DRPGAT的平均排名(MR)降低了13,平均倒数排名(MRR)、Hits@1、Hits@3、Hits@10分别提高1.9、1.2、2.3和1.6个百分点;在WN18RR数据集上,DRPGAT的MR降低了125,MRR、Hits@1、Hits@3、Hits@10分别提高了1.1、0.4、1.2和0.6个百分点,显示了所提模型的有效性。
中图分类号:
翟社平, 杨晴, 黄妍, 杨锐. 融合有向关系与关系路径的层次注意力的知识图谱补全[J]. 计算机应用, 2025, 45(4): 1148-1156.
Sheping ZHAI, Qing YANG, Yan HUANG, Rui YANG. Knowledge graph completion using hierarchical attention fusing directed relationships and relational paths[J]. Journal of Computer Applications, 2025, 45(4): 1148-1156.
数据集 | 实体数 | 关系数 | 训练集 样本数 | 验证集 样本数 | 测试集 样本数 | 三元组数 |
---|---|---|---|---|---|---|
FB15k-237 | 14 541 | 237 | 272 115 | 17 535 | 20 466 | 310 116 |
WN18RR | 40 943 | 11 | 86 835 | 3 034 | 3 134 | 93 003 |
表1 数据集统计
Tab. 1 Statistics of datasets
数据集 | 实体数 | 关系数 | 训练集 样本数 | 验证集 样本数 | 测试集 样本数 | 三元组数 |
---|---|---|---|---|---|---|
FB15k-237 | 14 541 | 237 | 272 115 | 17 535 | 20 466 | 310 116 |
WN18RR | 40 943 | 11 | 86 835 | 3 034 | 3 134 | 93 003 |
数据集 | 学习率 | 嵌入 维度 | dropout | 批大小 | 注意力 头数 | 编码器 层数 |
---|---|---|---|---|---|---|
FB15k-237 | 0.003 | 200 | 0.1 | 1 024 | 2 | 2 |
WN18RR | 0.003 | 200 | 0.1 | 512 | 1 | 2 |
表2 不同数据集上超参数的最优组合
Tab. 2 Optimal combination of hyperparameters on different datasets
数据集 | 学习率 | 嵌入 维度 | dropout | 批大小 | 注意力 头数 | 编码器 层数 |
---|---|---|---|---|---|---|
FB15k-237 | 0.003 | 200 | 0.1 | 1 024 | 2 | 2 |
WN18RR | 0.003 | 200 | 0.1 | 512 | 1 | 2 |
模型 | FB15k-237 | WN18RR | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
MR↓ | MRR↑ | Hits@1↑ | Hits@3↑ | Hits@10↑ | MR↓ | MRR↑ | Hits@1↑ | Hits@3↑ | Hits@10↑ | |
TransE | 339 | 0.270 | 0.191 | 0.295 | 0.426 | 6 175 | 0.200 | 0.223 | 0.370 | 0.428 |
PTransE | 200 | 0.212 | 0.174 | 0.227 | 0.285 | 2 824 | 0.187 | 0.166 | 0.202 | 0.219 |
OPTransE | 265 | 0.342 | 0.250 | 0.377 | 0.530 | 5 944 | 0.364 | 0.349 | 0.360 | 0.387 |
KPE-PTransE | 0.371 | — | — | 0.594 | 2 140 | 0.450 | — | — | ||
DistMult | 352 | 0.239 | 0.162 | 0.259 | 0.394 | 3 915 | 0.317 | 0.236 | 0.366 | 0.468 |
ComplEx | 395 | 0.271 | 0.187 | 0.298 | 0.441 | 4 790 | 0.388 | 0.333 | 0.422 | 0.472 |
RotatE | 177 | 0.338 | 0.241 | 0.375 | 0.533 | 3 340 | 0.475 | 0.428 | 0.492 | 0.571 |
RatE | 172 | 0.344 | 0.261 | 0.382 | 0.541 | — | — | — | — | — |
ConvE | 260 | 0.305 | 0.237 | 0.356 | 0.494 | 4 917 | 0.424 | 0.415 | 0.445 | 0.496 |
InteractE | — | 0.354 | 0.263 | — | 0.535 | — | 0.463 | 0.430 | — | 0.528 |
CompGCN | 231 | 0.355 | 0.264 | 0.390 | 0.535 | 3 533 | 0.479 | 0.443 | 0.494 | 0.546 |
KBGAT | 210 | 0.352 | — | — | 0.539 | 0.412 | — | — | 0.554 | |
MRGAT | — | 0.358 | 0.266 | 0.386 | 0.542 | — | 0.481 | 0.443 | 0.501 | 0.568 |
Hic-KGQA | — | — | 0.596 | |||||||
DRPGAT | 142 | 0.396 | 0.294 | 0.461 | 0.613 | 2 438 | 0.508 | 0.452 | 0.536 | 0.615 |
表3 不同模型在FB15k-237和WN18RR数据集上的结果对比
Tab. 3 Comparison of results of different models on FB15k-237 and WN18RR datasets
模型 | FB15k-237 | WN18RR | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
MR↓ | MRR↑ | Hits@1↑ | Hits@3↑ | Hits@10↑ | MR↓ | MRR↑ | Hits@1↑ | Hits@3↑ | Hits@10↑ | |
TransE | 339 | 0.270 | 0.191 | 0.295 | 0.426 | 6 175 | 0.200 | 0.223 | 0.370 | 0.428 |
PTransE | 200 | 0.212 | 0.174 | 0.227 | 0.285 | 2 824 | 0.187 | 0.166 | 0.202 | 0.219 |
OPTransE | 265 | 0.342 | 0.250 | 0.377 | 0.530 | 5 944 | 0.364 | 0.349 | 0.360 | 0.387 |
KPE-PTransE | 0.371 | — | — | 0.594 | 2 140 | 0.450 | — | — | ||
DistMult | 352 | 0.239 | 0.162 | 0.259 | 0.394 | 3 915 | 0.317 | 0.236 | 0.366 | 0.468 |
ComplEx | 395 | 0.271 | 0.187 | 0.298 | 0.441 | 4 790 | 0.388 | 0.333 | 0.422 | 0.472 |
RotatE | 177 | 0.338 | 0.241 | 0.375 | 0.533 | 3 340 | 0.475 | 0.428 | 0.492 | 0.571 |
RatE | 172 | 0.344 | 0.261 | 0.382 | 0.541 | — | — | — | — | — |
ConvE | 260 | 0.305 | 0.237 | 0.356 | 0.494 | 4 917 | 0.424 | 0.415 | 0.445 | 0.496 |
InteractE | — | 0.354 | 0.263 | — | 0.535 | — | 0.463 | 0.430 | — | 0.528 |
CompGCN | 231 | 0.355 | 0.264 | 0.390 | 0.535 | 3 533 | 0.479 | 0.443 | 0.494 | 0.546 |
KBGAT | 210 | 0.352 | — | — | 0.539 | 0.412 | — | — | 0.554 | |
MRGAT | — | 0.358 | 0.266 | 0.386 | 0.542 | — | 0.481 | 0.443 | 0.501 | 0.568 |
Hic-KGQA | — | — | 0.596 | |||||||
DRPGAT | 142 | 0.396 | 0.294 | 0.461 | 0.613 | 2 438 | 0.508 | 0.452 | 0.536 | 0.615 |
模型 | FB15k-237 | WN18RR | ||||
---|---|---|---|---|---|---|
MR | MRR | Hits@10 | MR | MRR | Hits@10 | |
DRPGAT-PE-path- DR-GAT | 195 | 0.301 | 0.516 | 3 056 | 0.439 | 0.562 |
DRPGAT-PE-path- DR | 172 | 0.331 | 0.531 | 2 883 | 0.461 | 0.575 |
DRPGAT-PE-path | 166 | 0.340 | 0.556 | 2 762 | 0.473 | 0.590 |
DRPGAT-PE | 151 | 0.375 | 0.591 | 2 509 | 0.495 | 0.599 |
DRPGAT | 142 | 0.396 | 0.613 | 2 438 | 0.508 | 0.615 |
表4 DRPGAT消融实验结果
Tab. 4 Results of DRPGAT ablation experiments
模型 | FB15k-237 | WN18RR | ||||
---|---|---|---|---|---|---|
MR | MRR | Hits@10 | MR | MRR | Hits@10 | |
DRPGAT-PE-path- DR-GAT | 195 | 0.301 | 0.516 | 3 056 | 0.439 | 0.562 |
DRPGAT-PE-path- DR | 172 | 0.331 | 0.531 | 2 883 | 0.461 | 0.575 |
DRPGAT-PE-path | 166 | 0.340 | 0.556 | 2 762 | 0.473 | 0.590 |
DRPGAT-PE | 151 | 0.375 | 0.591 | 2 509 | 0.495 | 0.599 |
DRPGAT | 142 | 0.396 | 0.613 | 2 438 | 0.508 | 0.615 |
路径信息 | 相似度值 | 注意力值 |
---|---|---|
1.000 0 | — | |
0.727 4 | 0.001 3 | |
0.195 8(过滤) | — | |
0.386 9(过滤) | — | |
1.000 0 | — | |
0.684 9 | 0.001 3 | |
0.711 2 | 0.001 6 | |
0.231 7(过滤) | — | |
1.000 0 | — | |
0.859 1 | 0.003 8 | |
0.463 4(过滤) | — | |
0.228 4(过滤) | — |
表5 过滤路径在路径层中的作用
Tab. 5 Role of filter paths at path layer
路径信息 | 相似度值 | 注意力值 |
---|---|---|
1.000 0 | — | |
0.727 4 | 0.001 3 | |
0.195 8(过滤) | — | |
0.386 9(过滤) | — | |
1.000 0 | — | |
0.684 9 | 0.001 3 | |
0.711 2 | 0.001 6 | |
0.231 7(过滤) | — | |
1.000 0 | — | |
0.859 1 | 0.003 8 | |
0.463 4(过滤) | — | |
0.228 4(过滤) | — |
1 | 杜雪盈,刘名威,沈立炜,等. 面向链接预测的知识图谱表示学习方法综述[J]. 软件学报, 2024, 35(1): 87-117. |
DU X Y, LIU M W, SHEN L W, et al. Survey on representation learning methods of knowledge graph for link prediction [J]. Journal of Software, 2024, 35(1): 87-117. | |
2 | BOLLACKER K, EVANS C, PARITOSH P, et al. Freebase: a collaboratively created graph database for structuring human knowledge [C]// Proceedings of the 2008 ACM SIGMOD International Conference on Management of Data. New York: ACM, 2008: 1247-1250. |
3 | MILLER G A. WordNet: a lexical database for English [J]. Communications of the ACM, 1995, 38(11): 39-41. |
4 | LEHMANN J, ISELE R, JAKOB M, et al. DBpedia — a large-scale, multilingual knowledge base extracted from Wikipedia [J]. Semantic Web, 2015, 6(2): 167-195. |
5 | SUDHAHAR S, PIERLEONI A, ROBERTS I. Reasoning over paths via knowledge base completion [C]// Proceedings of the 13th Workshop on Graph-Based Methods for Natural Language Processing. Stroudsburg: ACL, 2019: 164-171. |
6 | 张文豪,徐贞顺,刘纳,等. 知识图谱补全方法研究综述[J]. 计算机工程与应用, 2024, 60(12):61-73. |
ZHANG W H, XU Z S, LIU N, et al. Overview of knowledge graph completion methods[J]. Computer Engineering and Applications, 2024, 60(12):61-73. | |
7 | BORDES A, USUNIER N, GARCIA-DURÁN A, et al. Translating embeddings for modeling multi-relational data [C]// Proceedings of the 26th International Conference on Neural Information Processing Systems — Volume 2. Red Hook: Curran Associates Inc., 2013: 2787-2795. |
8 | LIN Y, LIU Z, SUN M, et al. Learning entity and relation embeddings for knowledge graph completion [C]// Proceedings of the 29th AAAI Conference on Artificial Intelligence. Palo Alto: AAAI Press, 2015, 2181-2187. |
9 | NICKEL M, TRESP V, KRIEGEL H P. A three-way model for collective learning on multi-relational data [C]// Proceedings of the 28th International Conference on Machine Learning. Madison, WI: Omnipress, 2011: 809-816. |
10 | TROUILLON T, WELBL J, RIEDEL S, et al. Complex embeddings for simple link prediction [C]// Proceedings of the 33rd International Conference on Machine Learning. New York: JMLR.org, 2016: 2071-2080. |
11 | LIN Y, LIU Z, LUAN H, et al. Modeling relation paths for representation learning of knowledge bases [C]// Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2015: 705-714. |
12 | XIONG W, HOANG T, WANG W Y. DeepPath: a reinforcement learning method for knowledge graph reasoning [C]// Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2017: 564-573. |
13 | DETTMERS T, MINERVINI P, STENETORP P, et al. Convolutional 2D knowledge graph embeddings [C]// Proceedings of the 32nd AAAI Conference on Artificial Intelligence. Palo Alto: AAAI Press, 2018: 1811-1818. |
14 | VASHISHTH S, SANYAL S, NITIN V, et al. InteractE: improving convolution-based knowledge graph embeddings by increasing feature interactions [C]// Proceedings of the 34th AAAI Conference on Artificial Intelligence. Palo Alto: AAAI Press, 2020: 3009-3016. |
15 | VASHISHTH S, SANYAL S, NITIN V, et al. Composition-based multi-relational graph convolutional networks [EB/OL]. [2024-01-23].. |
16 | LI Z, LIU H, ZHANG Z, et al. Learning knowledge graph embedding with heterogeneous relation attention networks [J]. IEEE Transactions on Neural Networks and Learning Systems, 2022, 33(8): 3961-3973. |
17 | WANG Z, ZHANG J, FENG J, et al. Knowledge graph embedding by translating on hyperplanes [C]// Proceedings of the 28th AAAI Conference on Artificial Intelligence. Palo Alto: AAAI Press, 2014: 1112-1119. |
18 | XIAO H, HUANG M, HAO Y, et al. TransA: an adaptive approach for knowledge graph embedding [EB/OL]. [2023-12-19]. . |
19 | YANG B, YIH W T, HE X, et al. Embedding entities and relations for learning and inference in knowledge bases [EB/OL]. [2023-11-14]. . |
20 | SCHLICHTKRULL M, KIPF T N, BLOEM P, et al. Modeling relational data with graph convolutional networks [C]// Proceedings of the 2018 European Semantic Web Conference, LNCS 10843. Cham: Springer, 2018: 593-607. |
21 | NATHANI D, CHAUHAN J, SHARMA C, et al. Learning attention-based embeddings for relation prediction in knowledge graphs [C]// Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics. Stroudsburg: ACL, 2019: 4710-4723. |
22 | DAI G, WANG X, ZOU X, et al. MRGAT: multi-relational graph attention network for knowledge graph completion [J]. Neural Networks, 2022, 154: 234-245. |
23 | WANG J, LI W, LIU F, et al. Hic-KGQA: improving multi-hop question answering over knowledge graph via hypergraph and inference chain [J]. Knowledge-Based Systems, 2023, 277: No.110810. |
24 | LAO N, COHEN W W. Relational retrieval using a combination of path-constrained random walks [J]. Machine Learning, 2010, 81(1): 53-67. |
25 | ZHU Y, LIU H, WU Z, et al. Representation learning with ordered relation paths for knowledge graph completion [C]// Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing. Stroudsburg: ACL, 2019: 2662-2671. |
26 | ZHANG Y, YAO Q, CHEN L. Interstellar: searching recurrent architecture for knowledge graph embedding [C]// Proceedings of the 34th International Conference on Neural Information Processing Systems. Red Hook: Curran Associates Inc., 2020: 10030-10040. |
27 | PENG Z, YU H, JIA X. Path-based reasoning with K-nearest neighbor and position embedding for knowledge graph completion[J]. Journal of Intelligent Information Systems, 2022, 58(3): 513-533. |
28 | VASWANI A, SHAZEER N, PARMAR N, et al. Attention is all you need [C]// Proceedings of the 31st International Conference on Neural Information Processing Systems. Red Hook: Curran Associates Inc., 2017: 6000-6010. |
29 | SUN Z, DENG Z H, NIE J Y, et al. RotatE: knowledge graph embedding by relational rotation in complex space [EB/OL]. [2024-01-12]. . |
30 | HUANG H, LONG G, SHEN T, et al. RatE: relation-adaptive translating embedding for knowledge graph completion [C]// Proceedings of the 28th International Conference on Computational Linguistics. [S.l.]: International Committee on Computational Linguistics, 2020: 556-567. |
[1] | 徐梓芯, 易修文, 鲍捷, 李天瑞, 张钧波, 郑宇. 面向流行病学调查的知识图谱构建与应用[J]. 《计算机应用》唯一官方网站, 2025, 45(4): 1340-1348. |
[2] | 王利琴, 耿智雷, 李英双, 董永峰, 边萌. 基于路径和增强三元组文本的开放世界知识推理模型[J]. 《计算机应用》唯一官方网站, 2025, 45(4): 1177-1183. |
[3] | 徐春, 吉双焱, 马欢, 孙恩威, 王萌萌, 苏明钰. 基于知识图谱和对话结构的问诊推荐方法[J]. 《计算机应用》唯一官方网站, 2025, 45(4): 1157-1168. |
[4] | 张学飞, 张丽萍, 闫盛, 侯敏, 赵宇博. 知识图谱与大语言模型协同的个性化学习推荐[J]. 《计算机应用》唯一官方网站, 2025, 45(3): 773-784. |
[5] | 袁成哲, 陈国华, 李丁丁, 朱源, 林荣华, 钟昊, 汤庸. ScholatGPT:面向学术社交网络的大语言模型及智能应用[J]. 《计算机应用》唯一官方网站, 2025, 45(3): 755-764. |
[6] | 杨燕, 叶枫, 许栋, 张雪洁, 徐津. 融合大语言模型和提示学习的数字孪生水利知识图谱构建[J]. 《计算机应用》唯一官方网站, 2025, 45(3): 785-793. |
[7] | 王猛, 张大千, 周冰艳, 马倩影, 吕继东. 基于时序知识图谱补全的CTCS-3级列控车载接口设备故障诊断方法[J]. 《计算机应用》唯一官方网站, 2025, 45(2): 677-684. |
[8] | 李瑞, 李贯峰, 胡德洲, 高文馨. 融合路径与子图特征的知识图谱多跳推理模型[J]. 《计算机应用》唯一官方网站, 2025, 45(1): 32-39. |
[9] | 赵文博, 马紫彤, 杨哲. 基于有向超图自适应卷积的链接预测模型[J]. 《计算机应用》唯一官方网站, 2025, 45(1): 15-23. |
[10] | 吕学强, 王涛, 游新冬, 徐戈. 层次融合多元知识的命名实体识别框架——HTLR[J]. 《计算机应用》唯一官方网站, 2025, 45(1): 40-47. |
[11] | 程子栋, 李鹏, 朱枫. 物联网威胁情报知识图谱中潜在关系的挖掘[J]. 《计算机应用》唯一官方网站, 2025, 45(1): 24-31. |
[12] | 薛桂香, 王辉, 周卫峰, 刘瑜, 李岩. 基于知识图谱和时空扩散图卷积网络的港口交通流量预测[J]. 《计算机应用》唯一官方网站, 2024, 44(9): 2952-2957. |
[13] | 武杰, 张安思, 吴茂东, 张仪宗, 王从宝. 知识图谱在装备故障诊断领域的研究与应用综述[J]. 《计算机应用》唯一官方网站, 2024, 44(9): 2651-2659. |
[14] | 赵宇博, 张丽萍, 闫盛, 侯敏, 高茂. 基于改进分段卷积神经网络和知识蒸馏的学科知识实体间关系抽取[J]. 《计算机应用》唯一官方网站, 2024, 44(8): 2421-2429. |
[15] | 李健京, 李贯峰, 秦飞舟, 李卫军. 基于不确定知识图谱嵌入的多关系近似推理模型[J]. 《计算机应用》唯一官方网站, 2024, 44(6): 1751-1759. |
阅读次数 | ||||||
全文 |
|
|||||
摘要 |
|
|||||