Similarity-Constrained Reweighting for Complex Query Answering on Knowledge Graphs
Authors: Daniel Daza, Alberto Bernardi, Luca Costabello, Christophe Gueret, Michael Cochez, Martijn Schut
Organizations: Vrije Universiteit Amsterdam · Eindhoven University of Technology · Translational AI Laboratory, Department of Laboratory Medicine Amsterdam University Medical Center, Vrije Universiteit Amsterdam · Accenture Labs · ELLIS Institute Finland · ˚Abo Akademi University, Turku, Finland · Elsevier Discovery Lab, Amsterdam
Machine learning models for Complex Query Answering (CQA) on knowledge graphs estimate the likelihood of answers that are not reachable via direct traversal. Recent work has proposed extending such queries with soft entity constraints, which require the target variable to be similar or dissimilar to specified sets of entities. We study a more general formulation where similarity constraints are specified on an arbitrary variable in a query, and introduce SCORE: a computationally efficient and interpretable method for incorporating similarity constraints on an arbitrary variable of a query. SCORE is based on a lightweight and interpretable score adjustment function that only requires tuning two hyperparameters on a validation set. Our experiments show that SCORE effectively incorporates preferences while maintaining strong query answering performance. It significantly improves ranking quality when constraints apply to the target variable and performs effectively in the more general case involving constraints on intermediate variables, and its performance remains robust when applied to several existing methods for CQA. Our implementation is available at https://github.com/dfdazac/score.
Figures & tables
Figure 1: Illustration of three approaches for query answering on knowledge graphs, with vectors indicating entity scores at different steps. Left : a traditional query with purely logical constraints. Middle : incorporating similarity constraints in NQR [ 10 ] , which supports only the target variable via uncalibrated score adjustments (shown in red and blue). Right : SCORE, which supports similarity constraints on arbitrary variables through normalized similarity scores.
Figure 2: Existing CQA methods compute fuzzy vectors via projection and intersection operators. We illustrate how we integrate the SCORE update ( Equation 9 ), by applying it after these operations have been computed by the base CQA model, with Δs indicating similarity scores.
Figure 3: SimCQA results for similarity constraints on the target variable. Shaded areas indicate a 95% confidence interval.
Figure 4: SimCQA results for similarity constraints on the target and intermediate variables, comparing SCORE with the adapted MeanCosine baseline. Shaded areas indicate a 95% confidence interval.
Figure 5: NDCG@10 per query type and variable position on different datasets. Indices indicate where the positions of variables in which similarity constraints are applied in the query.
Table 1: Example 2-hop query from Hetionet, showing the top-scored entities for both the intermediate (drug) and target (side effect) variables before and after applying similarity constraints with SCORE. ▲ indicates a promoted entity, ▼ a demoted one.
Dataset
Base
+SCORE
Δ
FB15k237
2.96
4.20
+1.24
Hetionet
25.65
28.68
+3.03
NELL-995
75.51
83.96
+8.45
Table 2: Average runtime per query (ms) with and without SCORE.
Appendix figures & tables18 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 6: Query graphs of different types covered in the datasets used in our experiments, along with their designated name.
Knowledge Graph
Queries
Preference Sets
Dataset
Entities
Relations
Edges
Train
Validation
Test
Train
Validation
Test
FB15k237
14,505
237
310,079
157,479
20,961
21,352
580,623
68,834
70,365
Hetionet
45,158
24
2,250,198
91,820
29,475
29,488
325,443
99,785
99,284
NELL995
63,361
200
142,804
75,446
17,289
17,435
245,511
52,446
52,589
Appendix
Table 3: Statistics of the datasets used in our experiments.
Structure
1p
2p
3p
2i
3i
ip
pi
2in
3in
inp
pin
pni
2u
up
Total
FB15k237
Training
Queries
7,596
34,720
56,495
16,205
8,870
0
0
5,300
3,821
9,384
8,891
6,197
0
0
157,479
Pref. Sets
19,075
121,420
240,770
46,302
26,265
0
0
16,536
11,530
41,128
38,217
19,380
0
0
580,623
Validation
Queries
1,631
1,746
2,255
1,341
753
1,249
1,501
1,210
1,560
2,184
1,825
782
1,087
1,837
20,961
Appendix
Table 4: Statistics of the queries and preference sets in the datasets used in our experiments.
Method
PA
MRR
H@1
H@10
NDCG@10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
Base CQA model
54.7
54.7
54.7
24.2
24.2
24.2
16.3
16.3
16.3
40.0
40.0
40.0
33.4
33.4
33.4
MeanCosine
63.0
66.6
67.2
22.9
23.7
23.9
15.5
16.0
16.1
37.7
39.1
39.5
32.7
34.0
34.3
NQR
70.6
74.0
75.1
18.9
19.9
20.1
12.5
13.2
13.3
31.8
33.3
33.8
28.9
30.8
31.3
SCORE
58.6
60.2
60.3
24.0
24.1
24.2
16.1
16.2
16.2
40.0
40.1
40.1
34.1
34.4
34.4
Appendix
Table 5: Numeric results for target-variable SimCQA on FB15k-237 at preference-set sizes t∈{1,5,10} .
Method
PA
MRR
H@1
H@10
NDCG@10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
Base CQA model
51.7
51.7
51.7
32.5
32.5
32.5
25.1
25.1
25.1
47.2
47.2
47.2
41.5
41.5
41.5
MeanCosine
57.3
59.3
59.8
30.9
32.0
32.4
24.3
25.2
25.4
43.7
45.5
46.2
40.2
42.0
42.5
NQR
80.1
85.4
86.6
20.9
21.8
22.0
14.9
15.8
16.0
33.0
34.0
34.2
33.2
35.4
35.9
SCORE
56.9
58.0
58.1
30.7
31.8
32.4
23.0
24.4
25.1
45.9
46.6
46.9
41.1
42.4
42.9
Appendix
Table 6: Numeric results for target-variable SimCQA on Hetionet at preference-set sizes t∈{1,5,10} .
Method
PA
MRR
H@1
H@10
NDCG@10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
Base CQA model
51.7
51.7
51.7
16.5
16.5
16.5
8.7
8.7
8.7
32.2
32.2
32.2
26.7
26.7
26.7
MeanCosine
56.4
58.8
59.1
14.7
15.8
16.3
8.2
8.7
9.0
27.9
30.3
31.1
24.6
26.5
27.2
NQR
63.7
63.8
63.8
9.6
10.1
10.2
4.8
5.1
5.1
18.9
19.9
20.2
18.1
19.0
19.2
SCORE
53.9
54.3
54.3
16.3
16.8
17.0
8.7
9.1
9.3
31.9
32.5
32.7
26.8
27.7
27.8
Appendix
Table 7: Numeric results for target-variable SimCQA on NELL-995 at preference-set sizes t∈{1,5,10} .
Method
PA
MRR
H@1
H@10
NDCG@10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
Base CQA model
53.3
53.3
53.3
20.9
20.9
20.9
13.9
13.9
13.9
35.0
35.0
35.0
31.7
31.7
31.7
SCORE
56.5
58.2
58.4
20.8
20.9
20.9
13.7
13.8
13.8
35.0
34.9
35.0
32.3
32.6
32.7
MeanCosine
58.6
61.1
61.4
17.3
17.8
17.9
11.4
11.7
11.8
28.7
29.7
30.0
26.1
27.0
27.2
Appendix
Table 8: Numeric results for general SimCQA on FB15k-237 at preference-set sizes t∈{1,5,10} .
Method
PA
MRR
H@1
H@10
NDCG@10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
Base CQA model
51.1
51.1
51.1
26.1
26.1
26.1
19.7
19.7
19.7
38.5
38.5
38.5
36.0
36.0
36.0
SCORE
55.3
56.6
56.8
24.7
25.7
26.1
18.2
19.3
19.7
37.6
38.2
38.5
36.0
37.3
37.7
MeanCosine
55.1
56.7
57.0
24.4
25.2
25.5
18.9
19.5
19.7
35.0
36.4
36.9
33.4
34.8
35.2
Appendix
Table 9: Numeric results for general SimCQA on Hetionet at preference-set sizes t∈{1,5,10} .
Method
PA
MRR
H@1
H@10
NDCG@10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
t=1
t=5
t=10
Base CQA model
51.4
51.4
51.4
15.4
15.4
15.4
8.2
8.2
8.2
30.0
30.0
30.0
26.5
26.5
26.5
SCORE
53.5
54.2
54.3
15.3
15.7
15.9
8.2
8.5
8.6
29.7
30.3
30.5
26.7
27.4
27.6
MeanCosine
55.1
57.0
57.2
12.8
13.6
14.0
7.0
7.4
7.7
24.1
26.0
26.6
22.7
24.1
24.6
Appendix
Table 10: Numeric results for general SimCQA on NELL-995 at preference-set sizes t∈{1,5,10} .
Method
1p
2in
2i
2p
2u
3in
3i
3p
inp
ip
pin
pi
pni
up
Avg.
FB15k237
Base CQA model
43.90
23.34
47.40
28.75
34.37
37.14
50.54
27.16
21.48
34.32
20.05
41.32
9.87
27.98
31.97
MeanCosine
44.25
23.76
47.92
29.67
34.80
37.20
50.92
26.95
22.81
34.29
20.38
40.53
10.33
28.34
32.30
NQR
41.61
21.13
46.13
25.24
32.33
33.82
49.43
21.30
19.48
27.79
16.92
36.12
9.25
25.95
29.04
SCORE
44.43
24.07
48.06
29.84
34.91
37.80
51.38
28.34
22.62
35.61
21.20
42.03
10.57
28.73
32.83
Hetionet
Appendix
Table 11: NDCG@10 results for target-variable SimCQA , averaged over preference sets of size t=1,…,10 .
Method
1ps0
2ins0
2is0
2ps0
2ps1
2us0
3ins0
3is0
3ps0
3ps1
3ps2
inps0
inps1
ips0
ips1
pins0
pins1
pis0
pis1
pnis1
ups0
ups1
Avg.
FB15k237
Base CQA model
43.90
23.34
47.40
29.29
28.75
34.37
37.14
50.54
28.60
27.72
27.16
22.15
21.48
40.29
34.32
21.48
20.05
36.97
41.32
9.87
30.34
27.98
31.11
MeanCosine
44.25
23.76
47.92
12.74
29.67
34.80
37.20
50.92
15.72
12.09
26.95
8.55
22.81
14.34
34.29
9.23
20.38
20.19
40.53
10.33
13.41
28.34
25.38
SCORE
44.43
24.07
48.06
29.39
29.84
34.91
37.80
51.38
29.00
28.36
28.34
22.65
22.62
40.42
35.61
22.36
21.20
38.12
42.03
10.57
30.68
28.73
31.84
Hetionet
Base CQA model
52.95
33.11
44.51
17.14
17.10
44.21
22.11
48.94
32.02
14.59
14.58
13.52
13.63
21.42
18.38
13.84
11.27
30.27
34.94
12.84
17.18
18.18
24.85
Appendix
Table 12: NDCG@10 results for general SimCQA , averaged over preference sets of size t=1,…,10 .
Figure 7: Additional metrics for SimCQA with similarity constraints on the target variable. Shaded areas indicate a 95% confidence interval.
Figure 8: Additional metrics for SimCQA with similarity constraints on the target and intermediate variables. Shaded areas indicate a 95% confidence interval.
Figure 9: SimCQA results for similarity constraints on the target variable, using different base CQA models: GNN-QE [ 35 ] and UltraQuery [ 11 ] . Shaded areas indicate a 95% confidence interval.
Figure 10: SimCQA results for similarity constraints on target and intermediate variables, using different base CQA models: GNN-QE [ 35 ] and UltraQuery [ 11 ] . Shaded areas indicate a 95% confidence interval.
Method
1p
2in
2i
2p
2u
3in
3i
3p
inp
ip
pin
pi
pni
up
Avg.
Pairwise accuracy
Base CQA model
58.15
56.03
54.72
55.59
57.70
52.98
54.22
53.01
54.65
55.55
53.62
55.50
57.39
53.97
55.22
MeanCosine
63.36
67.45
58.95
69.59
66.01
61.64
57.60
70.98
69.95
68.18
71.60
64.55
69.81
67.07
66.20
NQR
79.45
75.37
69.22
73.89
74.47
70.45
67.28
72.66
72.37
75.71
73.72
72.71
75.79
71.78
73.20
SCORE
62.82
62.44
58.06
61.04
62.12
58.92
57.28
58.23
59.58
60.75
60.42
59.15
62.34
58.75
60.14
Δ
+4.67
+6.41
+3.34
+5.46
+4.42
+5.94
+3.06
+5.21
+4.92
+5.20
+6.80
+3.65
+4.94
+4.78
+4.91
Appendix
Table 13: Pairwise accuracy (PA) and MRR per query type for target-variable SimCQA on FB15k-237, averaged over preference sets of size t=1,…,10 . Δ denotes the difference between SCORE and the base CQA model.
Figure 11: SCORE for general SimCQA on FB15k-237 when a fraction k of the labels in each preference set is flipped. Shaded areas indicate a 95% confidence interval.
PA
MRR
NDCG@10
Method
2p
3p
2p
3p
2p
3p
Base CQA model
52.54
49.16
18.07
11.54
26.76
25.64
SCORE
58.17
54.48
17.96
11.58
27.88
26.23
Appendix
Table 14: Results with similarity constraints on two variables of 2p and 3p queries (FB15k-237), averaged over preference sets of size t=1,…,10 .
Knowledge Graph Question Answering answers natural-language questions by finding and reasoning over entities and relations in structured knowledge graphs.
Institute for Artificial Intelligence, University of Stuttgart, Germany · Stanford University · School of Informatics University of Edinburgh Edinburgh, UK +1