KnowFormer: Revisiting Transformers for Knowledge Graph Reasoning
Abstract
Knowledge graph reasoning plays a vital role in various applications and has garnered considerable attention. Recently, path-based methods have achieved impressive performance. However, they may face limitations stemming from constraints in message-passing neural networks, such as missing paths and information over-squashing. In this paper, we revisit the application of transformers for knowledge graph reasoning to address the constraints faced by path-based methods and propose a novel method KnowFormer. KnowFormer utilizes a transformer architecture to perform reasoning on knowledge graphs from the message-passing perspective, rather than reasoning by textual information like previous pretrained language model based methods. Specifically, we define the attention computation based on the query prototype of knowledge graph reasoning, facilitating convenient construction and efficient optimization. To incorporate structural information into the self-attention mechanism, we introduce structure-aware modules to calculate query, key, and value respectively. Additionally, we present an efficient attention computation method for better scalability. Experimental results demonstrate the superior performance of KnowFormer compared to prominent baseline methods on both transductive and inductive benchmarks.
Benchmark Results
Tested on 2 datasets 4 baseline values reported too low
Tables show presented results in global context (best 3 papers + GCN + MLP).
Knowledge Graphs
| # | Model | MRR ↑ | Paper |
|---|---|---|---|
| 1 | FedSage | 0.8426
±0.0026 | |
| 2 | FED-PUB | 0.8348
±0.0025 | |
| 3 | FedAvg | 0.8252
±0.0023 | |
| 7 | GCN | 0.8171
±0.0030 | |
| 12 | DRUM | 0.7440 best reported | best at pub: A Theory of Link Prediction via Relational Weisfeiler-Leman on Knowledge Graphs (NeurIPS 2023) |
| 13 | RED-GNN | 0.7010 best reported | best at pub: Knowledge Graph Reasoning with Relational Digraph (WWW 2021) |
| 15 | SimKGC | 0.6660 | |
| 21 | KnowFormer | 0.5790 | This paper |
| 29 | AdaProp | 0.5620 | This paper |
| 32 | NBFnet | 0.5510 | This paper |
| 33 | A*Net | 0.5490 | This paper |
| 36 | HousE | 0.5110 | This paper |
| 37 | KGT5 | 0.5080 | This paper |
| 38 | HittER | 0.5030 | This paper |
| 51 | RNNLogic | 0.4830 | This paper |
| 57 | ULTRA | 0.4800 | This paper |
| 60 | CompGCN | 0.4790 | This paper |
| 62 | RotatE | 0.4770 | This paper |
| 79 | DistMult | 0.4550 | prev best: Knowledge Graphs (AAAI 2017) |
| 100 | TransE | 0.2310 best reported |
| # | Model | MRR ↑ | Paper |
|---|---|---|---|
| 1 | sum, Msg_r^3, f(t)=0 | 0.8500 | |
| 2 | sum, Msg_r^3, f(t)=t | 0.8440 | |
| 3 | PNA, Msg_r^1, f(t)=0 | 0.8010 | |
| 9 | KnowFormer | 0.4300 | This paper |
| 11 | AdaProp | 0.4170 | This paper |
| 12 | NBFnet | 0.4150 | This paper |
| 13 | A*Net | 0.4110 | This paper |
| 16 | RED-GNN | 0.3740 | This paper |
| 17 | HittER | 0.3730 | This paper |
| 22 | ULTRA | 0.3680 | This paper |
| 26 | HousE | 0.3610 | This paper |
| 33 | DistMult | 0.3580 | prev best: Knowledge Graphs (AAAI 2017) |
| 35 | CompGCN | 0.3550 | This paper |
| 52 | RNNLogic | 0.3440 | This paper |
| 53 | DRUM | 0.3430 | This paper |
| 58 | RotatE | 0.3380 best reported | best at pub: RotatE: Knowledge Graph Embedding by Relational Rotation in Complex Space (ICLR 2018) |
| 60 | SimKGC | 0.3360 | |
| 67 | TransE | 0.3300 | prev best: Composition-based Multi-Relational Graph Convolutional Networks (ICLR 2019) |
| 86 | KGT5 | 0.2760 | This paper |
