With the increase in the complexity of industrial systems and the demand for intelligence, knowledge graphs are being increasingly applied in industrial fields. Knowledge graph completion is essential for optimizing processes, enhancing decision quality, and enabling automation. However, most current methods focus only on node similarity and overlook the rich information in node neighborhoods, thereby limiting the relationship inference. To address this issue, we propose a knowledge graph completion method based on neighborhood information and nested attention. Our proposed model calculates the neighborhood information for all triples, embeds it to form neighborhood and triple representations, and encodes them using a nested attention mechanism to maintain the stability of the structural features. Finally, an inner product decoder completes the missing relationships. The experiments were conducted using three datasets, and the results showed that the prediction accuracy of the model improved while maintaining a low number of parameters. This provides a method for knowledge graph completion tasks that balances model scale and prediction accuracy.
本文引入两层局部点积注意力,形成嵌套注意力机制,将三元组表示和邻域表示分别处理后再进行融合,减少了单次计算所需的元素交互数量。局部点积注意力通过计算查询矩阵 Q 和键矩阵 K 的点积,得到查询向量和键向量的相似度,确定每个输入位置的重要程度。局部性偏置项通过非线性变换和加权计算,能够动态地识别和强调输入序列中对当前任务最为关键的位置,局部性偏置项公式如下:
其中, KA 、 VA 由Attn T 线性变换所得,dka 为 KA 向量的维度,输出为,长度与邻域信息表示相同。Attn C 通过线性变换得到,经过残差链接与归一化后,作为第二层嵌套注意力的输出,该输出将作为下一轮嵌套注意力编码器邻域信息表示的输入。在第一层局部点积注意力层之后,应用一个前馈网络层,由两个线性变换层与非线性激活函数组成,可以表示为以下函数:
JIS X, PANS R, CAMBRIAE, et al. A survey on knowledge graphs: Representation, acquisition, and applications[J]. IEEE Transactions on Neural Networks and Learning Systems, 2022, 33(2): 494-514. DOI: 10.1109/TNNLS.2021.3070843 .
CHENX Y, XIONGS W, WANGS, et al. Embedding of temporal knowledge graph based on contextual temporal association [J]. Journal of Wuhan University (Natural Science Edition), 2023, 69(2): 249-257. DOI:10.14188/j.1671-8836.2022.0304(Ch ).
YANZ Y, DINGC F, MAL R, et al. Advances in knowledge graph embedding based on graph neural networks[J]. Journal of Frontiers of Computer Science & Technology, 2023, 17(8): 1793-1813 (Ch). DOI: 10.3778/j.issn.1673-9418.2212063 .
CHENS X, LIUX D, GAOJ F, et al. HittER: Hierarchical transformers for knowledge graph embeddings[EB/OL]. 2020: 2008.12813. DOI: 10.18653/v1/2021.emnlp-main.812 .
[15]
VASWANIA, SHAZEERN, PARMARN, et al. Attention is all you need[EB/OL].[2024-02-15]. DOI: 10.1007/978-3-031-84300-6_13 .
[16]
BORDESA, USUNIERN, GARCIA-DURANA, et al. Translating embeddings for modeling multi-relational data[EB/OL].[2024-02-15].
[17]
WANGZ, ZHANGJ W, FENGJ L, et al. Knowledge graph embedding by translating on hyperplanes[EB/OL].[2024-02-15]. DOI: 10.1609/aaai.v28i1.8870 .
[18]
LINY K, LIUZ Y, SUNM S, et al. Learning entity and relation embeddings for knowledge graph completion[EB/OL].[2024-02-15]. DOI: 10.1609/aaai.v29i1.9491 .
[19]
SUNZ Q, DENGZ H, NIEJ Y, et al. Rotate: Knowledge graph embedding by relational rotation in complex space[EB/OL]. [2014-02-26]. DOI: 10.1109/iccc52777.2021.9580273 .
[20]
NICKELM, TRESPV, KRIEGELH P. A three-way model for collective learning on multi-relational data[EB/OL]. [2024-02-15]. DOI: 10.1145/2187836.2187874 .
[21]
YANGB S, YIHW T, HEX D, et al. Embedding entities and relations for learning and inference in knowledge bases[EB/OL].[2024-02-15].
[22]
TROUILLONT, WELBLJ, RIEDELS, et al. Complex embeddings for simple link prediction[EB/OL]. 2016: 1606.06357.
[23]
BALAŽEVIĆI, ALLENC, HOSPEDALEST M. TuckER: Tensor factorization for knowledge graph completion[EB/OL]. 2019: 1901.09590. DOI: 10.18653/v1/d19-1522 .
[24]
SOCHERR, CHEND Q, MANNINGC D, et al. Reasoning with neural tensor networks for knowledge base completion[EB/OL]. [2024-02-15]. DOI: 10.1109/ICICIP.2013.6568119 .
[25]
HAYASHIK, KISHIMOTOK, SHIMBOM. Binarized embeddings for fast, space-efficient knowledge graph completion[J]. IEEE Transactions on Knowledge and Data Engineering, 2023, 35(1): 141-153.
WANGL Q, ZHANGT, XUZ H, et al. Fusing entity semantic and structural information for knowledge graph reasoning[J]. Journal of Computer Applications, 2024,44(11): 3371-3378 (Ch).
LONGW, ZHANGM L, HANM. Heterogeneous graph neural network link prediction model based on relational embedding[J]. Computer Measurement & Control, 2025,33(3): 30-36. DOI:10.16526/j.cnki.11-4762/tp.2025.03.004(Ch ).
[35]
LID, XIAT, WANGJ, et al. SDFormer: A shallow-to-deep feature interaction for knowledge graph embedding[J]. Knowledge⁃Based Systems, 2024, 284: 111253. DOI: 10.1016/j.knosys.2023.111253 .
[36]
JIANGD, WANGR G, XUEL X, et al. Multisource hierarchical neural network for knowledge graph embedding[J]. Expert Systems with Applications, 2024, 237: 121446. DOI: 10.1016/j.eswa.2023.121446 .
[37]
WUC H, WUF Z, QIT, et al. Fastformer: Additive attention can be all you need[EB/OL]. 2021: 2108.09084.
[38]
MAX Z, KONGX, WANGS N, et al. Luna: Linear unified nested attention[EB/OL]. [2024-11-08].
[39]
LUJ C, YAOJ H, ZHANGJ G, et al. Soft: Softmax-free transformer with linear complexity[EB/OL]. [2024-11-08].
[40]
XIER B, LIUZ Y, JIAJ. Representation learning of knowledge graphs with entity descriptions[EB/OL]. [2024-11-08].
[41]
BOLLACKERK, EVANSC, PARITOSHP, 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. DOI: 10.1145/1376616.1376746 .
[42]
BORDESA, GLOROTX, WESTONJ, et al. A semantic matching energy function for learning with multi-relational data[J]. Machine Learning, 2014, 94(2): 233-259. DOI: 10.1007/s10994-013-5363-6 .
[43]
MILLERG A. WordNet: A lexical database for English[J]. Communications of the ACM, 1995, 38(11): 39-41. DOI: 10.1145/219717.219748 .