ICML 2024

KnowFormer: Revisiting Transformers for Knowledge Graph Reasoning

J. Liu, Qianren Mao, Weifeng Jiang, Jianxin Li

Main figure for 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.

Proposed method: KnowFormer

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

#ModelMRR ↑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
actual #12 vs paper #49 37 places worse
0.7440
best reported
actual #12 vs paper #49 37 places worse
paper 0.4860
paper 0.4860 Δ at pub 0.2580
13
RED-GNN
actual #13 vs paper #35 22 places worse
0.7010
best reported
actual #13 vs paper #35 22 places worse
paper 0.5330
paper 0.5330 Δ at pub 0.1680
15
SimKGC
actual #15 vs paper #15
0.6660
actual #15 vs paper #15
paper 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
actual #79 vs paper #79
0.4550
actual #79 vs paper #79
paper 0.4550
prev best: Knowledge Graphs (AAAI 2017)
paper 0.4550 Δ at pub 0.0250
100
TransE
actual #100 vs paper #102 2 places worse
0.2310
best reported
actual #100 vs paper #102 2 places worse
paper 0.2220
#ModelMRR ↑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
actual #33 vs paper #33
0.3580
actual #33 vs paper #33
paper 0.3580
prev best: Knowledge Graphs (AAAI 2017)
paper 0.3580 Δ at pub 0.1170
35
CompGCN
0.3550
This paper
52
RNNLogic
0.3440
This paper
53
DRUM
0.3430
This paper
58
RotatE
actual #58 vs paper #58
0.3380
best reported
actual #58 vs paper #58
paper 0.3370
60
SimKGC
actual #60 vs paper #60
0.3360
actual #60 vs paper #60
paper 0.3360
67
TransE
actual #67 vs paper #67
0.3300
actual #67 vs paper #67
paper 0.3300
paper 0.3300 Δ at pub 0.0360
86
KGT5
0.2760
This paper
SOTA performance (not significantly different from the best) Proposed method (this paper) Baseline / comparison (this paper) Global context (other papers) Best at pub — reported result worse than the best known when published (best reported in green) Best at pub — reported value improved over the best known when published