Question:
In the paper 'Making Large Language Models Perform Better in Knowledge Graph Completion,' which of the following approaches are proposed to enhance the ability of large language models (LLMs) to complete missing links in knowledge graphs?
A. Fine-tuning the LLM on domain-specific corpora to incorporate domain knowledge that might not be represented in the original pretraining data.
B. Applying transfer learning from existing large-scale knowledge graph completion models to improve LLM performance in structured knowledge tasks.
C. Employing an augmented training approach that incorporates both the textual descriptions and structural information of the knowledge graph to help the LLM learn complex relationships.
D. Using a specialized attention mechanism that focuses on relevant entities and relations in the knowledge graph during the inference process.

Answer: ACD

To address these issues, we take a strategic step to LLM-based KGC, aiming to explore how to incorporate the KG structural information into the LLMs and enable structure-aware reasoning. Our initial focus involves transferring the existing LLM paradigms such as in-context learning (ICL) [9] and instruction tuning (IT) [24] to a structure-aware context. We propose a structure-aware ICL method and a structure-aware IT method as the base models, focusing on integrating the KG structural information into LLM through text form. Such an approach benefits from the fact that specific textual information exists about entities and relationships in KG so that we can use the text to represent this knowledge as complementary background information, expecting that LLMs can learn the local structural information in KG through textual prompts. But they also have the obvious disadvantage that there is a clear semantic divide between structural and textual information. The textual descriptions in the expanded prompt still fail to fully exploit the structural information in the complex KG.

Additionally, we propose a novel Knowledge Prefix Adapter (KoPA) to make LLMs a better knowledge reasoner, leveraging structural embedding pre-training to capture the KG structural information. Then KoPA transforms the structural embeddings into textual embedding space by a knowledge prefix adapter and obtains several virtual knowledge tokens. These tokens, acting as prefixes in the input prompt sequence, direct the instruction-tuning process, providing valuable supplementary input triple information. This mapping of structural embeddings to textual form provides auxiliary information to input triples. Besides, we conduct comprehensive analysis and experiments, highlighting the remarkable performance and transferability of KoPA.

Making Large Language Models Perform Better in
Knowledge Graph Completion
Yichi Zhang1,2, Zhuo Chen1,2, Lingbing Guo1,2, Yajing Xu1,2, Wen Zhang1,2 and Huajun Chen1,2,3∗
1Zhejiang University
2Zhejiang University-Ant Group Joint Laboratory of Knowledge Graph
3Alibaba-Zhejiang University Joint Institute of Frontier Technology
Hang Zhou, China
{zhangyichi2022,huajunsir}@zju.edu.cn
ABSTRACT
Large language model (LLM) based knowledge graph completion
(KGC) aims to predict the missing triples in the KGs with LLMs.
However, research about LLM-based KGC fails to sufficiently har-
ness LLMs’ inference proficiencies, overlooking critical structural
information integral to KGs. In this paper, we explore methods to
incorporate structural information into the LLMs, with the over-
arching goal of facilitating structure-aware reasoning. We first
discuss on the existing LLM paradigms like in-context learning and
instruction tuning, proposing basic structural information injection
approaches. Then we propose a Knowledge Prefix Adapter (KoPA)
to fulfill this stated goal. The KoPA uses a structural pre-training
phase to comprehend the intricate entities and relations within KGs,
representing them as structural embeddings. Then KoPA communi-
cates such cross-modal structural information understanding
to the LLMs through a knowledge prefix adapter which projects
the structural embeddings into the textual space and obtains virtual
knowledge tokens positioned as a prefix of the input prompt. We
conduct comprehensive experiments and provide incisive analysis
concerning how the introduction of cross-modal structural informa-
tion would be better for LLM’s factual knowledge reasoning ability.
Our code and data are available at https://github.com/zjukg/KoPA.
CCS CONCEPTS
• Information systems →Information integration; • Computing
methodologies →Natural language generation; Semantic networks.
KEYWORDS
Knowledge Graphs, Knowledge Graph Completion, Large Language
Models, Graph-text Fusion, Cross-modal Adapter
∗Corresponding author.
Permission to make digital or hard copies of all or part of this work for personal or
classroom use is granted without fee provided that copies are not made or distributed
for profit or commercial advantage and that copies bear this notice and the full citation
on the first page. Copyrights for components of this work owned by others than the
author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or
republish, to post on servers or to redistribute to lists, requires prior specific permission
and/or a fee. Request permissions from permissions@acm.org.
Preprint, 2024,
© 2024 Copyright held by the owner/author(s). Publication rights licensed to ACM.
ACM ISBN 978-x-xxxx-xxxx-x/YY/MM
https://doi.org/10.1145/nnnnnnn.nnnnnnn
Figure 1: A simple case of LLM-based KGC. Useful struc-
tural information that describes the surrounding informa-
tion about the entities can serve as auxiliary prompts and
guide the LLM to make correct decisions.
1
INTRODUCTION
Knowledge graphs (KGs) [2] are the quintessential wisdom essence
and key infrastructure of modern AI. KGs represent and store real-
world knowledge in the triple form: (head entity, relation, tail entity).
This structured format of knowledge triples offers significant advan-
tages across many AI fields such as recommendation systems [30],
question answering [42], and fault analysis [7]. However, there is a
pertinent drawback of KGs, whether manually curated or automat-
ically extracted. Their scope is restricted to observed knowledge,
resulting in an incomplete representation riddled with unobserved
or missing triples. This phenomenon motivates knowledge graph
completion (KGC), which aims to predict the missing triples and
further enhance the given KG.
Existing KGC approaches can be divided into two categories:
methods based on embeddings [3] and pre-train language models
(PLM) [40]. Recently, as large language models (LLMs) [23, 46] show
outperforming capabilities [24], this field has recently been revo-
lutionized by LLMs. Some works [41] make the first step towards
LLM-based KGC, employing existing paradigms like zero-shot rea-
soning (ZSR) [4] and instruction tuning (IT) [24] to accomplish
the KGC task. However, such approaches transform the KGC task
into a text-based prediction of individual triples, leading to specific
fundamental problems. LLMs lack the depth and precision of factual
knowledge which always results in the hallucination [48] problem
of LLMs. Besides, the structural intricacies of KGs such as sub-
graph structure, relational patterns, and relative entities/relations
arXiv:2310.06671v2  [cs.CL]  14 Apr 2024
Preprint, 2024,
Yichi Zhang et al.
are often overlooked. This richly non-textual structured infor-
mation, if properly incorporated, can significantly enhance the
LLM’s understanding and representation of KGs. Figure 1 presents
an intuitive view of the importance of structural information for
LLM reasoning. However, this is neglected by vanilla ZSR and IT
approaches [41] because each input typically only includes a single
input triple, leading to potential wastage of the structural informa-
tion inherent in the KG. Such an approach fails to equip the LLMs
with the awareness of the KG structure.
To address these issues, we take a strategic step to LLM-based
KGC, aiming to explore how to incorporate the KG structural infor-
mation into the LLMs and enable structure-aware reasoning. Our
initial focus involves transferring the existing LLM paradigms such
as in-context learning (ICL) [9] and instruction tuning (IT) [24] to a
structure-aware context. We propose a structure-aware ICL method
and a structure-aware IT method as the base models, focusing on
integrating the KG structural information into LLM through text
form. Such an approach benefits from the fact that specific textual
information exists about entities and relationships in KG so that
we can use the text to represent this knowledge as complementary
background information, expecting that LLMs can learn the local
structural information in KG through textual prompts. But they also
have the obvious disadvantage that there is a clear semantic divide
between structural and textual information. The textual descrip-
tions in the expanded prompt still fail to fully exploit the structural
information in the complex KG.
Additionally, we propose a novel Knowledge Prefix Adapter
(KoPA) approach to make LLMs a better knowledge reasoner, lever-
aging structural embedding pre-training to capture the KG
structural information. Then KoPA transforms the structural
embeddings into textual embedding space by a knowledge prefix
adapter and obtains several virtual knowledge tokens. These to-
kens, acting as prefixes in the input prompt sequence, direct
the instruction-tuning process, providing valuable supplementary
input triple information. This mapping of structural embeddings to
textual form provides auxiliary information to input triples. Besides,
we conduct comprehensive analysis and experiments, highlight-
ing the remarkable performance and transferability of KoPA. In
summary, our contribution is three-folded:
• Extending the existing LLM paradigms. We are the first
extensive investigation of LLM-based KGC methods, specifically
by incorporating KG structural information to enhance the rea-
soning ability of LLMs. We discuss the pipeline to adapt the
existing LLM paradigms like ICL and IT to a structure-aware
setting for KGC using addtional textual prompts.
• Designing new cross-modal LLM paradigm. We further pro-
pose a knowledge prefix adapter (KoPA) that effectively inte-
grates pre-trained KG structural embeddings with LLMs. KoPA
fosters comprehensive cross-modal interactions between tex-
tual embeddings from LLMs and structural embeddings sourced
from KGs to enhance LLM’s reasoning ability.
• Comprehensive evaluation. We conduct extensive experi-
ments on three public benchmarks and evaluate the KGC per-
formance of all the structure-aware methods proposed by us
with adequate baseline comparison with further exploration of
the transfer ability and knowledge retention degree.
2
RELATED WORKS
2.1
Knowledge Graph Completion
Knowledge graph completion (KGC) [37] is an important topic in
the KG community, aiming to mine unobserved triples in a given
KG. KGC contains several sub-tasks such as triple classification
[3], entity prediction [3]. The common point among KGC tasks is
to establish an effective mechanism to measure the plausibility of
the triples. The mainstream KGC methods can be divided into two
categories: embedding-based and PLM-based methods. Embedding-
based methods [3, 31, 34, 38] are designed to embed the entities
and relations of KGs into continuous representation spaces. These
approaches make full use of structural information from the KGs
to model triple plausibility with a well-designed score function and
learn the entity/relation embeddings in a self-supervised manner.
Moreover, PLM-based methods consider KGC as text-based tasks
by fine-tuning pre-trained language models [8]. The short textual
descriptions are organized as an input sequence and encoded by the
PLMs. KG-BERT [40] is the first PLM-based method that models
KGC as a binary text classification task. Subsequent works like
MTL-KGC [16] and StAR [35] have further improved KG-BERT by
introducing more training tasks such as relation classification and
triple ranking and more complex triple encoding strategy. PKGC
[21] utilizes manual prompt templates to capture the triple semantic.
Other methods like KGT5 [5, 29] make a step on the generative KGC
[43] in a sequence-to-sequence paradigm with encoder-decoder
PLMs like T5 [27]. PLM-based methods leverage the power of PLM
but make the training process into text-based learning, which is
difficult to capture complex structure information in the KGs.
2.2
LLMs for KG research
In recent years, large language models (LLMs) [23, 33, 46] have
made rapid progress and demonstrated powerful capabilities in a
considerable number of text-related tasks [49]. LLMs are usually
pre-trained in an auto-regressive manner with next word prediction
task [4] and demonstrate strong capability on text comprehension
and generation. Among the research topics of LLM, integrating
LLM and KG [25] is a popular and important one. On the one hand,
hallucination [39, 48] is widespread in LLMs which means LLMs
are lack factual knowledge and not interpretable. KGs that store
structured knowledge can mitigate such a phenomenon [10, 15,
26] by introducing factual knowledge into LLMs. On the other
hand, LLMs can benefit KG-related tasks such as KGC [51, 52],
entity alignment [47], and KGQA [1] by its powerful generation
capability. KGs for LLMs (KG4LLM) and LLMs for KGs (LLM4KG)
are both important research topics. We focus on applying LLMs in
the KGC task (LLM4KGC), which has not been carefully studied yet.
KGLLaMA [41] made the first step by vanilla instruction tuning
approach but it lacks in-depth and systematic exploration about
how to unleash the power of KGs themselves to make structure-
aware reasoning in LLMs and achieve better KGC performance. In
this paper, we will dive into this problem from a more systematic
perspective with the knowledge graph completion task.
2.3
Incorporate Non-textual Modality
Information into LLMs
As LLMs demonstrate generalizable capabilities on text generation,
many other works attempt to incorporate non-textual modality such
Making Large Language Models Perform Better in
Knowledge Graph Completion
Preprint, 2024,
as images [19, 50], audio [22], and video [22], which are also called
multi-modal LLMs [45]. These methods tend to encode non-textual
information through the modality encoders and then process it as
virtual text tokens. The non-textual tokens are aligned with the
word tokens by instruction tuning on multi-modal datasets.
The multi-modal LLM mentioned above usually excludes graph,
which is another important data modality. There are also some
works talking about how to incorporate graph data into LLMs.
Drug-Chat [17] proposes to encode the drug molecule graphs with
graph encoders and fine-tune the LLM to predict drug interactions.
Other works [11, 18, 36, 44] explore how to solve graph learning
tasks like node classification and graph classification by convert
the graph structure information into LLMs.
Our research is relative to this topic as KGs also have complex
graph structures on top of the text descriptions. In this paper, we
will explore how to incorporate complex structural information in
the KGs into the LLMs to achieve better reasoning capabilities on
knowledge graph completion.
3
BASIC SETTINGS FOR LLM-BASED KGC
3.1
Notations and Preliminaries
A KG can be denoted as G = (E, R, T, D) where E, R are the entity
set, relation set respectively. T = {(ℎ,𝑟,𝑡) | ℎ,𝑡∈E,𝑟∈R} is the
triple set and D is the description set of each entity and relation. We
denote D(𝑒), D(𝑟) as the short textual description of each entity
𝑒∈E and each relation 𝑟∈R. For example, the text description of
the entity ’/m/0ctzf1’ is D(’/m/0ctzf1’)=’The Transformers’. When
applying LLMs to KGC tasks, we denote a LLM as M that serves as a
text decoder. The input textual sequence S of the model M consists
of several parts: the instruction prompt I, the triple prompt X, and
the optional auxiliary demonstration prompt U. The instruction
prompt I is the manually prepared instruction to guide the LLM M
to execute the KGC task. The triple prompt X contains the textual
information about the triples that need to be processed, which can
be denoted as X(ℎ,𝑟,𝑡) = D(ℎ) ⊕D(𝑟) ⊕D(𝑡), where (ℎ,𝑟,𝑡) ∈T
is a triple and ⊕denotes the textual token concatenation operation.
In other words, the short descriptions of ℎ,𝑟,𝑡would be applied as
the input information. The auxiliary demonstration prompt U is
an optional prompt for different settings. In the following, we will
follow this set of notations.
Meanwhile, we use triple classification as an entry point to in-
vestigate how to utilize LLM to accomplish the KGC task. Triple
classification is a basic KGC task aiming to conduct binary classi-
fication tasks on the given triples. Whereas in the LLM paradigm,
all tasks are converted into the form of text generation. Therefore,
we desire the model M to answer true or false given the textual
sequence input S = I ⊕U ⊕X.
Triple classification is different from vanilla text classification
because the entities and the relations in the prompt have complex
semantic information defined by the given KG. Without knowledge
of this type of information, the model response is unreliable and
unstable. Despite the vast amount of commonsense knowledge
that exists in the LLMs [48], research has shown that large models
are numb to fine-grained factual knowledge and will fall into a
hallucination. Thus, incorporating the KG information into the
prompt to provide more auxiliary information and guide the LLM
to make structure-aware reasoning is the key to achieving excellent
LLM-based KGC.
3.2
Extending Existing LLM Paradigms
In this section, we first discuss how to solve the KGC task with
existing mainstream LLM paradigms called training-free reasoning
approaches and instruction-tuning approaches.
3.2.1
Training-free reasoning approaches. Training-free rea-
soning approaches prompt the LLMs to get direct answers without
training. Common training-free methods consist of zero-shot rea-
soning (ZSR) and in-context learning (ICL). For ZSR, we directly
utilize the sequence S𝑧𝑠𝑟= I ⊕X as the input to get the prediction
results. The decoding process of the LLM M can be formulated as:
A𝑧𝑠𝑟= arg max
A 𝑃M (A|S𝑧𝑠𝑟)
= arg max
A 𝑃M (A|I𝑧𝑠𝑟, X)
(1)
where A is the generated answer of the model M and I𝑧𝑠𝑟is
the instruction template for ZSR. In the setting of ZSR, no KG
information is added to the input sequence S𝑧𝑠𝑟. The determinative
information in the ZSR prompt is only the textual descriptions of
the test triple. ZSR is unable to incorporate KG information due to
its setting limitations, otherwise, it cannot be called zero-shot.
As another training-free paradigm, in-context learning (ICL) [9]
allows the model M to add auxiliary demonstration U to the input
S and accomplish the task in the form of analogical reasoning,
which can be denoted as:
A𝑖𝑐𝑙= arg max
A 𝑃M (A|S𝑖𝑐𝑙)
= arg max
A 𝑃M (A|I𝑖𝑐𝑙, U, X)
(2)
As for the triple classification task, the demonstration U should
be some triples and their labels in the form of {(X𝑖,𝑦𝑖), 1 ≤𝑖≤𝑘},
where X𝑖is the demonstration triple and 𝑦𝑖is the label. We denote
the ICL with 𝑘demonstrations as 𝑘-shot ICL.
The demonstration triples can be randomly sampled from the
existing training KG. However, to further incorporate the relative
KG information of the test triple (ℎ,𝑟,𝑡), we propose to sample
triples that are in the local structure of ℎand 𝑡, which means one
of the entities in each sampled triple should be ℎor 𝑡. Besides, as
existing KG only consists of positive triples, we employ negative
sampling [21] to sample negative triples for demonstration. The
number of positive and negative triples are the same for balanced
predictions. In the demonstration prompt, the positive triples are
labeled as true and the negative triples are labeled as false.
By doing this, we incorporate the local structural information
into the demonstration prompt U with both positive and nega-
tive samples. Such a structure-aware demonstration could better
enhance the analogical reasoning process of the model M.
3.2.2
Instruction tuning approaches. Instruction tuning ap-
proaches fine-tune the LLMs with instruction template to activate
the instruction following ability of LLMs. Vanilla instruction tun-
ing leverages the input S𝑖𝑡to fine-tune LLMs. The instruction
prompt I𝑖𝑡will describe the details of completing the triple classi-
fication task and the triple prompt X consists of the input triple.
Preprint, 2024,
Yichi Zhang et al.
Figure 2: An overview of the knowledge prefix adapter (KoPA) by us. KoPA first pre-trains structural embeddings for the
entities and relations in the given KG and then employs instruction tuning to fine-tune the LLM. The structural embeddings of
the given input triple will be projected into the textual space of the LLM by the adapter and serve as prefix tokens in the front
of the input sequence, which can be "seen" by the following textual tokens due to the unidirectional attention mechanism in
the decoder-only LLM.
No other auxiliary demonstrations are included in the input tem-
plate. To train the model M, the input sequence is organized as
S𝑖𝑡= I𝑖𝑡⊕X ⊕A𝑖𝑡, where A𝑖𝑡is the predicted answer of the
training data. The model M is fine-tuned with the next word pre-
diction task [49] which is a universal approach to training LLMs.
The training objective can be formulated as:
L𝑖𝑡= −
1
|S𝑖𝑡|
|S𝑖𝑡|
∑
𝑖=1
log 𝑃M (𝑠𝑖|𝑠<𝑖)
(3)
where 𝑠𝑖(𝑖= 1, 2, . . . , |S𝑖𝑡|) represents the textual tokens of the
input sequence S𝑖𝑡. In the inference stage, the model M is employed
to predict the answer A𝑖𝑡of the test data like Equation 1. Besides,
negative sampling [21] is also applied to generate negative data
samples as training KG only consists of positve triples.
To incorporate semantic-rich KG information into LLMs, we
also propose a structure-aware instruction tuning approach by
adding the one-hop neighborhood structure information in the
input prompt to inform the LLM with the local structural informa-
tion. As mentioned before, the structural information of KG plays a
significant role in the KGC tasks [37]. To incorporate such KG infor-
mation during the fine-tuning stage, we achieve this goal by adding
the neighborhood descriptions of the input triple. Specifically, we
can sample the neighborhoods of the head ℎand tail 𝑡and put the
textual descriptions of neighborhood triples in the demonstration
prompt U𝑖𝑡. In this way, the input training sequence is enhanced
as S𝑖𝑡= I𝑖𝑡⊕U𝑖𝑡⊕X ⊕A𝑖𝑡.
Therefore, we provide a detailed discussion of how the existing
LLM paradigms can introduce local structural information about
KGs to further enhance the model performance. However, though
these approaches can work to some extent, they have obvious
drawbacks. This textbf fundamental approaches to incorporate
KG structural information focus on adding the neighborhood
information to the input prompt in the text form. However,
representing the KG structural information in text is not a good
choice, which may bring in more invalid or redundant information
to the prompt. It’s not scalable and effective to increase prompt
length indefinitely because a long context will lead to both a decline
in model capability and high computational consumption. Besides,
we also have difficulty finding the structural information in the
KGs that is decisive for triple discrimination. These two problems
put us in a dilemma.
4
METHODLOGY
To solve such issues, we propose the Knowledge Prefix Adapter
(KoPA for short) to incorporate the KG structural information into
LLM for KGC. Figure 2 presents an intuitive view of KoPA. Firstly
we extract the structural information of entities and relations from
the KG through structural embedding pre-training, and then we
inform this structural information to LLM through a structural
prefix adapter into the input sequence S. The LLM M is further
fine-tuned with the structural-enhanced text sequence. We will
discuss the details in the next few sections about our design.
4.1
Structural Embedding Pre-training
Instead of adding text about the neighborhood information into
the input sequence, KoPA extracts the structural information of
the entities and relations by self-supervised structural embedding
pre-training. For each entity 𝑒∈E and each relation 𝑟∈R, we
learn a structural embedding 𝒆∈R𝑑𝑒, 𝒓∈R𝑑𝑟respectively, where
𝑑𝑒,𝑑𝑟are the embedding dimensions. We encode the KG struc-
tural information in the embeddings and further adapt them into
the textual representation space of LLMs. Referring to the exist-
ing embedding-based KGC paradigm, we define a score function
F (ℎ,𝑟,𝑡) to measure the plausibility of the triple (ℎ,𝑟,𝑡). We adopt
the self-supervised pre-training objective by negative sampling [3]:
L𝑝𝑟𝑒=
1
|T |
∑
(ℎ,𝑟,𝑡)∈T

−log𝜎(𝛾−F (ℎ,𝑟,𝑡))
−
𝐾
∑
𝑖=1
𝑝𝑖log𝜎(F (ℎ′
𝑖,𝑟′
𝑖,𝑡′
𝑖) −𝛾)

(4)
Making Large Language Models Perform Better in
Knowledge Graph Completion
Preprint, 2024,
Table 1: Comparasion among LLM-based KGC methods in
three ways. As for the prompt length anaysis, 𝐿𝐼, 𝐿𝑇denote
the length of the instruction prompt and triple prompt. 𝐿𝐷
denotes the length of a demonstration and 𝑘is the demon-
stration number. ZSR/ICL/IT refer to zero-shot reasoning,
in-context learning, and instruction tuning respectively.
Method
Requires
Fine-tuning
Extra
KG Info
Prompt
Length
ZSR
%
%
𝐿𝐼+ 𝐿𝑇
ICL
%
!
𝐿𝐼+ 𝐿𝑇+ 𝑘𝐿𝐷
Vanilla IT
!
%
𝐿𝐼+ 𝐿𝑇
Enhanced IT
!
!
𝐿𝐼+ 𝐿𝑇+ 𝑘𝐿𝐷
KoPA
!
!
𝐿𝐼+ 𝐿𝑇+ 3
where 𝛾is the margin, 𝜎is the sigmoid activation function and
(ℎ′
𝑖,𝑟′
𝑖,𝑡′
𝑖)(𝑖= 1, 2, . . . , 𝐾) are 𝐾negative samples [3] of (ℎ,𝑟,𝑡).
The weight 𝑝𝑖is the self-adversarial weights proposed in [31].
By minimizing such a pre-training loss, the structural embed-
dings of each entity and relation are optimized to fit all its relative
triples thus the KG structural information such as subgraph struc-
ture and relational patterns is captured in the embeddings. Such
an approach has been proven effective in many embedding-based
KGC methods [3, 31] to capture classic structural information like
relational patterns and distributed entity representations [13] in
the earliest days.
4.2
Knowledge Prefix Adapter
After structural embedding pre-training, we could obtain the struc-
tural embeddings (𝒉, 𝒓, 𝒕) of a triple (ℎ,𝑟,𝑡) where the KG structural
information is encoded in. However, the structural embeddings are
learned in a different representation space against the textual to-
ken representation space of the LLM M, which means M can not
directly understand these embeddings. Thus we apply a knowledge
prefix adapter P to project them into the textual token representa-
tion space of M. Specifically speaking, the structural embeddings
are converted to several virtual knowledge tokens K by P:
K = P(𝒉) ⊕P(𝒓) ⊕P(𝒕)
(5)
In practice, the adapter P would be a simple projection layer
[50]. Then we put K in the front of the original input sequence
S serving as a prefix of the instruction and triple prompt S𝑘𝑝𝑎=
K ⊕I𝑖𝑡⊕X. This way, all the following text tokens can be seen
with the prefix K due to the unidirectional attention in decoder-
only LLMs. By doing this, the textual tokens can pay unidirectional
attention to the structural embeddings of the input triple. Such
a structure-aware prompt will be employed during fine-tuning
and inference. During training, we froze the pre-trained structural
embeddings. The adapter is optimized to learn the mapping from
structural knowledge toward textual representation and will have
the generalization to new triples in the inference stage, which will
benefit the textual description and provide the triple information
from another perspective to make enhanced predictions.
Table 2: Statistical information of datasets. The positve (+)
and negative (-) samples are 1:1 in the valid / test set.
Dataset
|E|
|R|
#Train
#Valid(+/-)
#Test(+/-)
UMLS
135
46
5216
652/652
661/661
CoDeX-S
2034
42
32888
1827/1827
1828/1828
FB15K-237N
13104
93
87282
7041/7041
8226/8226
4.3
Complexity Analysis
After proposing KoPA, we make a comparison among LLM-based
KGC methods to demonstrate the advantages of KoPA, which is
shown in Table 1. Compared with the basic paradigms (ZSR/ICL/IT),
KoPA incorporates the KG structural embeddings into LLM to
combine the textual and structural information. Meanwhile, KoPA
makes the length of the prompt more refined as the length of virtual
tokens generated by the structural prefix adapter is fixed to 3 for
head/relation/tail respectively. In contrast, the prompt length of
structure-aware IT (enhanced IT in the table) is linearly related to
the number of neighborhood triples 𝑘. In contrast to methods that
incorporate structural information based on textual descriptions,
KoPA achieves this goal by fixed-length virtual knowledge tokens
generated by the adapter.
5
EXPERIMENTS
5.1
Experimental Settings
5.1.1
Datasets. In our experiments, we use three public KG bench-
marks UMLS [40], CoDeX-S [28], and FB15K-237N [21] to evaluate
the proposed LLM-based KGC methods. The detailed split informa-
tion of the datasets is shown in Table 2.
5.1.2
Baseline Methods. In our experiments, we provide a com-
prehensive comparison with three broad classes of baselines on
triple classification, which is an important subtask of KGC. The
KGC baselines can be divided into three parts: embedding-based
methods [3, 31, 34, 38], PLM-based methods [21, 40], and LLM-based
methods [41]. Besides, we further divide the LLM-based methods
into two categories: training-free methods and fine-tuning methods.
Training-free methods consist of ZSR and ICL while fine-tuning
methods consist of vanilla IT and structure-aware IT (enhanced IT).
The specific models used for these baselines are listed below:
(1). Embedding-based KGC methods. We select four tradi-
tional embedding-based KGC methods for comparisons, namely
TransE [], DistMult [38], ComplEx [34], and RotatE [31]. These
methods predict the triple plausibility by the learned structural
embeddings and the score functions defined in the model.
(2). PLM-based KGC methods. We select KG-BERT [40] and
PKGC [21] as PLM-based KGC baselines, which are classic methods
focusing on the triple classification task. These methods treat triple
classification as a binary text classification task.
(3). LLM-based KGC methods. LLM-based KGC research is
still at an early stage. There are only KGLLaMA [41] to be the
LLM-based KGC baseline. In addition to KGLLaMA, the methods
proposed in Section 3 by us including ZSR, ICL, IT, and structure-
aware IT (enhanced IT) will also serve as baselines.
Preprint, 2024,
Yichi Zhang et al.
Table 3: The main experiment results of triple classification. We report the accuracy (ACC), precision (P), recall (R), and F1-score
(F1) results for each method on the three datasets. "-" means the result are missing because the specificity of PKGC makes it
difficult to reproduce. The best Acc / F1 results in baselines are marked with underline, and we highlight our results with bold
when we achieve new SOTA.
Model
UMLS
CoDeX-S
FB15K-237N
Acc
P
R
F1
Acc
P
R
F1
Acc
P
R
F1
Embedding-based
TransE [3]
84.49
86.53
81.69
84.04
72.07
71.91
72.42
72.17
69.71
70.80
67.11
68.91
DistMult [38]
86.38
87.06
86.53
86.79
66.79
69.67
59.46
64.16
58.66
58.98
56.84
57.90
ComplEx [34]
90.77
89.92
91.83
90.87
67.64
67.84
67.06
67.45
65.70
66.46
63.38
64.88
RotatE [31]
92.05
90.17
94.41
92.23
75.68
75.66
75.71
75.69
68.46
69.24
66.41
67.80
PLM-based
KG-BERT [40]
77.30
70.96
92.43
80.28
77.30
70.96
92.43
80.28
56.02
53.47
97.62
67.84
PKGC [21]
-
-
-
-
-
-
-
-
79.60
-
-
79.50
LLM-based
Training-free
Zero-shot(Alpaca)
52.64
51.55
87.69
64.91
50.62
50.31
99.83
66.91
56.06
53.32
97.37
68.91
Zero-shot(GPT-3.5)
67.58
88.04
40.71
55.67
54.68
69.13
16.94
27.21
60.15
86.62
24.01
37.59
ICL(1-shot)
50.37
50.25
75.34
60.29
49.86
49.86
50.59
50.17
54.54
53.67
66.35
59.34
ICL(2-shot)
53.78
52.47
80.18
63.43
52.95
51.54
98.85
67.75
57.81
56.22
70.56
62.58
ICL(4-shot)
53.18
52.26
73.22
60.99
51.14
50.58
99.83
67.14
59.29
57.49
71.37
63.68
ICL(8-shot)
55.52
55.85
52.65
54.21
50.62
50.31
99.83
66.91
59.23
57.23
73.02
64.17
LLM-based
Fine-tuning
KG-LLaMA [41]
85.77
87.84
83.05
85.38
79.43
78.67
80.74
79.69
74.81
67.37
96.23
79.25
KG-Alpaca [41]
86.01
94.91
76.10
84.46
80.25
79.38
81.73
80.54
69.91
62.71
98.28
76.56
Vanilla IT
86.91
95.18
77.76
85.59
81.18
77.01
88.89
82.52
73.50
65.87
97.53
78.63
Structure-aware IT
89.93
93.27
86.08
89.54
81.27
77.14
88.40
82.58
76.42
69.56
93.95
79.94
KoPA
92.58
90.85
94.70
92.70
82.74
77.91
91.41
84.11
77.65
70.81
94.09
80.81
5.1.3
Implementation and Detail Settings. We reproduce the
baseline results and implement the KoPA proposed by us.
For embedding-based KGC methods, we reproduce the results
with OpenKE we set the embedding dimension 𝑑𝑒= 𝑑𝑟= 512 and
sample 𝐾= 32 negative samples during training. The margin 𝛾is
tuned among {0, 4, 6, 8, 12}. After training KGC models, we search
for the best classification score threshold on the validation set for
test data following the traditional setting [3].
For PLM-based methods, the backbone model for PLM-based
KGC methods is BERT [8]. We fine-tune the KG-BERT according
to the official code implementation. Since PKGC requires a lot of
manual work to annotate each relation with a prompt, we only
report the results of FB15K-237N shown in the original paper.
For zero-shot reasoning, in addition to measuring with the same
backbone Alpaca, we also test the performance of the GPT-3.5-turbor
which has 175B parameters. For the in-context learning method,
we sample k-shot (k=1,2,4,8) structure-aware demonstrations. Be-
sides, we sample 4 neighborhood triples for each triple to conduct
structure-aware instruction tuning. For KoPA, we employ RotatE
[31] and the score function of structural embedding pre-training
and the embedding dimension is set to 512 and the adapter is a
512×4096 linear projection layer.
For KoPA, we employ Alpaca-7B [32] as the LLM backbone. Al-
paca is a famous extended version of LLaMA [33] model fine-tuned
on instruction-following data. We reproduce the triple classification
results of KGLLaMA [41] over two backbones (LLaMA and Alpaca)
to avoid the effect of backbone choice on the results. We name the
two baseline models KGLLaMA and KGAlpaca respectively. For
all the fine-tuning methods (instruction tuning, structure-aware
instruction tuning, and KoPA), we fine-tune Alpaca using LoRA
[14] with rank 64. The number of epochs is searched in {3, 4, 5} and
the learning rate is tuned in {1𝑒−4, 3𝑒−4, 5𝑒−4}. We use the AdamW
optimizer [20] with a fixed batch size of 12. We conducted all the
experiments with Nvidia A800 GPUs. The structural embedding
pre-training process is efficient and only takes several minutes to
finish. Therefore, the main time cost is caused by the LLM fine-
tuning, which takes several hours for different datasets. (1 hour for
UMLS, 4 hours for CoDeX-S, and 8 hours for FB15K-237N in our
experimental environments).
5.1.4
Evaluation Protocol. We evaluate the methods with the
triple classification task [3], which is essentially binary classifica-
tion and all the test datasets are label-balanced. Therefore, we use
accuracy, precision, recall, and F1-score as the evaluation metrics.
5.2
Main Results
The main experiment results of triple classification are shown in Ta-
ble 3. Since precision and recall alone do not give a good response
to the model’s performance on the classification task, we focus
on accuracy and F1-score. However, to provide a comprehensive
analysis of different models, we also report the precision and re-
call results in the table. Overall, we can find that KoPA achieves
outperforming accuracy and F1 results compared with the existing
16 baseline models on all three datasets. Taking CoDeX-S as an
example, KoPA achieves 1.81% improvement in accuracy and 1.85%
improvement on F1. As we use the pre-trained RotatE embeddings
in KoPA, we can observe that KoPA significantly outperforms the
Making Large Language Models Perform Better in
Knowledge Graph Completion
Preprint, 2024,
(a). IR=10%
(b). IR=20%
(c). IR=30%
(d). IR=40%
KoPA
Vanilla IT
Enhanced IT
Figure 3: The results of the transferbility experiment. We
report the results on CoDeX-S dataset under different induc-
tive rate (IR). Besides, we split the test data into seen (S) and
unseen (U) parts based on whether the entity appeared dur-
ing training. Also we total the results of all (A) the test data
together. Accuracy (Acc) and F1-score (F1) are reported in the
radar charts.
original embedding-based RotatE method, especially on larger and
more challenging datasets like CoDeX-S and FB15K-237N.
Meanwhile, compared with all LLM-based approaches, we can
see that the LLMs cannot understand the KG structural information
well without fine-tuning. The zero-shot LLMs perform very poorly
in the triple classification task even though GPT-3.5-turbo (175B
parameters) has excellent capability. Though the demonstrations
provided by ICL can incorporate the KG information, the perfor-
mance gain is limited. Besides, the prediction results of training-free
methods are biased and easy to slip into the extremes of all-right
or all-wrong, as the recall of them is either very high or very low
but the F1 scores are relatively low all the time.
However, fine-tuning LLMs can introduce the KG information
into LLMs as the overall performance makes obvious improvements.
Meanwhile, though structure-aware IT enhances the input prompt
with neighborhood information of triples, its performance is also
limited compared with KoPA. This suggests that the structural
embeddings consist of more semantic-rich information compared
with text-based auxiliary prompts, which can also be understood
by the LLM through the prefix adapter. Combining the analysis
in Section 4.3 and the experimental results, KoPA achieves better
results on top of shorter prompts.
5.3
Transferability Exploration
The results in the main experiments have shown the effectiveness
of KoPA. To further validate the generality and the transferability
Table 4: Ablation study results on CoDeX-S. We first replace
the pre-trained structural embedding with other components
and change the insert position of virtual knowledge tokens to
demonstrate the effectiveness of knowledge prefix adapter.
Model
Acc
F1
KoPA(Prefix + RotatE)
82.74
84.11
Embedding
w/o SE
81.18
82.52
w/ TransE
82.46
83.42
w/ DistMult
80.71
81.27
w/ ComplEx
81.21
82.12
w/ Random
81.53
82.36
Position
Infix
81.21
82.69
Suffix
77.29
77.75
of KoPA, we conduct a new transferability experiment. In this
experiment, we will demonstrate that the knowledge prefix adapter
will learn to transfer from structural embeddings to textual token
representations and provide semantic-rich auxiliary information to
enhance the decoding process of LLM inference.
We demonstrate this point by testing the influence of KoPA for
entities that do not appear in the training phase, which is also called
inductive setting in other KGC works [6]. We split the KG dataset
into an inductive setting with a defined inductive rate (IR), which
refers to the ratio of unseen entities during training. For example,
if IR=10%, we will randomly select 10% entities as the inductive
entity set. Any triple in the training set whose head or tail is in the
inductive set will be removed during training. Besides, the triples
in the test set will be divided into two parts: the seen (S) part and
the unseen (U) part. If the head or tail in a triple is in the inductive
entity set, it will be regarded as unseen. We fine-tune the LLM with
only remaining seen triples and test on both seen and unseen triples.
In this setting, a set of entities will not participate in the training
process and the LLM does not see their textual descriptions, which
will make the test process more challenging. We report the accuracy
and F1 score for seen (S), unseen (U), and all (A) test triples, which
is shown in Figure 3 for three fine-tuning methods: KoPA, vanilla
IT, and structure-aware IT (enhanced IT in the figure).
From the radio charts, we can observe that KoPA outperforms the
other methods for unseen triples and has less performance degra-
dation when IR increases. The performance of structure-aware
IT (enhanced IT) with neighborhood triples in the textual form
is more unstable. These phenomena suggest that the knowledge
prefix adapter can learn a good mapping from the structural em-
beddings to the textual representation, which is transferable even if
the entities are unseen during training. The structural embeddings
captured from KG play a more significant role in informing the
LLM with useful structural information.
5.4
Ablation Study
To verify the effectiveness of the KoPA design, we conduct a two-
part ablation study. The first part is designed to verify the effec-
tiveness of structural embedding and the second part is designed
to verify the effectiveness of prefix adapter. As shown in Table 4,
we can find that removing the structural embeddings or replacing
them with random initialized embeddings both lead to performance
decline. Also, we find that the model is compatible with different
Preprint, 2024,
Yichi Zhang et al.
Enhanced IT
KoPA
Vanilla IT
RotatE
Figure 4: The Venn diagram of the correct predictions from
various KGC models. Each intersecting part in the diagram
represents the same predictions from different models on
certain data.
types of structural embeddings. However, the performance gain
depends on whether the embedding was originally powerful in the
triple classification task or not. Refer to Tables 3, TransE [3] and Ro-
tatE [31] are better embedding-based KGC models compared with
DistMult [38] and ComplEx [34]. This demonstrates that semantic-
rich structural information is the key to performance improvement
and KoPA takes full advantage of it.
Meanwhile, putting the virtual knowledge tokens generated by
the adapter in the middle (infix) or in the last (suffix) of the input
sequence will also decrease the performance. We believe the reason
is that putting tokens in the front of the sequence will make all
the text pay attention to them as LLMs are usually decoder-only
architectures with unidirectional self-attention. Then the LLM can
make a better decision with the structural embeddings that fully
interact with the text. Combining these two parts of the ablation
study, we believe that our design of KoPA is effective and reasonable.
5.5
Case Study
To make a more intuitive view of KoPA, we conduct a case study in
this section from both macro and micro perspectives. From a macro
perspective, we count the prediction overlap of several models and
plot a Venn diagram shown in Figure 4.
From the diagram we can find that KoPA has a significant por-
tion of the proper predictions that do not intersect with several
other models, which means that KoPA makes the right prediction
on some test data that many other models predict incorrectly. This
suggests that the structural information incorporated in KoPA has a
significant role in making correct predictions. For a micro example,
a test triple (John Landis, film director film, Coming to America) is
predicted as wrong by the RotatE model and vanilla instruction tun-
ing LLM. With retrieved neighborhood triples (Coming to America,
locations, New York City), (John Landis, nationality, USA ), (Coming
to America, genre, romantic comedy), (Comedy, common netflix ti-
tles, Coming to America), the structure-aware fine-tuned LLM still
makes a wrong prediction because the neighborhood information
is of little use in the judgment of the current prediction though
they are the correct factual. The structural embeddings applied
in KoPA contain more information than structural information in
the form of text and are easier for us to extract by a structural
pre-training process. Thus, KoPA outperforms other models in the
triple classification task.
Humanity
Social
Science
STEM
Other
Average
None
UMLS
CoDeX
FB15K-237N
Figure 5: The common ability experiments on MMLU.
5.6
Common Ability Retention
To delve into the preservation of generic capabilities in LLMs, we
conducted another experiment to assess the overall proficiency of
LLMs both before and after fine-tuning. We apply the MMLU [12]
benchmark for this problem. MMLU is the most popular bench-
mark to evaluate the general abilities of LLMs in different domains
such as Humanities, Social Sciences, STEM, and others. The overall
evaluation results on different datasets are shown in Figure 5:
From the results, it can be noticed that after KoPA training, there
were discernible alterations in the generalized abilities of LLMs.
In most instances, there was a decrease, but notably, STEM profi-
ciency exhibited improvement on the UMLS dataset. We attribute
this phenomenon to the UMLS being a medical KG, encompassing
substantial knowledge in medicine, biology, and chemistry, and
training on this dataset allows the model to acquire more STEM
knowledge. Consequently, when facing natural language inputs
differing from the training task, the model adeptly leverages the
acquired knowledge from KGC task fine-tuning to get enhanced
results. We have listed several subjects in MMLUs that showed
improvement after training with UMLS. These subjects are highly
relevant and close to the knowledge domain encapsulated in the
UMLS in Table 5. The LLMs trained with the KGC task also achieved
significant improvements across different input prompts, marking
a compelling observation.
Table 5: The specific domains in MMLU in which LLM
achieves higher scores after training on UMLS.
Subjects
w/o Training
w/ Training
Clinical
44.9
47.9 (+3.0%)
College
Medicine
30.1
31.2 (+1.1%)
High School
Biology
42.9
46.8 (+3.9%)
High School
Chemistry
30.0
32.0 (+2.0%)
Medical
Genetics
44.0
48.0 (+4.0%)
Making Large Language Models Perform Better in
Knowledge Graph Completion
Preprint, 2024,
6
CONCLUSION
In this paper, we systematically explore how to incorporate struc-
tural understanding ability into LLMs to make structure-aware
reasoning for KGC tasks. We extend the original LLM paradigms
and propose structure-aware ICL and IT methods to incorporate the
structural information by text. We further propose KoPA, a knowl-
edge prefix adapter to incorporate the pre-trained structural embed-
dings into the LLMs. We conduct triple classification experiments
to make comprehensive comparisons among the structure-aware
methods and demonstrate the outperforming results achieved by
KoPA. In the future, we plan to dive deep into LLM-based KGC and
think about a more unified framework to accomplish all the KGC
tasks with LLMs. Besides, we will also explore flexibly adapting
KGs into LLM-based downstream applications to make the LLMs
knowledgeable, reliable, and human-friendly.
REFERENCES
[1] Jinheon Baek, Alham Fikri Aji, and Amir Saffari. 2023. Knowledge-Augmented
Language Model Prompting for Zero-Shot Knowledge Graph Question Answer-
ing. CoRR abs/2306.04136 (2023).
[2] Kurt D. Bollacker, Colin Evans, Praveen K. Paritosh, Tim Sturge, and Jamie Taylor.
2008. Freebase: a collaboratively created graph database for structuring human
knowledge. In SIGMOD Conference. ACM, 1247–1250.
[3] Antoine Bordes, Nicolas Usunier, Alberto García-Durán, Jason Weston, and Ok-
sana Yakhnenko. 2013. Translating Embeddings for Modeling Multi-relational
Data. In NIPS. 2787–2795.
[4] Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan,
Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda
Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan,
Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter,
Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin
Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya
Sutskever, and Dario Amodei. 2020. Language Models are Few-Shot Learners. In
NeurIPS.
[5] Chen Chen, Yufei Wang, Bing Li, and Kwok-Yan Lam. 2022. Knowledge Is Flat:
A Seq2Seq Generative Framework for Various Knowledge Graph Completion. In
COLING. International Committee on Computational Linguistics, 4005–4017.
[6] Mingyang Chen, Wen Zhang, Yushan Zhu, Hongting Zhou, Zonggang Yuan,
Changliang Xu, and Huajun Chen. 2022. Meta-Knowledge Transfer for Inductive
Knowledge Graph Embedding. In SIGIR. ACM, 927–937.
[7] Zhuo Chen, Wen Zhang, Yufeng Huang, Mingyang Chen, Yuxia Geng, Hongtao
Yu, Zhen Bi, Yichi Zhang, Zhen Yao, Wenting Song, Xinliang Wu, Yi Yang, Mingyi
Chen, Zhaoyang Lian, Yingying Li, Lei Cheng, and Huajun Chen. 2023. Tele-
Knowledge Pre-training for Fault Analysis. In ICDE. IEEE, 3453–3466.
[8] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT:
Pre-training of Deep Bidirectional Transformers for Language Understanding. In
NAACL-HLT (1). Association for Computational Linguistics, 4171–4186.
[9] Qingxiu Dong, Lei Li, Damai Dai, Ce Zheng, Zhiyong Wu, Baobao Chang, Xu
Sun, Jingjing Xu, Lei Li, and Zhifang Sui. 2023. A Survey for In-context Learning.
CoRR abs/2301.00234 (2023).
[10] Chao Feng, Xinyu Zhang, and Zichu Fei. 2023. Knowledge Solver: Teaching LLMs
to Search for Domain Knowledge from Knowledge Graphs. CoRR abs/2309.03118
(2023).
[11] Jiayan Guo, Lun Du, and Hengyu Liu. 2023. GPT4Graph: Can Large Language
Models Understand Graph Structured Data ? An Empirical Evaluation and Bench-
marking. CoRR abs/2305.15066 (2023).
[12] Dan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn
Song, and Jacob Steinhardt. 2021. Measuring Massive Multitask Language Un-
derstanding. In ICLR. OpenReview.net.
[13] Geoffrey E. Hinton, James L. McClelland, and David E. Rumelhart. 1990. Dis-
tributed Representations. In The Philosophy of Artificial Intelligence. Oxford
University Press, 248–280.
[14] Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean
Wang, Lu Wang, and Weizhu Chen. 2022. LoRA: Low-Rank Adaptation of Large
Language Models. In ICLR. OpenReview.net.
[15] Ziwei Ji, Zihan Liu, Nayeon Lee, Tiezheng Yu, Bryan Wilie, Min Zeng, and
Pascale Fung. 2023. RHO: Reducing Hallucination in Open-domain Dialogues
with Knowledge Grounding. In ACL (Findings). Association for Computational
Linguistics, 4504–4522.
[16] Bosung Kim, Taesuk Hong, Youngjoong Ko, and Jungyun Seo. 2020. Multi-Task
Learning for Knowledge Graph Completion with Pre-trained Language Models.
In COLING. International Committee on Computational Linguistics, 1737–1743.
[17] Youwei Liang, Ruiyi Zhang, Li Zhang, and Pengtao Xie. 2023. DrugChat: To-
wards Enabling ChatGPT-Like Capabilities on Drug Molecule Graphs. CoRR
abs/2309.03907 (2023).
[18] Chang Liu and Bo Wu. 2023. Evaluating Large Language Models on Graphs:
Performance Insights and Comparative Analysis. CoRR abs/2308.11224 (2023).
[19] Haotian Liu, Chunyuan Li, Qingyang Wu, and Yong Jae Lee. 2023. Visual Instruc-
tion Tuning. CoRR abs/2304.08485 (2023).
[20] Ilya Loshchilov and Frank Hutter. 2019. Decoupled Weight Decay Regularization.
In ICLR (Poster). OpenReview.net.
[21] Xin Lv, Yankai Lin, Yixin Cao, Lei Hou, Juanzi Li, Zhiyuan Liu, Peng Li, and Jie
Zhou. 2022. Do Pre-trained Models Benefit Knowledge Graph Completion? A
Reliable Evaluation and a Reasonable Approach. In ACL (Findings). Association
for Computational Linguistics, 3570–3581.
[22] Chenyang Lyu, Minghao Wu, Longyue Wang, Xinting Huang, Bingshuai Liu,
Zefeng Du, Shuming Shi, and Zhaopeng Tu. 2023. Macaw-LLM: Multi-Modal
Language Modeling with Image, Audio, Video, and Text Integration. CoRR
abs/2306.09093 (2023).
[23] OpenAI. 2023. GPT-4 Technical Report. CoRR abs/2303.08774 (2023).
[24] Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright,
Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray,
John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda
Askell, Peter Welinder, Paul F. Christiano, Jan Leike, and Ryan Lowe. 2022. Train-
ing language models to follow instructions with human feedback. In NeurIPS.
[25] Shirui Pan, Linhao Luo, Yufei Wang, Chen Chen, Jiapu Wang, and Xindong Wu.
2023. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
CoRR abs/2306.08302 (2023).
[26] Baolin Peng, Michel Galley, Pengcheng He, Hao Cheng, Yujia Xie, Yu Hu, Qiuyuan
Huang, Lars Liden, Zhou Yu, Weizhu Chen, and Jianfeng Gao. 2023. Check Your
Facts and Try Again: Improving Large Language Models with External Knowledge
and Automated Feedback. CoRR abs/2302.12813 (2023).
[27] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang,
Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. 2020. Exploring the
Limits of Transfer Learning with a Unified Text-to-Text Transformer. J. Mach.
Learn. Res. 21 (2020), 140:1–140:67.
[28] Tara Safavi and Danai Koutra. 2020. CoDEx: A Comprehensive Knowledge
Graph Completion Benchmark. In EMNLP (1). Association for Computational
Linguistics, 8328–8350.
[29] Apoorv Saxena, Adrian Kochsiek, and Rainer Gemulla. 2022.
Sequence-to-
Sequence Knowledge Graph Completion and Question Answering. In ACL (1).
Association for Computational Linguistics, 2814–2828.
[30] Rui Sun, Xuezhi Cao, Yan Zhao, Junchen Wan, Kun Zhou, Fuzheng Zhang,
Zhongyuan Wang, and Kai Zheng. 2020. Multi-modal Knowledge Graphs for
Recommender Systems. In CIKM. ACM, 1405–1414.
[31] Zhiqing Sun, Zhi-Hong Deng, Jian-Yun Nie, and Jian Tang. 2019. RotatE: Knowl-
edge Graph Embedding by Relational Rotation in Complex Space. In ICLR (Poster).
OpenReview.net.
[32] Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos
Guestrin, Percy Liang, and Tatsunori B. Hashimoto. 2023. Stanford Alpaca: An
Instruction-following LLaMA model. https://github.com/tatsu-lab/stanford_
alpaca.
[33] Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne
Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal
Azhar, Aurélien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lam-
ple. 2023. LLaMA: Open and Efficient Foundation Language Models. CoRR
abs/2302.13971 (2023).
[34] Théo Trouillon, Johannes Welbl, Sebastian Riedel, Éric Gaussier, and Guillaume
Bouchard. 2016. Complex Embeddings for Simple Link Prediction. In ICML (JMLR
Workshop and Conference Proceedings, Vol. 48). JMLR.org, 2071–2080.
[35] Bo Wang, Tao Shen, Guodong Long, Tianyi Zhou, Ying Wang, and Yi Chang. 2021.
Structure-Augmented Text Representation Learning for Efficient Knowledge
Graph Completion. In WWW. ACM / IW3C2, 1737–1748.
[36] Heng Wang, Shangbin Feng, Tianxing He, Zhaoxuan Tan, Xiaochuang Han, and
Yulia Tsvetkov. 2023. Can Language Models Solve Graph Problems in Natural
Language? CoRR abs/2305.10037 (2023).
[37] Quan Wang, Zhendong Mao, Bin Wang, and Li Guo. 2017. Knowledge Graph
Embedding: A Survey of Approaches and Applications. IEEE Trans. Knowl. Data
Eng. 29, 12 (2017), 2724–2743. https://doi.org/10.1109/TKDE.2017.2754499
[38] Bishan Yang, Wen-tau Yih, Xiaodong He, Jianfeng Gao, and Li Deng. 2015. Em-
bedding Entities and Relations for Learning and Inference in Knowledge Bases.
In ICLR (Poster).
[39] Linyao Yang, Hongyang Chen, Zhao Li, Xiao Ding, and Xindong Wu. 2023.
ChatGPT is not Enough: Enhancing Large Language Models with Knowledge
Graphs for Fact-aware Language Modeling. CoRR abs/2306.11489 (2023).
[40] Liang Yao, Chengsheng Mao, and Yuan Luo. 2019. KG-BERT: BERT for Knowledge
Graph Completion. CoRR abs/1909.03193 (2019).
Preprint, 2024,
Yichi Zhang et al.
[41] Liang Yao, Jiazhen Peng, Chengsheng Mao, and Yuan Luo. 2023. Exploring
Large Language Models for Knowledge Graph Completion. CoRR abs/2308.13916
(2023).
[42] Michihiro Yasunaga, Hongyu Ren, Antoine Bosselut, Percy Liang, and Jure
Leskovec. 2021. QA-GNN: Reasoning with Language Models and Knowledge
Graphs for Question Answering. In NAACL-HLT. Association for Computational
Linguistics, 535–546.
[43] Hongbin Ye, Ningyu Zhang, Hui Chen, and Huajun Chen. 2022. Generative
Knowledge Graph Construction: A Review. In EMNLP. Association for Computa-
tional Linguistics, 1–17.
[44] Ruosong Ye, Caiqi Zhang, Runhui Wang, Shuyuan Xu, and Yongfeng Zhang. 2023.
Natural Language is All a Graph Needs. CoRR abs/2308.07134 (2023).
[45] Shukang Yin, Chaoyou Fu, Sirui Zhao, Ke Li, Xing Sun, Tong Xu, and En-
hong Chen. 2023. A Survey on Multimodal Large Language Models. CoRR
abs/2306.13549 (2023).
[46] Aohan Zeng, Xiao Liu, Zhengxiao Du, Zihan Wang, Hanyu Lai, Ming Ding,
Zhuoyi Yang, Yifan Xu, Wendi Zheng, Xiao Xia, Weng Lam Tam, Zixuan Ma,
Yufei Xue, Jidong Zhai, Wenguang Chen, Zhiyuan Liu, Peng Zhang, Yuxiao Dong,
and Jie Tang. 2023. GLM-130B: An Open Bilingual Pre-trained Model. In ICLR.
OpenReview.net.
[47] Rui Zhang, Yixin Su, Bayu Distiawan Trisedya, Xiaoyan Zhao, Min Yang, Hong
Cheng, and Jianzhong Qi. 2023. AutoAlign: Fully Automatic and Effective Knowl-
edge Graph Alignment enabled by Large Language Models. CoRR abs/2307.11772
(2023).
[48] Yue Zhang, Yafu Li, Leyang Cui, Deng Cai, Lemao Liu, Tingchen Fu, Xinting
Huang, Enbo Zhao, Yu Zhang, Yulong Chen, Longyue Wang, Anh Tuan Luu, Wei
Bi, Freda Shi, and Shuming Shi. 2023. Siren’s Song in the AI Ocean: A Survey on
Hallucination in Large Language Models. CoRR abs/2309.01219 (2023).
[49] Wayne Xin Zhao, Kun Zhou, Junyi Li, Tianyi Tang, Xiaolei Wang, Yupeng Hou,
Yingqian Min, Beichen Zhang, Junjie Zhang, Zican Dong, Yifan Du, Chen Yang,
Yushuo Chen, Zhipeng Chen, Jinhao Jiang, Ruiyang Ren, Yifan Li, Xinyu Tang,
Zikang Liu, Peiyu Liu, Jian-Yun Nie, and Ji-Rong Wen. 2023. A Survey of Large
Language Models. CoRR abs/2303.18223 (2023).
[50] Deyao Zhu, Jun Chen, Xiaoqian Shen, Xiang Li, and Mohamed Elhoseiny. 2023.
MiniGPT-4: Enhancing Vision-Language Understanding with Advanced Large
Language Models. CoRR abs/2304.10592 (2023).
[51] Yuqi Zhu, Xiaohan Wang, Jing Chen, Shuofei Qiao, Yixin Ou, Yunzhi Yao, Shumin
Deng, Huajun Chen, and Ningyu Zhang. 2023. LLMs for Knowledge Graph
Construction and Reasoning: Recent Capabilities and Future Opportunities. CoRR
abs/2305.13168 (2023).
[52] Yuqi Zhu, Xiaohan Wang, Jing Chen, Shuofei Qiao, Yixin Ou, Yunzhi Yao, Shumin
Deng, Huajun Chen, and Ningyu Zhang. 2023. LLMs for Knowledge Graph
Construction and Reasoning: Recent Capabilities and Future Opportunities. CoRR
abs/2305.13168 (2023).


Question:
What is the primary innovation introduced by Kg-GPT in reasoning over knowledge graphs?
A. Enhanced structured prompting and adaptive retrieval
B. Integration of graph embeddings into pre-training
C. Modification of the model architecture for graph processing
D. Acceleration of training convergence via novel optimization algorithms

Answer: A

To this end, we propose a new general framework, called KG-GPT, that uses LLMs’ reasoning capabilities to perform KG-based tasks. KG-GPT is similar to StructGPT (Jiang et al., 2023) in that both reason on structured data using LLMs. However, unlike StructGPT which identifies paths from a seed entity to the final answer entity within KGs, KG-GPT retrieves the entire sub-graph and then infers the answer. This means KG-GPT can be used not only for KGQA but also for tasks like KG-based fact verification.

KG-GPT consists of three steps: 1) Sentence (Claim / Question) Segmentation, 2) Graph Retrieval, and 3) Inference. During Sentence Segmentation, a sentence is partitioned into discrete sub-sentences, each aligned with a single triple (i.e. [head, relation, tail]). The subsequent step, namely Graph Retrieval, retrieves a potential pool of relations that could bridge the entities identified within the sub-sentences. Then, a candidate pool of evidence graphs (i.e. sub-KG) is obtained using the retrieved relations and the entity set. In the final step, the obtained graphs are used to derive a logical conclusion, such as validating a given claim or answering a given question.

Findings of the Association for Computational Linguistics: EMNLP 2023, pages 9410–9421
December 6-10, 2023 ©2023 Association for Computational Linguistics
KG-GPT: A General Framework for Reasoning on Knowledge Graphs
Using Large Language Models
Jiho Kim1, Yeonsu Kwon1, Yohan Jo2, Edward Choi1
1KAIST 2Seoul National University
{jiho.kim, yeonsu.k, edwardchoi}@kaist.ac.kr
yohan.jo@snu.ac.kr
Abstract
While large language models (LLMs) have
made considerable advancements in under-
standing and generating unstructured text, their
application in structured data remains underex-
plored. Particularly, using LLMs for complex
reasoning tasks on knowledge graphs (KGs)
remains largely untouched. To address this,
we propose KG-GPT, a multi-purpose frame-
work leveraging LLMs for tasks employing
KGs. KG-GPT comprises three steps: Sentence
Segmentation, Graph Retrieval, and Inference,
each aimed at partitioning sentences, retriev-
ing relevant graph components, and deriving
logical conclusions, respectively. We evalu-
ate KG-GPT using KG-based fact verification
and KGQA benchmarks, with the model show-
ing competitive and robust performance, even
outperforming several fully-supervised models.
Our work, therefore, marks a significant step
in unifying structured and unstructured data
processing within the realm of LLMs.1
1
Introduction
The remarkable advancements in large language
models (LLMs) have notably caught the eye of
scholars conducting research in the field of natural
language processing (NLP) (Brown et al., 2020;
Chowdhery et al., 2022; OpenAI, 2023a,b; Anil
et al., 2023). In their endeavor to create LLMs
that can mirror the reasoning capabilities inherent
to humans, past studies have primarily centered
their attention on unstructured textual data. This
includes, but is not limited to, mathematical word
problems (Miao et al., 2020; Cobbe et al., 2021;
Patel et al., 2021), CSQA (Talmor et al., 2019), and
symbolic manipulation (Wei et al., 2022). While
significant strides have been made in this area, the
domain of structured data remains largely unex-
plored.
1Code is available at https://github.com/jiho283/
KG-GPT.
Structured data, particularly in the form of
knowledge graphs (KGs), serves as a reservoir of in-
terconnected factual information and associations,
articulated through nodes and edges. The inherent
structure of KGs offers a valuable resource that
can assist in executing complex reasoning tasks,
like multi-hop inference. Even with these advan-
tages, to the best of our knowledge, there is no
general framework for performing KG-based tasks
(e.g. question answering, fact verification) using
auto-regressive LLMs.
To this end, we propose a new general frame-
work, called KG-GPT, that uses LLMs’ reasoning
capabilities to perform KG-based tasks. KG-GPT
is similar to StructGPT (Jiang et al., 2023) in that
both reason on structured data using LLMs. How-
ever, unlike StructGPT which identifies paths from
a seed entity to the final answer entity within KGs,
KG-GPT retrieves the entire sub-graph and then
infers the answer. This means KG-GPT can be
used not only for KGQA but also for tasks like
KG-based fact verification.
KG-GPT consists of three steps: 1) Sentence
(Claim / Question) Segmentation, 2) Graph Re-
trieval, and 3) Inference. During Sentence Seg-
mentation, a sentence is partitioned into discrete
sub-sentences, each aligned with a single triple (i.e.
[head, relation, tail]). The subsequent step, namely
Graph Retrieval, retrieves a potential pool of rela-
tions that could bridge the entities identified within
the sub-sentences. Then, a candidate pool of evi-
dence graphs (i.e. sub-KG) is obtained using the
retrieved relations and the entity set. In the final
step, the obtained graphs are used to derive a logi-
cal conclusion, such as validating a given claim or
answering a given question.
To evaluate KG-GPT, we employ KG-based
fact verification and KGQA benchmarks, both de-
manding complex reasoning that utilizes structured
knowledge of KGs. In KG-based fact verification,
we use FACTKG (Kim et al., 2023), which includes
9410
Figure 1: An overview of KG-GPT. The framework comprises three distinct phases: Sentence Segmentation,
Graph Retrieval, and Inference. The given example comes from FACTKG. It involves a 2-hop inference from
‘William_Anders’ to ‘Frank_Borman’, requiring verification through an evidence graph consisting of three triples.
Both ‘William_Anders’ and ‘Frank_Borman’ serve as internal nodes in DBpedia (Lehmann et al., 2015), while
“AFIT, M.S. 1962” acts as a leaf node. Moreover, artificial satellite represents the Type information absent from the
provided entity set.
various graph reasoning patterns, and KG-GPT
shows competitive performance compared to other
fully-supervised models, even outperforming some.
In KGQA, we use MetaQA (Zhang et al., 2018), a
QA dataset composed of 1-hop, 2-hop, and 3-hop
inference tasks. KG-GPT shows performance com-
parable to fully-supervised models. Notably, the
performance does not significantly decline with the
increase in the number of hops, demonstrating its
robustness.
2
Method
KG-GPT is composed of three stages: Sentence
Segmentation, Graph Retrieval, and Inference, as
described in Fig. 1.
We assume a graph G (knowledge graph con-
sisting of entities E and relations R), a sentence
S (claim or question), and all entities involved in
S, ES ⊂E are given. In order to derive a logical
conclusion, we need an accurate evidence graph
GE ⊂G, which we obtain in two stages, Sentence
Segmentation and Graph Retrieval. Furthermore,
all the aforementioned steps are executed employ-
ing the in-context learning methodology to max-
imize the LLM’s reasoning ability. The prompts
used for each stage are in Appendix A.
2.1
Sentence Segmentation
Many KG-based tasks require multi-hop reasoning.
To address this, we utilize a Divide-and-Conquer
approach. By breaking down a sentence into sub-
sentences that correspond to a single relation, iden-
tifying relations in each sub-sentence becomes eas-
ier than finding n-hop relations connected to an
entity from the original sentence all at once.
We assume S can be broken down into sub-
sentences: S1, S2, ..., Sn where Si consists of a
set of entities Ei ⊂E and a relation ri ∈R. Each
e(j)
i
∈Ei can be a concrete entity (e.g. William An-
ders in Fig. 1-(1)), or a type (e.g. artificial satellite
in Fig. 1-(1)). ri can be mapped to one or more
items in R, as there can be multiple relations with
similar semantics (e.g. birthPlace, placeOfBirth).
2.2
Graph Retrieval
To effectively validate a claim or answer a question,
it is crucial to obtain an evidence graph (i.e. sub-
9411
KG) that facilitates logical conclusions. In this
stage, we first aim to retrieve the corresponding
relations for each sub-sentence Si to extract GE.
For each Si, we use the LLM to map ri to one
or more items in R as accurately as possible. To
do so, we first define Ri ⊂R, which is a set of
relations connected to all e(j)
i
∈Ei according to the
schema of G (i.e. relation candidates in Fig. 1-(2)).
This process considers both the relations connected
to a specific entity and the relations associated with
the entity’s type in G. We further elaborate on the
process in Appendix B. Then, we feed Si and Ri to
the LLM to retrieve the set of final top-K relations
Ri,k. In detail, relations in Ri are linearized (e.g.
[location, birthYear, ..., birthDate]) and combined
with the corresponding sub-sentence Si to estab-
lish prompts for the LLM and the LLM generates
Ri,k = {r(1)
i
, ..., r(k)
i
} as output. In the final graph
retrieval step, we can obtain GE, made up of all
triples whose relations come from Ri,k and whose
entities come from Ei across all Si.
2.3
Inference
Then, we feed S and GE to the LLM to derive a
logical conclusion. In order to represent GE in the
prompt, we linearize the triples associated with
GE (i.e. [[head1, rel1, tail1], ..., [headm, relm,
tailm]]), and then concatenate these linearized
triples with the sentence S. In fact verification, the
determination of whether S is supported or refuted
is contingent upon GE. In question answering, the
LLM identifies an entity in GE as the most probable
answer to S.
3
Experiments
We evaluate our framework on two tasks that re-
quire KG grounding: fact-verification and question-
answering. A detailed description of experimental
settings can be found in Appendix C.
3.1
Dataset
3.1.1
FACTKG
FACTKG (Kim et al., 2023) serves as a practical
and challenging dataset meticulously constructed
for the purpose of fact verification, employing a
knowledge graph for validation purposes. It encom-
passes 108K claims that can be verified via DBpe-
dia (Lehmann et al., 2015), which is one of the
available comprehensive knowledge graphs. These
claims are categorized as either Supported or Re-
futed. FACTKG embodies five diverse types of
reasoning that represent the intrinsic characteris-
tics of the KG: One-hop, Conjunction, Existence,
Multi-hop, and Negation. To further enhance its
practical use, FACTKG integrates claims in both
colloquial and written styles. Examples of claims
from FACTKG can be found in Appendix D.
3.1.2
MetaQA
MetaQA (Zhang et al., 2018) is a carefully curated
dataset intended to facilitate the study of question-
answering that leverages KG-based approaches in
the field of movies. The dataset encompasses over
400K questions, including instances of 1-hop, 2-
hop, and 3-hop reasoning. Additionally, it covers a
diverse range of question styles. Examples of ques-
tions from MetaQA can be found in Appendix D.
3.2
Baselines
For evaluation on FACTKG, we use the same base-
lines as in Kim et al. (2023). These baselines are
divided into two distinct categories: Claim Only
and With Evidence. In the Claim Only setting, the
models are provided only with the claim as their
input and predict the label. For this setting, in ad-
dition to the existing baselines, we implement a
12-shot ChatGPT (OpenAI, 2023b) baseline. In
the With Evidence scenario, models consist of an
evidence graph retriever and a claim verification
model. We employ the KG version of GEAR (Zhou
et al., 2019) as a fully supervised model.
In our exploration of MetaQA, we use a selection
of prototypical baselines well-known in the field
of KGQA. These include models such as KV-Mem
(Xu et al., 2019), GraftNet (Sun et al., 2018), Em-
bedKGQA (Saxena et al., 2020), NSM (He et al.,
2021), and UniKGQA (Jiang et al., 2022), which
operate in a fully supervised fashion. Additionally,
we implement a 12-shot ChatGPT baseline.
4
Results & Analysis
4.1
FACTKG
We evaluated the models’ prediction capability for
labels (i.e. Supported or Refuted) and presented
the accuracy score in Table 1. As a result, KG-GPT
outperforms Claim Only models BERT, BlueBERT,
and Flan-T5 with performance enhancements of
7.48%, 12.75%, and 9.98% absolute, respectively.
It also outperforms 12-shot ChatGPT by 4.20%.
These figures emphasize the effectiveness of our
framework in extracting the necessary evidence for
claim verification, highlighting the positive impact
9412
Input Type
Training
Strategy
Methods
Accuracy
Claim Only
full
BERT
65.20
BlueBERT
59.93
zero-shot
Flan-T5
62.70
12-shot
ChatGPT
68.48
With Evidence
full
GEAR
77.65
12-shot
KG-GPT
72.68
8-shot
67.68
4-shot
59.53
Table 1: The performance of the models on FACTKG.
Except for ChatGPT and KG-GPT, all performances are
obtained from Kim et al. (2023).
Training
Methods
MetaQA
MetaQA
MetaQA
Strategy
1-hop
2-hop
3-hop
full
KV-Mem
96.2
82.7
48.9
GraftNet
97.0
94.8
77.7
EmbedKGQA
97.5
98.8
94.8
NSM
97.1
99.9
98.9
UniKGQA
97.5
99.0
99.1
12-shot
ChatGPT
60.0
23.0
38.7
12-shot
96.3
94.4
94.0
8-shot
KG-GPT
95.8
93.8
68.8
4-shot
94.7
92.8
46.6
Table 2: The performance of the models on MetaQA
(Hits@1). The best results for each task and those of
12-shot KG-GPT are in bold.
of the sentence segmentation and graph retrieval
stages. The qualitative results including the graphs
retrieved by KG-GPT are in Appendix E.1.
Nonetheless, when compared to GEAR, a fully
supervised model built upon KGs, KG-GPT ex-
hibits certain limitations. KG-GPT achieves an ac-
curacy score of 72.68%, which is behind GEAR’s
77.65%. This performance gap illustrates the ob-
stacles encountered by KG-GPT in a few-shot sce-
nario, namely the difficulty in amassing a suffi-
cient volume of information from the restricted
data available. Hence, despite the notable progress
achieved with KG-GPT, there is clear room for im-
provement to equal or surpass the performance of
KG-specific supervised models like GEAR.
4.2
MetaQA
The findings on MetaQA are presented in Table 2.
The performance of KG-GPT is impressive, scoring
96.3%, 94.4%, and 94.0% on 1-hop, 2-hop, and 3-
hop tasks respectively. This demonstrates its strong
ability to generalize from a limited number of ex-
amples, a critical trait when handling real-world
applications with varying degrees of complexity.
Stage
FactKG
MetaQA
MetaQA
MetaQA
1-hop
2-hop
3-hop
Sentence
39
3
63
100
Segmentation
Graph Retrieval
17
4
3
0
Inference
44
93
34
0
Table 3: Number of errors from 100 incorrect samples
across each dataset.
Interestingly, the performance of KG-GPT
closely matches that of a fully-supervised model.
Particularly, it surpasses KV-Mem by margins of
0.1%, 11.7%, and 45.1% across three distinct tasks
respectively, signifying its superior performance.
While the overall performance of KG-GPT is simi-
lar to that of GraftNet, a noteworthy difference is
pronounced in the 3-hop task, wherein KG-GPT
outperforms GraftNet by 16.3%. The qualitative
results including the graphs retrieved by KG-GPT
are in Appendix E.2.
4.3
Error Analysis
In both FACTKG and MetaQA, there are no cor-
responding ground truth graphs containing seed
entities. This absence makes a quantitative step-by-
step analysis challenging. Therefore, we carried
out an error analysis, extracting 100 incorrect sam-
ples from each dataset: FACTKG, MetaQA-1hop,
MetaQA-2hop, and MetaQA-3hop. Table 3 shows
the number of errors observed at each step. No-
tably, errors during the graph retrieval phase are
the fewest among the three steps. This suggests
that once sentences are correctly segmented, iden-
tifying relations within them becomes relatively
easy. Furthermore, a comparative analysis between
MetaQA-1hop, MetaQA-2hop, and MetaQA-3hop
indicates that as the number of hops increases, so
does the diversity of the questions. This heightened
diversity in turn escalates the errors in Sentence
Segmentation.
4.4
Ablation Study
4.4.1
Number of In-context Examples
The results for the 12-shot, 8-shot, and 4-shot
from the FACTKG and MetaQA datasets are re-
ported in Table 1 and Table 2, respectively. Though
there was a predicted improvement in performance
with the increase in the number of shots in both
FACTKG and MetaQA datasets, this was not uni-
formly observed across all scenarios.
Notably,
MetaQA demonstrated superior performance, ex-
9413
ceeding 90%, in both the 1-hop and 2-hop scenar-
ios, even with a minimal set of four examples. In
contrast, in both the FACTKG and MetaQA 3-hop
scenarios, the performance of the 4-shot learning
scenario was similar to that of the baselines which
did not utilize graph evidence. This similarity sug-
gests that LLMs may struggle to interpret com-
plex data features when equipped with only four
shots. Thus, the findings highlight the importance
of formulating in-context examples according to
the complexity of the task.
4.4.2
Top-K Relation Retrieval
Table 11 shows the performance according to the
value of k in FACTKG. As a result, performance
did not significantly vary depending on the value of
k. Table 12 illustrates the average number of triples
retrieved for both supported and refuted claims, de-
pending on k. Despite the increase in the number
of triples as the value of k grows, it does not im-
pact the accuracy. This suggests that the additional
triples are not significantly influential.
In MetaQA, the performance and the average
number of retrieved triples are also depicted in
Table 13 and Table 14, respectively. Unlike the
FACTKG experiment, as the value of k rises in
MetaQA, it appears that more significant triples are
retrieved, leading to improved performance.
5
Conclusion
We suggest KG-GPT, a versatile framework that
utilizes LLMs for tasks that use KGs. KG-GPT is
divided into three stages: Sentence Segmentation,
Graph Retrieval, and Inference, each designed for
breaking down sentences, sourcing related graph
elements, and reaching reasoned outcomes, respec-
tively. We assess KG-GPT’s efficacy using KG-
based fact verification and KGQA metrics, and
the model demonstrates consistent, impressive re-
sults, even surpassing a number of fully-supervised
models. Consequently, our research signifies a sub-
stantial advancement in combining structured and
unstructured data management in the LLMs’ con-
text.
Limitations
Our study has two key limitations. Firstly, KG-GPT
is highly dependent on in-context learning, and its
performance varies significantly with the number
of examples provided. The framework struggles
particularly with complex tasks when there are in-
sufficient or low-quality examples. Secondly, de-
spite its impressive performance in fact-verification
and question-answering tasks, KG-GPT still lags
behind fully supervised KG-specific models. The
gap in performance highlights the challenges faced
by KG-GPT in a few-shot learning scenario due to
limited data. Future research should focus on op-
timizing language models leveraging KGs to over-
come these limitations.
Acknowledgements
This work was supported by Institute of Informa-
tion & Communications Technology Planning &
Evaluation (IITP) grant (No.2019-0- 00075), Na-
tional Research Foundation of Korea (NRF) grant
(NRF-2020H1D3A2A03100945), and the Korea
Health Industry Development Institute (KHIDI)
grant (No.HR21C0198), funded by the Korea gov-
ernment (MSIT, MOHW).
References
Rohan Anil, Andrew M Dai, Orhan Firat, Melvin John-
son, Dmitry Lepikhin, Alexandre Passos, Siamak
Shakeri, Emanuel Taropa, Paige Bailey, Zhifeng
Chen, et al. 2023. Palm 2 technical report. arXiv
preprint arXiv:2305.10403.
Tom Brown, Benjamin Mann, Nick Ryder, Melanie
Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind
Neelakantan, Pranav Shyam, Girish Sastry, Amanda
Askell, et al. 2020. Language models are few-shot
learners. Advances in neural information processing
systems, 33:1877–1901.
Aakanksha Chowdhery, Sharan Narang, Jacob Devlin,
Maarten Bosma, Gaurav Mishra, Adam Roberts,
Paul Barham, Hyung Won Chung, Charles Sutton,
Sebastian Gehrmann, et al. 2022. Palm: Scaling
language modeling with pathways. arXiv preprint
arXiv:2204.02311.
Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian,
Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias
Plappert, Jerry Tworek, Jacob Hilton, Reiichiro
Nakano, et al. 2021. Training verifiers to solve math
word problems. arXiv preprint arXiv:2110.14168.
Gaole He, Yunshi Lan, Jing Jiang, Wayne Xin Zhao, and
Ji-Rong Wen. 2021. Improving multi-hop knowledge
base question answering by learning intermediate
supervision signals. In Proceedings of the 14th ACM
international conference on web search and data
mining, pages 553–561.
Dieuwke Hupkes, Mario Giulianelli, Verna Dankers,
Mikel Artetxe, Yanai Elazar, Tiago Pimentel, Chris-
tos Christodoulopoulos, Karim Lasri, Naomi Saphra,
9414
Arabella Sinclair, et al. 2022. State-of-the-art gen-
eralisation research in nlp: a taxonomy and review.
arXiv preprint arXiv:2210.03050.
Jinhao Jiang, Kun Zhou, Zican Dong, Keming Ye,
Wayne Xin Zhao, and Ji-Rong Wen. 2023. Structgpt:
A general framework for large language model to
reason on structured data.
Jinhao Jiang, Kun Zhou, Wayne Xin Zhao, and Ji-Rong
Wen. 2022. Unikgqa: Unified retrieval and reason-
ing for solving multi-hop question answering over
knowledge graph. arXiv preprint arXiv:2212.00959.
Jiho Kim, Sungjin Park, Yeonsu Kwon, Yohan Jo, James
Thorne, and Edward Choi. 2023. FactKG: Fact veri-
fication via reasoning on knowledge graphs. In Pro-
ceedings of the 61st Annual Meeting of the Associa-
tion for Computational Linguistics (Volume 1: Long
Papers), pages 16190–16206, Toronto, Canada. As-
sociation for Computational Linguistics.
Jens Lehmann, Robert Isele, Max Jakob, Anja Jentzsch,
Dimitris Kontokostas, Pablo N Mendes, Sebastian
Hellmann, Mohamed Morsey, Patrick Van Kleef,
Sören Auer, et al. 2015. Dbpedia–a large-scale, mul-
tilingual knowledge base extracted from wikipedia.
Semantic web, 6(2):167–195.
Shen-yun Miao, Chao-Chun Liang, and Keh-Yih Su.
2020. A diverse corpus for evaluating and developing
English math word problem solvers. In Proceedings
of the 58th Annual Meeting of the Association for
Computational Linguistics, pages 975–984, Online.
Association for Computational Linguistics.
OpenAI. 2023a. Gpt-4 technical report.
OpenAI. 2023b. Introducing chatgpt.
Arkil Patel, Satwik Bhattamishra, and Navin Goyal.
2021. Are NLP models really able to solve simple
math word problems? In Proceedings of the 2021
Conference of the North American Chapter of the
Association for Computational Linguistics: Human
Language Technologies, pages 2080–2094, Online.
Association for Computational Linguistics.
Apoorv Saxena, Aditay Tripathi, and Partha Talukdar.
2020. Improving multi-hop question answering over
knowledge graphs using knowledge base embeddings.
In Proceedings of the 58th Annual Meeting of the As-
sociation for Computational Linguistics, pages 4498–
4507, Online. Association for Computational Lin-
guistics.
Haitian Sun, Bhuwan Dhingra, Manzil Zaheer, Kathryn
Mazaitis, Ruslan Salakhutdinov, and William W Co-
hen. 2018. Open domain question answering using
early fusion of knowledge bases and text.
arXiv
preprint arXiv:1809.00782.
Alon Talmor, Jonathan Herzig, Nicholas Lourie, and
Jonathan Berant. 2019. CommonsenseQA: A ques-
tion answering challenge targeting commonsense
knowledge. In Proceedings of the 2019 Conference
of the North American Chapter of the Association for
Computational Linguistics: Human Language Tech-
nologies, Volume 1 (Long and Short Papers), pages
4149–4158, Minneapolis, Minnesota. Association for
Computational Linguistics.
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten
Bosma, Ed Chi, Quoc Le, and Denny Zhou. 2022.
Chain of thought prompting elicits reasoning in large
language models. arXiv preprint arXiv:2201.11903.
Kun Xu, Yuxuan Lai, Yansong Feng, and Zhiguo Wang.
2019. Enhancing key-value memory neural networks
for knowledge based question answering. In Proceed-
ings of the 2019 Conference of the North American
Chapter of the Association for Computational Lin-
guistics: Human Language Technologies, Volume 1
(Long and Short Papers), pages 2937–2947, Min-
neapolis, Minnesota. Association for Computational
Linguistics.
Yuyu Zhang, Hanjun Dai, Zornitsa Kozareva, Alexan-
der J Smola, and Le Song. 2018. Variational reason-
ing for question answering with knowledge graph. In
AAAI.
Jie Zhou, Xu Han, Cheng Yang, Zhiyuan Liu, Lifeng
Wang, Changcheng Li, and Maosong Sun. 2019.
GEAR: Graph-based evidence aggregating and rea-
soning for fact verification. In Proceedings of the
57th Annual Meeting of the Association for Compu-
tational Linguistics, pages 892–901, Florence, Italy.
Association for Computational Linguistics.
9415
A
Prompts
The prompts for Sentence Segmentation, Graph
Retrieval, and Inference can be found in Table 4,
Table 5 and Table 6, respectively.
B
Relation Candidates Extraction
Algorithm
B.1
FACTKG
In FACTKG, we develop a new KG called Type-
DBpedia. This graph comprises types found in DB-
pedia and connects them through relations, thereby
enhancing the usability of KG content. We describe
the detailed process of incorporating Ri using DB-
pedia and TypeDBpedia in Algorithm 1.
We denote the entities as E1 and E2 because the
sub-sentence always includes two entities in FAC-
TKG. Relations (e, DBpedia) represents the set
of relations connected to e in DBpedia. Similarly,
Relations (T, TypeDBpedia) represents the set of
relations connected to T in TypeDBpedia.
Algorithm 1: Extract Relation Candidates
Input: Entity Set E = {E1, E2},
DBpedia, TypeDBpedia
Output: Relation Candidates Ri
Initialization: T = ∅, RT = ∅, RE = ∅,
Ri = ∅
for each entity e in E do
if isType (e) then
T ←T ∪{e}
end
else
if isEmpty (RE) then
RE ←Relations (e, DBpedia)
end
else
RE ←RE ∩Relations (e,
DBpedia)
end
end
end
if not isEmpty (T) then
RT ←Relations (T, TypeDBpedia)
Ri ←RE ∩RT
end
else
Ri ←RE
end
B.2
MetaQA
For the n-hop task in MetaQA, Ri is constructed
from the relations within n-hops from the seed
entity.
C
Experimental Settings
We utilize ChatGPT2 (OpenAI, 2023b) across all
tasks, and to acquire more consistent responses, we
carry out inference with the temperature and top_p
parameters set to 0.2 and 0.1, respectively. For each
stage of KG-GPT, 12 pieces of training samples
were made into in-context examples and added
to the prompt. In FACTKG, there are over 500
existing relations (|R| > 500), so we set k = 5 for
Top-K relation retrieval. Conversely, in MetaQA,
there are only 9 existing relations (|R| = 9), so we
set k = 3.
D
Data Examples
Examples of data from FACTKG and MetaQA can
be found in Tables 7 and 8, respectively.
E
Qualitative Results
E.1
FACTKG
Table 9 includes the graphs retrieved by KG-GPT,
along with the prediction results, for five different
claims.
E.2
MetaQA
Table 10 includes the graphs retrieved by KG-GPT,
along with the prediction results, for nine different
questions.
F
Top-K Relation Retrieval
F.1
FACTKG
The performance and the average number of re-
trieved triples are depicted in Table 11 and Table 12,
respectively.
F.2
MetaQA
The performance and the average number of re-
trieved triples are depicted in Table 13 and Table 14,
respectively.
2https://platform.openai.com/docs/guides/gpt/chat-
completions-api
9416
Sentence Segmentation Prompt
Please divide the given sentence into several sentences each of which can be represented by one triplet. The generated
sentences should be numbered and formatted as follows: #(number). (sentence), (entity set). The entity set for each
sentence should contain no more than two entities, with each entity being used only once in all statements. The ‘##’
symbol should be used to indicate an entity set. In the generated sentences, there cannot be more than two entities in
the entity set. (i.e., the number of ## must not be larger than two.)
Examples)
Sentence A: Ahmad Kadhim Assad’s club is Al-Zawra’a SC.
Entity set: [‘Ahmad_Kadhim_Assad’ ## “Al-Zawra’a_SC”]
–>Divided:
1. Ahmad Kadhim Assad’s club is Al-Zawra’a SC., Entity set: [‘Ahmad_Kadhim_Assad’ ## “Al-Zawra’a_SC”]
...
Sentence L: An academic journal with code IJPHDE is also Acta Math. Hungar.
Entity set: [“Acta Math. Hungar.” ## “IJPHDE”]
–>Divided:
1. An academic journal is with code IJPHDE., Entity set: [‘academic journal’ ## “IJPHDE”]
2. An academic journal is also Acta Math. Hungar., Entity set: [‘academic journal’ ## “Acta Math. Hungar.”]
Your Task)
Sentence: <<<<CLAIM>>>>
Entity set: <<<<ENTITY_SET>>>>
–>Divided:
Table 4: Sentence Segmentation Prompt.
Relation Retrieval Prompt
I will give you a set of words.
Find the top <<<<TOP_K>>>>elements from Words set which are most semantically related to the given sentence.
You may select up to <<<<TOP_K>>>>words. If there is nothing that looks semantically related, pick out any
<<<<TOP_K>>>>elements and give them to me.
Examples)
Sentence A: Ahmad Kadhim Assad’s club is Al-Zawra’a SC.
Words set: [‘club’, ‘clubs’, ‘parent’, ‘spouse’, ‘birthPlace’, ‘deathYear’, ‘leaderName’, ‘awards’, ‘award’,
‘vicepresident’, ‘vicePresident’]
Top 2 Answer: [‘club’, ‘clubs’]
...
Sentence L: An academic journal with code IJPHDE is also Acta Math. Hungar.
Words set: [‘abbreviation’, ‘placeOfBirth’, ‘owner’, ‘coden’, ‘almaMater’, ‘dean’, ‘coach’, ‘writer’, ‘firstAired’,
‘director’, ‘formerTeam’, ‘starring’, ‘birthPlace’]
Top 2 Answer: [‘abbreviation’, ‘coden’]
Now let’s find the top <<<<TOP_K>>>>elements.
Sentence: <<<<SENTENCE>>>>
Words set: <<<<RELATION_SET>>>>
Top <<<<TOP_K>>>>Answer:
Table 5: Relation Retrieval Prompt. The prompt is used when retrieving a relation to retrieve a graph.
9417
Inference Prompt
You should verify the claim based on the evidence set.
Each evidence is in the form of [head, relation, tail] and it means “head’s relation is tail.”.
Verify the claim based on the evidence set. (True means that everything contained in the claim is
supported by the evidence.)
Please note that the unit is not important. (e.g. “98400” is also same as 98.4kg)
Choose one of {True, False}, and give me the one-sentence evidence.
Examples)
Claim A: Ahmad Kadhim Assad’s club is Al-Zawra’a SC.
Evidence set: [[‘Ahamad_Kadhim’, ‘clubs’, “Al-Zawra’a SC”]]
Answer: True, based on the evidence set, Ahmad Kadhim Assad’s club is Al-Zawra’a SC.
...
Claim L: The place, designed by Huseyin Butuner and Hilmi Guner, is located in a country,
where the leader is Paul Nurse.
Evidence set: [[“Baku_Turkish_Martyrs’_Memorial”, ‘designer’, “Hüseyin Bütüner and Hilmi Güner”],
[“Baku_Turkish_Martyrs’_Memorial”, ‘location’, ‘Azerbaijan’]]
Answer: False, there is no evidence for Paul Nurse.
Now let’s verify the Claim based on the Evidence set.
Claim: <<<<CLAIM>>>>
Evidence set: <<<<EVIDENCE_SET>>>>
Answer:
Table 6: Inference Prompt.
Reasoning Type
Claim Example
Graph
One-hop
AIDAstella was built by Meyer Werft.
s
m
r2
Conjunction
AIDA Cruise line operated the AIDAstella which was built by
Meyer Werft.
c
s
m
r3
r2
Existence
Meyer Werft had a parent company.
m
r1
Multi-hop
AIDAstella was built by a company in Papenburg.
s
x
p
r2
r4
Negation
AIDAstella was not built by Meyer Werft in Papenburg.
s
m
p
r2
r4
Table 7: Five different reasoning types of FACTKG. r1: parentCompany, r2: shipBuilder, r3: shipOperator, r4:
location, m: Meyer Werft, s: AIDAstella, c: AIDA Cruises.
9418
Task
Question Examples
1-hop
1. what does [Helen Mack] star in?
2. what is the main language in [Karate-Robo Zaborgar]?
3. who is the writer of [Boyz n the Hood]?
2-hop
1. who are movie co-directors of [Delbert Mann]?
2. what genres do the films starred by [Al St. John] fall under?
3. which films share the screenwriter with [King Arthur]?
3-hop
1. the films that share directors with the film [Catch Me If You Can] were in which languages?
2. who are the directors of the movies written by the writer of [She]?
3. when did the movies release whose actors also appear in the movie [Operator 13]?
Table 8: Question examples from MetaQA.
Type
Claim
Retrieved Graph
Prediction
Conjunction
Yes, Agra Airport is located in India
where the leader is Narendra Modi.
[‘Agra_Airport’, location, ‘India’],
[‘India’, leader, ‘Narendra_Modi’],
[‘India’, leaderName, ‘Narendra_Modi’],
[‘Narendra_Modi’, birthPlace, ‘India’]
Supported
Conjunction
I wasn’t aware that 103 Colmore Row,
located in Birmingham, with 23
floors, was completed in 1976.
[‘103_Colmore_Row’, location, ‘Birmingham’],
[‘103_Colmore_Row’, floorCount, “23”],
[‘103_Colmore_Row’, completionDate, “1976”],
[‘103_Colmore_Row’, buildingEndDate, “1976”]
Supported
Multi-hop
Alfredo Zitarrosa died in a city,
Uruguay (which has Raul Fernando
Sendic Rodriguez as leader).
[‘Alfredo_Zitarrosa’, deathPlace, ‘Uruguay’],
[‘Alfredo_Zitarrosa’, birthPlace, ‘Uruguay’],
[‘Montevideo’, country, ‘Uruguay’],
[‘Alfredo_Zitarrosa’, deathPlace, ‘Montevideo’],
[‘Alfredo_Zitarrosa’, birthPlace, ‘Montevideo’],
[‘Uruguay’, capital, ‘Montevideo’],
[‘Uruguay’, leader, ‘Raúl_Fernando_Sendic_Rodríguez’],
[‘Uruguay’, leaderName, ‘Raúl_Fernando_Sendic_Rodríguez’]
Supported
Negation
Al-Taqaddum Air Base is located
in Fallujah which is not in Iraq.
[‘Al-Taqaddum_Air_Base’, city, ‘Fallujah’],
[‘Al-Taqaddum_Air_Base’, cityServed, ‘Fallujah’],
[‘Fallujah’, country, ‘Iraq’]
Refuted
Multi-hop
A country is the location of the
Adare Manor, is run by leader
Enda Kenny and the natives are
Irish people.
[‘Adare_Manor’, country, ‘Republic_of_Ireland’],
[‘Republic_of_Ireland’, leader, ‘Enda_Kenny’],
[‘Republic_of_Ireland’, leaderName, ‘Enda_Kenny’],
[‘Adare_Manor’, locationCountry, ‘Republic_of_Ireland’],
[‘Republic_of_Ireland’, demonym, ‘Irish_people’]
Supported
Table 9: Qualitative results from FACTKG.
Task
Question
Retrieved Graph
Prediction
what films does [Brigitte Nielsen] appear in?
[‘Cobra’, starred_actors, ‘Brigitte Nielsen’],
[‘Red Sonja’, starred_actors, ‘Brigitte Nielsen’]
‘Cobra’
1-hop
can you name a film directed by
[Nikolai Müllerschön]?
[‘The Red Baron’, directed_by, ‘Nikolai Müllerschön’]
‘The Red Baron’
what type of film is [Six Shooter]?
[‘Six Shooter’, has_genre, ‘Short’]
‘Short’
when did the films starred by
[Deborah Van Valkenburgh] release?
[‘Mean Guns’, starred_actors, ‘Deborah Van Valkenburgh’],
[‘Mean Guns’, release_year, ‘1997’]
‘1997’
2-hop
which films have the same director of
[The Duellists]?
[‘The Duellists’, directed_by, ‘Ridley Scott’],
[‘The Counselor’, directed_by, ‘Ridley Scott’]
‘The Counselor’
what genres are the movies written by
[Robert Kenner] in?
[‘Food, Inc.’, written_by, ‘Robert Kenner’],
[‘Food, Inc.’, has_genre, ‘Documentary’]
‘Documentary’
what are the genres of the movies whose
writers also wrote
[The Lives of a Bengal Lancer]?
[‘The Lives of a Bengal Lancer’, written_by, ‘John L. Balderston’],
[‘Frankenstein’, written_by, ‘John L. Balderston’],
[‘Frankenstein’, has_genre, ‘Horror’]
‘Horror’
3-hop
when did the movies starred by
[Seeking Justice] actors release?
[‘Seeking Justice’, starred_actors, ‘Nicolas Cage’],
[‘World Trade Center’, starred_actors, ‘Nicolas Cage’],
[‘World Trade Center’, release_year, ‘2006’]
‘2006’
what types are the movies starred by actors
in [A Thin Line Between Love and Hate]?
[‘A Thin Line Between Love and Hate’, directed_by, ‘Martin Lawrence’],
[“Big Momma’s House”, starred_actors, ‘Martin Lawrence’],
[“Big Momma’s House”, has_genre, ‘Comedy’],
[‘A Thin Line Between Love and Hate’, written_by, ‘Martin Lawrence’],
[‘A Thin Line Between Love and Hate’, starred_actors, ‘Martin Lawrence’]
‘Comedy’
Table 10: Qualitative results from MetaQA.
9419
Input Type
Method
k
Accuracy
With Evidence
KG-GPT
3
72.12
5
72.68
10
72.40
Table 11: Performance changes according to the change
in the k value in FACTKG.
k
FactKG
Supported
Refuted
3
1.93
1.08
5
2.52
1.39
10
3.13
1.86
Table 12: The average number of retrieved triples
changes according to the change in the k value in FAC-
TKG.
Method
k
MetaQA
1hop
MetaQA
2hop
MetaQA
3hop
1
97.0
93.4
89.4
KG-GPT
3
96.3
94.4
94.0
5
96.7
95.0
93.7
Table 13: Performance changes according to the change
in the k value in MetaQA.
k
MetaQA
1-hop
2-hop
3-hop
1
2.06
4.43
3.25
3
2.16
4.53
3.59
5
2.12
4.51
3.65
Table 14: The average number of retrieved triples
changes according to the change in the k value in
MetaQA.
9420
Motivation
Practical
Cognitive
Intrinsic
Fairness
4.1 4.2
Generalisation type
Compositional
Structural
Cross Task
Cross Language Cross Domain
Robustness
4.1 4.2
4.1 4.2
Shift type
Covariate
Label
Full
Assumed
4.1 4.2
Shift source
Naturally occuring
Partitioned natural
Generated shift
Fully generated
4.1 4.2
Shift locus
Train–test
Finetune train–test
Pretrain–train
Pretrain–test
4.1 4.2
Table 15: GenBench Evaluation Card from Hupkes et al. (2022).
9421