U NI KGQA:
U NIFIED
R ETRIEVAL
AND
R EASONING
FOR
S OLVING
M ULTI - HOP
Q UESTION
A NSWERING
O VER K NOWLEDGE G RAPH
Anonymous authors
Paper under double-blind review
A BSTRACT
Multi-hop Question Answering over Knowledge Graph (KGQA) aims to find the answer entities that are multiple hops away from the topic entities mentioned in a natural language question on a large-scale Knowledge Graph (KG).
To cope with the vast search space, existing work usually adopts a two-stage approach: it firstly retrieves a relatively small subgraph related to the question and then performs the reasoning on the subgraph to accurately find the answer entities.
Although these two stages are highly related, previous work employs very different technical solutions for developing the retrieval and reasoning models, neglecting their relatedness in task essence.
In this paper, we propose UniKGQA, a novel approach for multi-hop KGQA task, by unifying retrieval and reasoning in both model architecture and parameter learning.
For model architecture, UniKGQA consists of a semantic matching module based on a pre-trained language model (PLM) for question-relation semantic matching, and a matching information propagation module to propagate the matching information along the edges on KGs.
For parameter learning, we design a shared pre-training task based on question-relation matching for both retrieval and reasoning models, and then propose retrieval- and reasoning-oriented fine-tuning strategies.
Compared with previous studies, our approach is more unified, tightly relating the retrieval and reasoning stages.
Extensive experiments on three benchmark datasets have demonstrated the effectiveness of our method on the multi-hop KGQA task.
I NTRODUCTION
With the availability of large-scale knowledge graphs (KGs), such as Freebase (Bollacker et al., 2008) and Wikidata (Tanon et al., 2016), knowledge graph question answering (KGQA) has become an important research topic that aims to find the answer entities of natural language questions from
KGs.
Recent studies (Lan et al., 2021) mainly focus on multi-hop KGQA , a more complex scenario where sophisticated multi-hop reasoning over edges (or relations) is required to infer the correct answer on the KG.
We show an example in Figure 1(a).
Given the question “ Who is the wife of the nominee for The Jeff Probst Show ”, the task goal is to find a reasoning path from the topic entity “ The Jeff Probst Show ” to the answer entities “ Shelley Wright ” and “ Lisa Ann Russell ”.
Faced with the vast search space in large-scale KGs, previous work (Sun et al., 2018; 2019) typically adopts a retrieval -then- reasoning approach, which can achieve a good trade-off between accuracy and efficiency for multi-hop KGQA.
Generally, the retrieval stage aims to extract relevant triples from the large-scale KG to compose a relatively smaller question-relevant subgraph, while the reasoning stage focuses on accurately finding the answer entities from the retrieved subgraph.
Although the purposes of the two stages are different, both stages need to evaluate the semantic relevance of a candidate entity with respect to the question (for removal or reranking), which can be considered as a semantic matching problem in essence.
For measuring the entity relevance, relation-based features, either direct relations (Miller et al., 2016) or composite relation paths (Sun et al., 2018), have been shown to be particularly useful for building the semantic matching models.
As shown in Figure 1(a), given the question, it is key to identify the semantically matched relations and the composed relation path in the KG ( e.g., “ nominee → spouse ”) for finding the correct answer entities.
Since the two stages cope with different scales of search space on KGs ( e.g., millions v.s. thousands), they
TheJeff ProbstShow nominee
Jeff Probst
Shelley Wright
Lisa Ann Russell is_a
Talkshow
CBS Television Distribution distributedby
Whois the wifeofthe nomineefor TheJeffProbstShow ?
Lisa Whelchel nominee
Survivor spouse nominee is_a distributedby
Whois the wifeofthe nomineefor TheJeffProbstShow ?
TheJeff ProbstShow
Talkshow
CBS Television Distribution
Jeff Probst
Lisa Whelchel
Lisa Ann Russell
Shelley Wright
Survivor Θ 𝑝 Θ 𝑜 Γ 𝑝 Γ
𝑜
R e t r i e v a l
R ea s on i ng
Pre-training
Fine-tuning update by QRM
[Figure]
TV producer TV producer
[Figure]
parameters
[Figure]
usually adopt specific technical solutions: the former prefers more efficient methods focusing on the recall performance (Sun et al., 2018), while the latter prefers more capable methods for modeling fined-grained matching signals (He et al., 2021).
Considering the same essence for both stages, this work aims to push forwards the research on multihop KGQA by investigating the following problem: can we design a unified model architecture for both stages for deriving a better performance?
To develop a unified model architecture for multihop KGQA, a major merit is that we can tightly relate the two stages and enhance the sharing of relevance information.
Although the two stages are highly related, previous studies usually treat them separately in model learning: only the retrieved triples are passed from the retrieval stage to the reasoning stage, while the rest useful signal for semantic matching has been neglected in the pipeline framework.
Such an approach is likely to lead to sub-optimal or inferior performance, since multi-hop KGQA is a very challenging task, requiring elaborate solutions that sufficiently leverage various kinds of relevance information from the two stages.
However, there are two major issues to develop a unified model architecture for multi-hop KGQA:
(1) How to cope with very different scales of search space for the two stages?
(2) How to effectively share or transfer useful relevance information across the two stages?
For the first issue, instead of letting the same model architecture directly fitting very different data distributions, we propose a new subgraph form to reduce the node scale at the retrieval stage, namely abstract subgraph that is composed by merging the nodes with same relations from the KG (see Figure 1(b)).
For the second issue, based on the same model architecture, we design an effective learning approach for the two stages, so that we can share the same pre-trained parameters and further use the learned retrieval model to initialize the reasoning model (see Figure 1(c)).
To this end, in this paper, we propose UniKGQA, a unified model for multi-hop KGQA task.
Specifically, UniKGQA consists of a semantic matching module based on a PLM for question-relation semantic matching, and a matching information propagation module to propagate the matching information along the edges on KGs.
In order to learn these parameters, we design both pre-training ( i.e., question-relation matching) and fine-tuning ( i.e., retrieval- and reasoning-oriented learning) strategies based on the unified architecture.
Compared with previous work on multi-hop KQGA, our approach is more unified and simplified, tightly relating the retrieval and reasoning stages.
To our knowledge, it is the first work that unifies the retrieval and reasoning in both model architecture and learning for the multi-hop KGQA task.
To evaluate our approach, we conduct extensive experiments on three benchmark datasets.
On the simple dataset, MetaQA, we obtain a comparable results with state-of-the-arts methods.
On the difficult datasets, WebQSP and CWQ, we outperform existing state-of-the-arts baselines by a large margin ( e.g., 8.1% improvement of hits@1 on WebQSP and 2.0% improvement of hits@1 on CWQ).
P RELIMINARY
In this section, we introduce the notations that will be used throughout the paper and then
P L M
Question: 𝑞
Relation: r m
L i n e a r
L i n e a r 𝒉 𝒎 𝒉 𝑞 𝒎 𝑒 𝑖 ,𝑟 𝑚 ,𝑒 𝑗 𝑡− 𝒎 𝑒 1 ,𝑟 1 ,𝑒 (𝑡−1) 𝒎 𝑒 𝑛 ,𝑟 𝑛 ,𝑒 (𝑡−1) …
𝑁 𝑒 𝑠 𝑒 1 𝑡− 𝑠 𝑒 𝑛 𝑡− ෤𝒆 𝑡
S c
o r e upd a t e 𝒆 𝑡 𝒔 𝑡 𝑬 (𝑡−1) 𝑺 (𝑡−1) 𝑬 (𝑡) 𝑺 (𝑡)
Step 𝑡 −
Step 𝑡
L i n e a r L i n e a r
E m b e dd i n g upd a t e
S c
o r e upd a t e
Semantic Matching
Matching Information Propagation
Knowledge Graph (KG).
A knowledge graph typically consists of a set of triples, denoted by
G = {⟨ e, r, e ′ ⟩|
e, e ′ ∈ E , r ∈ R} , where E and R denote the entity set and relation set, respectively.
A triple ⟨ e, r, e ′ ⟩ describes the fact that a relation r exists between head entity e and tail entity e ′ .
Furthermore, we denote the set of neighborhood triples that an entity e belongs to by N e = {⟨ e, r, e ′ ⟩ ∈ G} ∪ {⟨ e ′ , r, e ⟩ ∈ G} .
Let r − 1 denote the inverse relation of r , and we can represent a triple ⟨ e, r, e ′ ⟩ by its inverse triple ⟨ e ′ , r − 1 , e ⟩ .
In this way, we can simplify the definition of the neighborhood triples for an entity e as N e = {⟨ e ′ , r, e ⟩ ∈ G} .
We further use E ∈ R d ×|E| and
R ∈ R d ×|R| to denote the embedding matrices for entities and relations in KG, respectively.
Multi-hop Knowledge Graph Question Answering (Multi-hop KGQA).
Given a natural language question q and a KG G , the task of KGQA aims to find answer entitie(s) to the question over the KG, denoted by the answer set A q ∈ E .
Following previous work (Sun et al., 2018; 2019), we assume that the entities mentioned in the question ( e.g., “The Jeff Probst Show” in Figure 1(a) are marked and linked with entities on KG, namely topic entities , denoted as T q ⊂ E .
In this work, we focus on solving the multi-hop KGQA task where the answer entities are multiple hops away from the topic entities over the KG.
Considering the trade-off between efficiency and accuracy, we follow existing work (Sun et al., 2018; 2019) that solves this task using a retrieval -then- reasoning framework.
In the two-stage framework, given a question q and topic entities T q , the retrieval model aims to retrieve a small subgraph G q from the large-scale input KG G , while the reasoning model searches answer entities A q by reasoning over the retrieved subgraph G q .
Abstract Subgraph.
Based on KGs, we further introduce the concept of abstract graph , which is derived based on the reduction from an original subgraph.
Specifically, given a subgraph related to question q , denoted as G q ⊂ G , we merge the tail entities from the triples with the same prefix ( i.e., the same head entity and relation: ⟨ e, r, ? ⟩ ), and then generate a corresponding abstract node (cid:101) e to represent the set of tail entities, so we have ˜ e = { e ′ |⟨ e, r, e ′ ⟩ ∈ G} .
Similarly, we can also perform the same operations on the head entities.
To unify the notations, we transform an original node that can’t be merged into an abstract node by creating a set including the node itself.
In this way, the corresponding abstract subgraph G q can be denoted as: (cid:101) G q = {⟨ ˜ e, r, ˜
e ′ ⟩|∃ e ∈ ˜
e, ∃ e ′ ∈ ˜
e ′ , ⟨ e, r, e ′ ⟩ ∈
G q } , where each node ˜ e is an abstract node representing a set of original nodes (one or multiple).
We present an illustrative example of the original subgraph and its abstract subgraph in Figure 1(a) and Figure 1(b).
A PPROACH
In this section, we present our proposed UniKGQA, that unifies the retrieval and reasoning for multi-hop KGQA.
The major novelty is that we introduce a unified model architecture for both stages (Section 3.1) and design an effective learning approach involving both specific pre-training and fine-tuning strategies (Section 3.2).
Next, we describe the two parts in details.
3. U NIFIED M ODEL A RCHITECTURE
We consider a general input form for both retrieval and reasoning, and develop the base architecture by integrating two major modules: (1) the semantic matching (SM) module that employs a PLM to perform the semantic matching between questions and relations; (2) the matching information propagation (MIP) module that propagates the semantic matching information on KGs.
We present the overview of the model architecture in Figure 2.
Next, we describe the three parts in details.
General Input Formulation.
In order to support both retrieval and reasoning stages, we consider a general form for evaluating entity relevance, where a question q and a subgraph G q of candidate entities are given.
For the retrieval stage, G q is an abstract subgraph that incorporates abstract nodes to merge entities from a same relation.
For the reasoning stage, G q is constructed based on the retrieved subgraph from the retrieval stage, without abstract nodes.
Such a general input formulation enables the development of unified model architecture for the two different stages.
In what follows, we will describe the approach in a general way, without considering specific stages.
Semantic Matching (SM).
The SM module aims to produce the semantic matching features between the question q and a triple ⟨ e ′ , r, e ⟩ from the given subgraph G q .
Considering the excellent modeling capacity of the PLMs, we leverage the PLM to produce text encoding as the representations of question q and relation r .
Specifically, we first utilize the PLM to encode the texts of q and r , and employ the output representation of the [CLS] token as their representations:
[Equation]
Based on h q and h r , inspired by the NSM model (He et al., 2021), we obtain the vector capturing semantic matching features m ( t ) ⟨ e ′ ,r,e ⟩ between question q and triple ⟨ e ′ , r, e ⟩ at the t -th step by adopting corresponding projection layers:
[Equation]
where m ( t ) ⟨ e ′ ,r,e ⟩ ∈ R d , W ( t ) Q , W ( t ) R ∈ R h × d are parameters of the t -step projection layers, h , d are the hidden dimensions of PLM and the feature vector, respectively, σ is the sigmoid activation function, and ⊙ is the hadamard product.
Matching Information Propagation (MIP).
Based on the generated semantic matching features, the MIP module firstly aggregates them to update the entity representation and then utilizes it to obtain the entity match score.
To initialize the match scores, given a question q and a subgraph
G q , for each entity e i ∈ G q , we set the match score between q and e i as follows: s (1) e i = 1 if e i is a topic entity and s (1) e i =
otherwise.
At the t -th step, we utilize the match scores of the head entities computed at the last step s ( t − 1) e ′ as the weights and aggregate the matching features from neighboring triples to obtain the representation of the tail entities:
[Equation]
where e ( t ) ∈
R
d is the representation of the entity e in the t -th step, and the W ( t ) e ∈ R 2 d × d is a learnable matrix.
At the first step, since there are no matching scores, following the NSM He et al.
(2021) model, we directly aggregate the representations of its one-hop relations as the entity representation: e (1)
=
σ ( (cid:80) ⟨ e ′ ,r,e ⟩∈N e r · W E ) , where the W E ∈ R 2 d × d is a learnable matrix.
Based on the representation of all entities E ( t ) ∈ R d × n , we update their entity match scores using the softmax function as:
[Equation]
where v ∈ R d is a learnable vector.
After T -step iterations, we can obtain the final entity match scores s ( T ) , which is a probability distribution over all entities in the subgraph G q .
These match scores can be leveraged to measure the possibilities of the entities being the answers to the given question q , and will be used in both the retrieval and reasoning stages.
3. M ODEL T RAINING
In our approach, we have both the retrieval model and the reasoning model for the two stages of multi-hop KGQA.
Since the two models adopt the same architecture, we introduce Θ and Γ to denote the model parameters that are used for retrieval and reasoning stages, respectively.
As shown in Section 3.1, our architecture contains two groups of parameters, namely the underlying PLM and the other parameters for matching and propagation.
Thus, Θ and Γ can be decomposed as: Θ = { Θ p , Θ o } and Γ = { Γ p , Γ o } , where the subscripts p and o denote the PLM parameters and the other parameters in our architecture, respectively.
In order to learn these parameters, we design both pre-training ( i.e., question-relation matching) and fine-tuning ( i.e., retrieval- and reasoning-oriented learning) strategies based on the unified architecture.
Next, we describe the model training approach.
Pre-training with Question-Relation Matching (QRM).
For pre-training, we mainly focus on learning the parameters of the underlying PLMs ( i.e., Θ p and Γ p ).
In implementation, we let the two models share the same copy of PLM parameters, i.e., Θ p =
Γ p .
As shown in Section 3.1, a basic capacity of the semantic matching module is to model the relevance between a question and a single relation (Eq. 2), which is based on the text encoding from the underlying PLM.
Therefore, we design a contrastive pre-training task based on question-relation matching.
Specifically, we adopt the contrastive leaning objective (Hadsell et al., 2006) to align the representations of relevant question-relation pairs while pushing apart others.
To collect the relevant question-relation pairs, given an example consisting of a question q , the topic entities T q and answer entities
A q , we extract all the shortest paths between the T q and A q from the entire KG and regard all of the relations within these paths as relevant to q , denoted as R + .
In this way, we can obtain a number of weaksupervised examples.
During pre-training, for each question q , we randomly sample a relevant relation r + ∈ R + , and utilize a contrastive learning loss for pre-training:
[Equation]
where τ is a temperature hyperparameter, r − i is a randomly sampled negative relation, and sim ( q , r ) is the cosine similarity, and
q , r is the question and relation encoded by the PLM from the SM module (Eq. 1).
In this way, the question-relation matching capacity will be enhanced by pretraining the PLM parameters.
Note that the PLM parameters will be fixed after pre-training.
Fine-tuning for Retrieval on Abstract Subgraphs (RAS).
After pre-training, we firstly fine-tune the entire model for learning the parameters Θ o according to the retrieval task.
Recall that we transform the subgraph into a form of abstract subgraphs , where abstract nodes are incorporated for merging entities from the same relation.
Since our MIP module (Section 3.1) can produce the matching scores s A of nodes in a subgraph (Eq. 4), where the subscript A denotes that nodes are from an abstract subgraph.
Furthermore, we utilize the labeled answers to get the ground-truth vectors, denoted by s ∗ A .
We set an abstract node in s ∗ A to 1 if it contains the answer entity.
Then we minimize the KL divergence between the learned and ground-truth matching score vectors as:
[Equation]
After fine-tuning with the RAS loss, the retrieval model can be effectively learned.
We further utilize it to retrieve the subgraph for the given question q , by selecting the top- K ranked nodes according to their match scores.
Note that only the node within a reasonable distance to the topic entities will be selected into the subgraph, which ensures a relatively small yet relevant subgraph G q for the subsequent reasoning stage to find answer entities.
Fine-tuning for Reasoning on Retrieved Subgraphs (RRS).
After fine-tuning the retrieval model, we continue to fine-tune the reasoning model by learning the parameters Γ o .
With the fine-tuned retrieval model, we can obtain a smaller subgraph G q for each question q .
In the reasoning stage, we focus on performing accurate reasoning to find the answer entities, so that we recover the original nodes in the abstract nodes and the original relations among them.
Since the retrieval and reasoning stages are highly dependent, we first initialize the parameters of the reasoning model with those from the retrieval model:
Θ o → Γ o .
Then, following Eq. 4, we employ a similar approach to fitting the
[Table]
[Table]
learned matching scores (denoted by s R ) with the ground-truth vectors (denoted by s ∗ R ) according to the KL loss:
[Equation]
where the subscript R denotes that the nodes come from a retrieved subgraph.
After fine-tuning with the RRS loss, we can utilize the learned reasoning model to select the top- n ranked entities as the answer list according to the match scores.
As shown in Figure 1(c), the overall procedure of training UniKGQA is composed by: (1) pretraining Θ p with question-relation matching; (2) fixing Θ p and fine-tuning Θ o for retrieval on abstract subgraphs; and (3) fixing the Γ p initialized with Θ p and fine-tuning Γ o for reasoning on retrieved subgraphs.
Our work provides a novel unified model for the retrieval and reasoning stages to share the reasoning capacity.
In Table 1, we summarize the differences between our method and several popular methods for multi-hop KGQA, including GraphfNet (Sun et al., 2018), PullNet (Sun et al., 2019), NSM (He et al., 2021), and SR+NSM (Zhang et al., 2022).
As we can see, existing methods usually adopt different models for the retrieval and reasoning stages, while our approach is more unified.
As a major benefit, the information between the two stages can be effectively shared and reused: we initialize the reasoning model by the learned retrieval model.
E XPERIMENT 4. E XPERIMENTAL S ETTING
Datasets.
Following existing work on multi-hop KGQA (Sun et al., 2018; 2019;
He et al., 2021;
Zhang et al., 2022), we adopt three benchmark datasets, namely MetaQA (Zhang et al., 2018),
WebQuestionsSP (WebQSP) (Zhang et al., 2018)
(Yih et al., 2015), and Complex WebQuestions 1.
(CWQ) (Talmor & Berant, 2018) for evaluating our model.
Table 2 shows the statistics of the three datasets.
Since previous work has achieved nearly full scores on MetaQA, WebQSP and CWQ are our primarily evaluated datasets.
We present a detailed description of these datasets in Appendix A.
Evaluation Protocol.
For the retrieval performance, we follow Zhang et al.
(2022) that evaluate the models by the answer coverage rate (%).
It is the proportion of questions whose retrieved subgraphs contain at least one answer.
For the reasoning performance, we follow Sun et al.
(2018; 2019) that regard the reasoning as a ranking task for evaluation.
Given each test question, we rely on the predictive probabilities from the evaluated model to rank all candidate entities, and then evaluate whether the top-1 answer is correct with Hits@1 .
Since a question may correspond to multiple answers, we also compute the widely-used F1 score.
Baselines.
We consider the following baselines for performance comparison: (1) reasoning augmented methods: KV-Mem (Miller et al., 2016), GraftNet (Sun et al., 2018), EmbedKGQA (Saxena et al., 2020), NSM (He et al., 2021), TransferNet (Shi et al., 2021); (2) retrieval augmented methods:
PullNet (Sun et al., 2019), SR+NSM (Zhang et al., 2022), SR+NSM+E2E (Zhang et al., 2022).
We present a detailed description of these baselines in Appendix B.
4. E VALUATION R ESULTS
Table 3 shows the results of different methods on 5 multi-hop KGQA datasets.
It can be seen that:
First, most baselines perform very well on the three MetaQA datasets (even Hit@1 reaches 100%).
This is possible because these datasets are based on a few hand-crafted question templates and have
[Table]
only nine relation types for the given KG.
It is easy for the model to capture the semantics between the questions and relations to perform reasoning.
To further examine this, we conduct an extra oneshot experiment on MetaQA datasets and present the details in Appendix E. Second, TransferNet performs better than GraftNet, EmbedKGQA, and NSM under the same retrieval method.
It attends to question words to compute the scores of relations and transfers entity scores w.r.t.
relation scores.
Such a way can effectively capture the question-path matching semantics.
Besides, SR+NSM and
SR+NSM+E2E outperform NSM and PullNet in a large margin.
The reason is that they both pretrain a PLM-based relation paths retriever to improve the retrieval performance and then reduce the difficulty of the later reasoning stage.
Finally, on WebQSP and CWQ, our proposed UniKGQA is substantially better than all other competitive baselines.
Unlike other baselines that rely on independent models to perform retrieval and reasoning, our approach can utilize a unified architecture to accomplish the two tasks.
Such a unified architecture can pre-learn the essential capability of question-relation semantic matching for both retrieval and reasoning stages, and is also capable of effectively transferring relevance information from the retrieval stage to the reasoning stage, i.e., initializing the reasoning model with the retrieval model.
In our approach, we fix the parameters of the pre-trained PLM encoder for efficiency.
Actually, updating its parameters can further improve our performance.
Such a way provides a choice for efficiency or effectiveness when employing our approach in real-world applications.
Here, we study it by proposing two variants of our UniKGQA: (1) w QU that updates the parameters of the PLM encoder only when encoding questions; (2) w QU, RU that updates the parameters of the PLM encoder both when encoding questions and relations.
Indeed, both variants can further improve the performance of our UniKGQA.
And only updating the PLM encoder when question encoding can obtain a comparable even better performance to update both.
The reason is that updating the PLM encoder when question and relation encoding would make it easier to overfit the downstream task.
Therefore, updating the PLM encoder when question encoding seems to be a promising strategy of our UniKGQA, as it can achieve a better performance with additional affordable computation cost.
4. F URTHER A NALYSIS
Retrieval Evaluation.
We evaluate the effectiveness of our UniKGQA to retrieve a smaller but more accurate answer-recall subgraph for a given question.
Following the evaluation principles of
SR (Zhang et al., 2022), we measure such a capacity from three aspects: the direct subgraph size, answer coverage rate, and the final QA performance.
Concretely, we first compare UniKGQA with
SR (Zhang et al., 2022) and PPR-based heuristic retrieval method (Sun et al., 2018) based on the answer coverage rates curves w.r.t.
the number of graph nodes.
Then, we compare UniKGQA with
SR+NSM (Zhang et al., 2022) and PPR+NSM (He et al., 2021)
based on their final QA performance.
To further study the effectiveness of our approach, we add an extra variant of our UniKGQA, namely
UniKGQA+NSM, which relies on UniKGQA for retrieval while NSM for performing reasoning.
Figure 3(a) and Figure 3(b) show the comparison results of the above methods.
As we can see,
[Figure]
under the same size of retrieved subgraphs, UniKGQA and SR have significantly larger answer coverage rates than PPR.
It demonstrates the effectiveness and necessity of training a learnable retrieval module.
Besides, although the curves of UniKGQA and SR are very similar, our UniKGQA can achieve a better final reasoning performance than SR+NSM.
The reason is that UniKGQA can transfer the relevance information from the retrieval stage to the reasoning stage based on the unified architecture, learning a more effective reasoning model.
Such a reason can be also inferred by comparing our UniKGQA with UniKGQA+NSM.
[Table]
Ablation Study.
Our UniKGQA contains two important training strategies to improve the performance: (1) pre-training with question-relation matching; (2) initializing the parameters of the reasoning model with the retrieval model.
Here, we conduct the ablation study to verify their effectiveness.
We propose three variants as: (1) w/o Pre removing the pre-training procedure; (2) w/o Trans removing the initialization with the parameters of retrieval model; (3) w/o Pre, Trans removing both the pre-training and initialization procedures.
We show the results in Table 4.
We can see that all these variants underperform our UniKGQA, which indicates that both pre-training and initializing the parameters of the reasoning model with the retrieval model are important for the final performance.
Besides, such an observation also verifies that our UniKGQA is indeed capable of inheriting the knowledge from the prior tasks to improve the final performance.
Fine-tuning Efficiency.
As our UniKGQA model can inherit the learned knowledge from the pretraining stage and the retrieval task, it can be quickly adapted into downstream reasoning tasks.
In this way, we can perform a more efficient fine-tuning on the reasoning task with few fine-tuning steps.
To explore it, we report the performance changes of our UniKGQA and a strong baseline
NSM w.r.t.
the number of fine-tuning epochs based on the same retrieval subgraphs.
The results are presented in Figure 3(c).
First, we can see that before fine-tuning ( i.e., when the epoch is zero), our
UniKGQA has achieved a comparable performance as the best results of NSM at the last epoch.
It indicates that the reasoning model has successfully inherited the knowledge from prior tasks based on the parameters initialized by the retrieval model.
After fine-tuning with two epochs, our UniKGQA has already converged into a good performance.
It verifies that our model can be fine-tuned in an efficient way with very few epochs.
To further study our UniKGQA model, we conduct parameter sensitivity analysis w.r.t.
pre-training steps, hidden dimensions, and the number of retrieved nodes
K , shown in Appendix H.
R ELATED W ORK
Multi-hop Knowledge Graph Question Answering.
Multi-hop KGQA aims to seek answer entities which are multiple hops away from the topic entities in a large-scale KG.
Considering the efficiency and accuracy, existing work (Sun et al., 2018; 2019; Zhang et al., 2022) typically first retrieves a question-relevant subgraph to reduce the search space and then performs multi-hop reasoning on it.
Such a retrieval-and-reasoning paradigm has shown superiority over directly reasoning on the entire KG (Chen et al., 2019; Saxena et al., 2020).
The retrieval stage focuses on extracting a relatively small subgraph involving the answer entities.
A commonly-used approach is to collect entities with nearer hops around the topic entities to compose the subgraph and filter the ones with low Personalized PageRank scores to reduce the graph size (Sun et al., 2018;
He et al., 2021).
Despite the simplicity, such a way neglects the question semantics, limiting the retrieval efficiency and accuracy.
To address it, several work (Sun et al., 2019; Zhang et al., 2022) devises retrievers based on semantic matching using neural networks ( e.g., LSTMs or
PLMs).
Starting from the topic entities, these retrievers iteratively measure the semantic relevance between the question and neighbouring entities or relations, and add proper ones into the subgraph.
In this way, a smaller but more question-relevant subgraph would be constructed.
The reasoning stage aims to accurately find the answer entities of the given question by walking along the relations starting from the topic entities.
Early work (Miller et al., 2016; Sun et al., 2018; 2019) relies on the special network architectures ( e.g., Key-Value Memory Network or Graph Convolution Network) to model the multi-hop reasoning process.
Recent work further enhances the reasoning capacity of the above networks from the perspectives of intermediate supervision signals (He et al., 2021), knowledge transferring (Shi et al., 2021), etc.
However, all these methods design different model architectures and training methods for the retrieval and reasoning stages, respectively, neglecting the similarity and intrinsic connection of the two stages.
Recently, some work parses the question into structured query language ( e.g., SPARQL)
Lan et al.
(2021); Das et al.
; Huang et al.
and execute it by a query engine to get answers.
In this way, the encoder-decoder architecture ( i.e., T5 Raffel et al.
(2020)) is generally adopted to produce the structured queries, where the annotated structured queries are also required for training.
Dense Retrieval.
Given a query, the dense retrieval task aims to select relevant documents from a large-scale document pool.
Different from the traditional sparse term-based retrieval methods, e.g., TF-IDF (Chen et al., 2017) and BM25 (Robertson & Zaragoza, 2009), dense retrieval methods (Karpukhin et al., 2020; Guu et al., 2020; Sachan et al., 2021) rely on a bi-encoder architecture to map queries and documents into low-dimensional dense vectors.
Then their relevance scores can be measured using vector distance metrics ( e.g., cosine similarity), which supports efficient approximate nearest neighbour (ANN) search algorithms.
In multi-hop KGQA, starting from the topic entities, we need to select the relevant neighboring triples from a large-scale KG, to induce a path to reach the answer entities, which can be seen as a constrained dense retrieval task.
Therefore, in this work, we also incorporate a bi-encoder architecture to map questions and relations into dense vectors, and then perform retrieval or reasoning based on their vector distances.
C ONCLUSION
In this work, we proposed a novel approach UniKGQA for the multi-hop KGQA task.
Unlike previous methods, UniKGQA introduced a unified model architecture based on PLMs for both retrieval and reasoning stages, which consists of the semantic matching module and the matching information propagation module.
To cope with the different scales of search space in the two stages, we proposed to generate abstract subgraphs for the retrieval stage, which can significantly reduce the number of nodes to be searched.
Furthermore, we designed an effective model learning method with both pre-training ( i.e., question-relation matching) and fine-tuning ( i.e., retrieval- and reasoning-oriented learning) strategies based on the unified architecture.
With the unified architecture, the proposed learning method can effectively enhance the sharing and transferring of relevance information between the two stages.
We conducted extensive experiments on three benchmark datasets, and the experiment results show that our proposed unified model outperforms the competitive methods, especially on more challenging datasets ( i.e., WebQSP, CWQ) Lewis et al.
(2020); Raffel et al.
A D ATASETS
We adopt three widely-used multi-hop KGQA datasets in this work:
• MetaQA (Zhang et al., 2018) contains more than 400k questions in the domain of movie and the answer entities are up to 3 hops away from the topic entities.
According to the number of hops, this dataset is split into three sub-datasets, i.e., MetaQA-1hop, MetaQA-2hop, and MetaQA-3hop.
• WebQuestionsSP (WebQSP)
(Yih et al., 2015) contains 4,737 questions and the answer entities require up to 2-hop reasoning on the KG Freebase (Bollacker et al., 2008).
We use the same train/valid/test splits as GraftNet (Sun et al., 2018).
• Complex WebQuestions 1.1 (CWQ) (Talmor & Berant, 2018) is constructed based on WebQSP by extending the question entities or adding constraints to answers.
These questions require up to 4-hop reasoning on the KG Freebase (Bollacker et al., 2008).
Existing work has demonstrated that the training data for MetaQA is more than sufficient (Shi et al., 2021;
He et al., 2021), hence all the comparison methods in our experiments can achieve very high performance.
We conduct further analysis of the three MetaQA datasets about the number of templates, the average number of training cases per template, and the number of relations used
for
constructing questions, and show them in Table 5.
In summary, more training cases and simpler questions make the MetaQA easier to be solved.
B B ASELINES
We consider the following baseline methods for performance comparison:
• KV-Mem (Miller et al., 2016) maintains a key-value memory table to store KG facts, and conducts multi-hop reasoning by performing iterative read operations on the memory.
• GraftNet (Sun et al., 2018) first retrieves the question-relevant subgraph and text sentences from the KG and Wikipedia respectively with a heuristic method.
Then it adopts a graph neural network to perform multi-hop reasoning on a heterogeneous graph built upon the subgraph and text sentences.
• PullNet (Sun et al., 2019) trains a graph retrieval model composed of a LSTM and a graph neural network instead of the heuristic way in GraftNet for the retrieval task, and then conducts multi-hop reasoning with GraftNet.
• EmbedKGQA (Saxena et al., 2020) reformulates the multi-hop reasoning of GraftNet as a link prediction task by matching pre-trained entity embeddings with question representations from a PLM.
• NSM
(He et al., 2021) first conducts retrieval following GraftNet and then adapt the neural state machine (Hudson & Manning, 2019) used in visual reasoning for multi-hop reasoning on the KG.
• TransferNet (Shi et al., 2021) first conducts retrieval following GraftNet and then performs the multi-hop reasoning on a KG or a text-formed relation graph in a transparent framework.
The reasoning model consists of a PLM for question encoding and a graph neural network for updating the relevance scores between entities and the question.
• SR+NSM (Zhang et al., 2022) first learns a PLM-based relation path retriever to conduct effectively retrieval and then leverages NSM reasoner to perform multi-hop reasoning.
• SR+NSM+E2E (Zhang et al., 2022) further fine-tunes the SR+NSM by an end-to-end way.
[Figure]
C K NOWLEDGE G RAPH P REPROCESSING D ETAILS
We preprocess the full Freebase following existing work (Sun et al., 2018;
He et al., 2021).
For
MetaQA, we directly use the subset of WikiMovies provided by the datasets, and the size is about 134,741.
For WebQSP and CWQ datasets, we set the max hops of retrieval and reasoning as two and four for the WebQSP and CWQ, respectively.
Based on the topic entities labeled in original datasets, we reserve the neighborhood subgraph consisting of entities within the four hops of the topic entities for each sample.
After such simple preprocessing, the size of KG we used is 147,748,092 for
WebQSP and 202,358,414 for CWQ.
Based on the preprocessed KG, we conduct the retrieval and reasoning using our proposed approach.
D I MPLEMENTATION D ETAILS .
During pre-training, we collect question-relation pairs based on the shortest relation paths between topic entities and answer entities, and then use these pairs to pre-train the RoBERTa (Liu et al., 2019) model with the contrastive learning objective.
We set the temperature τ as 0.05, and select the best model by evaluating Hits@1 on the validation set.
For retrieval and reasoning, we initialize the
PLM module of our UniKGQA model with the contrastive learning pre-trained RoBERTa, and set the hidden size of other linear layers as 768.
We optimize parameters with the AdamW optimizer, where the learning rate is 0.00001 for the PLM module, and 0.0005 for other parameters.
The batch size is set to 40.
The reasoning step is set to 4 for CWQ dataset, and 3 for other datasets.
We preprocess the KGs for each datasets following existing work (Sun et al., 2018;
He et al., 2021).
E O NE - SHOT EXPERIMENT FOR M ETA QA
[Table]
Since the samples in MetaQA are more than sufficient, all the comparison methods in our experiments have achieved very high performance.
For example, our method and previous work ( e.g.,
TransferNet and NSM) have achieved more than 98% Hits@1 on MetaQA, which shows that this dataset’s performance may have been saturated.
To examine this assumption, we consider conducting few-shot experiments to verify the performance of different methods.
Specially, we follow the
NSM paper He et al.
(2021) that conducts the one-shot experiment.
We randomly sample just one training case for each question template from the original training set, to form a one-shot training dataset.
In this way, the numbers of training samples for MetaQA-1, MetaQA-2, and MetaQAare 161, 210, and 150, respectively.
We evaluate the performance of our approach and some strong baselines ( i.e., TrasnferNet and NSM) trained with this new training dataset.
As shown in Table 6, our method can consistently outperform these baselines in all three subsets.
F A BLATION S TUDY OF OUR U NIFIED M ODEL A RCHITECTURE
[Table]
The unified model architecture is the key of our approach.
Once the unified model architecture is removed, it would be hard to share the question-relation matching capability enhanced by pre-training in retrieval and reasoning stages, and also hard to transfer the relevance information for multi-hop
KGQA learned in the retrieval stage to the reasoning stage.
To verify it, we conduct an extra ablation study to explore the effect of only adopting the unified model architecture as the reasoning model or the retrieval model.
We select the existing strong retrieval model ( i
[Table]
e., SR) and reasoning model ( i.e., NSM), and compare the performance when integrated with our UniKGQA.
As we can see in
Table 7, all the variants underperform our UniKGQA.
It indicates that the unified model used in the retrieval and reasoning stages simultaneously is indeed the key reason for improvement.
G A NALYSIS OF THE P RE - TRAINING S TRATEGY
[Table]
We conduct the analysis experiments to investigate how the pre-training strategy (Pre) affects the performance with or without updating the PLM (QU).
We show the results in Table 8.
Once removing the pre-training strategy, the model performance would drop 10.4% (2.1%) in WebQSP and 5.1% (3.3%) in CWQ when fixing (not fixing) the PLM.
It indicates that the pre-training strategy is an important component of our approach.
After pre-training, the PLM can be fixed for more efficient parameters optimization during fine-tuning.
H P ARAMETER S ENSITIVITY A NALYSIS
Pre-training Steps Although the pre-training strategy has shown effective in our approach, too many pre-training steps will be time-consuming and costly.
Here, we investigate the performance with respect to varying pre-training steps.
As shown in Figure 4(a), we can see that our method can reach the best performance with only few pre-training steps ( i.e., 2800) compared with the best baseline TransferNet.
It shows that our approach does not require too many steps for pre-training.
Instead, we can see that too many pre-training steps will hurt the model performance.
The reason may be that the PLM has overfit into the contrastive learning objective.
Parameter Tuning.
In our approach, we have two hyper-parameters required to tune: (1) the hidden size of linear layers d and (2) the number of retrieved nodes K .
Here, we tune the d amongst { 64, 128, 256, 512, 768, 1024 } and K amongst { 1, 5, 10, 15, 20 } .
We show the results in Figure 4(b) and Figure 4(c) compared with the best results for the reasoning stage and the retrieval stage.
Since
K is a consistent hyper-parameter in the UniKGQA and SR, we also describe the various results of SR with different K to give a fair comparison.
First, we can see that our method is robust to different hidden sizes, as the performance is consistently nearby 77.0.
As the PLM adopts 768 as the embedding size, we can see 768 is also slightly better than other numbers.
Besides, we can see that with the increase of K , the answer coverage rate also improves consistently.
However, when K increases to 15 or even 20, the performance gain becomes relatively small.
It means that the retrieved subgraphs are likely saturated, and further increasing K could only bring marginal improvement.