Unifying Large Language Models and Knowledge Graphs: A Roadmap综述笔记-入门-知识图谱KG-大模型LLM
论文信息
标题:Unifying Large Language Models and Knowledge Graphs: A Roadmap
作者:Shirui Pan
摘要
LLMs如chatGPT和GPT4凭借其涌现能力和泛化特性对自然语言理解和影响人工智能领域带来了深远的影响
然而作为一个黑箱系统LLMs通常难以捕获与生成真实世界中的复杂信息相比之下如知识库系统等类型的知识图谱则具备明确的结构化组织方式能够系统地存储大量事实信息 KGs通过整合外部知识资源不仅有助于提升大语言模型在推理过程中的透明度而且还能有效拓展其理解能力此外在动态扩展能力方面 KGs仍显不足现有的研究方法在处理新领域知识或未知数据时仍面临诸多限制因此Aiming to integrate both LLMs and KGs while leveraging their respective strengths represents a promising direction for overcoming these challenges
本文中,我们构建了整合LLMs与知识图谱的规划框架.该规划框架由三个核心模块构成:第一部分介绍了一种基于LLMs的语言模型构建方法,第二部分探讨如何整合知识图谱与LLMs技术,第三部分提出了一种基于知识图谱的知识抽取方法.
KG整合到大语言模型中:在大语言模型的前期训练阶段及推理过程中融入知识图谱(Knowledge Graph),从而提升其对已学知识的理解能力。
基于大语言模型的知识图谱增强型知识图谱(Knowledge Graph Enhanced Large Language Model)能够协助完成多种任务包括向量化表示、填充空白节点、建立关系网络以及构建问答系统等。
整合后的模型架构通过数据与知识驱动实现了双向推演机制,在提升自身能力的同时也推动了知识图谱技术的发展。
我们在路线图中回顾并总结了这三个框架内的现有研究成果,并对未来研究方向进行了展望。
背景
KGs
优点
- 结构化
- 准确率
- 确定性
- 可解释性
- 领域专业知识
缺点
- 不够完整
- 语言理解能力匮乏
- 对没见过的数据泛化性差
LLMs
优点
- 通用知识
- 语言处理
- 泛化性强
缺点
- 隐性的知识体系
- 错觉或表象的存在
- 迟疑不决的状态
- 未能获取新的专业知识
KGs中现有方法的主要缺陷体现在以下几个方面:
- 它们难以有效应对新兴事物及其关联
- 缺乏对丰富文本数据资源的充分利用
- 泛化性能较弱
LLM可以帮助KG更好的利用和理解文本信息。
大模型分类
| encoder-only | encoder-decoder | decoder-only | |
|---|---|---|---|
| 代表模型 | Bert | T5 | GPT |
| 训练方法 | predict masked words | masking and predicting spans of masking words | predict the next word |
| 下游任务 | 文本分类,实体命名 | summariaztion, translation, and question answering | generally perform downstream tasks from a few examples or simple instructions |
知识图谱分类
| encyclopedic KGs | commonsense KGs | domain-specific KGs | multimodal KGs |
|---|---|---|---|
| 百科知识图谱 | 常识知识图谱 | 领域知识图谱 | 多模态知识图谱 |
研究内容
LLMs和KGs统一的三种通用框架:
- KG-enhanced LLMs
- LLM-augmented KGs
- Synergized LLMs + KGs
KG-enhanced LLMs
- 通过在预训练阶段整合KGs
- 通过在推理阶段整合KGs
- 借助KGs对事实进行解释,并指导LLMs的推理过程
LLM-augmented KGs
将LLMs作为 text encoder用于知识图谱的相关任务。
- 利用大型语言模型(LLMs)生成语料库中的文本表示,并将其融入知识图谱(KGs)的表示能力中。
- 借助现有的知识在LLMs中构建语义关系网络。
- 构造一个KG促进系统设计了一个将结构化知识图谱转换为LLMs可理解格式的方法。
Synergized LLMs + KGs
包含四个layer:
-
Date
- LLMs和KGs分别处理文本和结构化数据以及多模态数据 -
Synergized Model
-
Technique
-
Application
- 搜索引擎、推荐系统、AI助手

KG-ENHANCED LLMS
KG-enhanced LLM Pre-training
- 将知识图谱整合到训练目标中(Integrating KGs into training objective)
- 通过知识图谱提供的结果来计算mask的概率(利用知识图谱结果分配mask的概率)
- 基于知识图谱信息筛选出关键实体进行遮蔽处理(使用知识图谱来选择实体进行遮蔽)
- 通过知识图谱获取被遮蔽实体的相关干扰项(使用知识图谱获取遮蔽实体的干扰项)
- 在预训练任务中进行实体预测(实体预测 (预训练任务))
- 在tokens级别的与entities级别的平衡中优化权重设置(平衡token-level和entity-level训练比重)
- 将文本与其关联的知识 entities 一同作为输入数据... (将文本和相关联的实体一起作为输入...)
- Incorporating knowledge graphs into the input streams of large language models (LLMs).(将知识图谱整合到大语言模型(LLMs)的输入流中)
- Embedding knowledge graphs into separate fusion pathways of LLMs.(将知识图谱嵌入到LLMs的独立融合路径中)
局限性:更新数据就必须得重新预训练
KG-enhanced LLM inference
-
Dynamic Knowledge Fusion
- 加强text和entity的interaction -
Retrieval-Augmented Knowledge Fusion
- 信息检索与文本相关的知识图谱(基于零参数的模型)被提取出来,并被用作输出生成器的隐藏变量。
- 在生成过程的不同阶段采用不同数量的信息检索结果作为支撑作用,并能显著提升整体引导能力。
KG-enhanced LLM Interpretability
- KGs for LLM Probing
探索和验证存储在LLMs的知识。
通过prompt将知识图谱中存储的事实表达为断言,并利用LLMs作为评估工具来预测可能缺失的知识实体。
LPAQA:在LAMA中设置"prompt"是人工操作的结果,在研究领域中引入了一种自动生成"prompt"方法
后续的研究都是改进prompt,整体方法都是基于LAMA。
根据实验研究发现,在面对不常用的知识时LLMs会表现出较差的记忆能力 虽然尝试扩大模型规模 但仍然未能取得显著进展
- KGs for LLM Analysis
The method is intended to address these types of inquiries, including how LLMs produce outcomes, as well as how their functionality and architecture operate.
KagNet and QA-GNN:在每次推理过程中都利用知识图谱与语言模型(LLMs)生成的结果建立关联。
在KGs中提取事实并采用因果启发式的方法进行分析。结果显示LLMs模型更倾向于采用固定模式的词语结构以解决信息缺口的问题,并不依赖于与知识相关联的术语或表达。
因果启发式分析 causal-inspired analysis

LLM-AUGMENTED FOR KGS
integrate LLMs for:
- embedding technology
- achieving completion of tasks
- development process of structures
- Knowledge Graph to Text Generation Process
- answer retrieval mechanism for queries

LLM-augmented KG Embedding
utilize LLMs to enhance the representations of KGs through transforming the textual descriptions of entities and relations into structured data(利用LLMs来增强知识图谱的表示通过将实体和关系的文本描述转化为结构化数据)
Pretrain-KGE:

KEPLER: 提出一个统一的模型用于知识嵌入和预训练表示。
Nayyeri et al.:
Huang et al.: 使用LLMs和图像、图嵌入去学习多模态知识图谱嵌入。
CoDEx: 基于LLMs开发一个新的损失函数以指导KGE模型被用来指导其测量三元组的可能性。
LLMs for joint Text and KG Embedding
上面的方法是借助LLMs进行编码,然后用专门的KGE模型去嵌入。
这个方法是直接用LLMs融合图结构和文本信息到嵌入空间。
Rather than relying on KGE models to analyze graph structures, another approach leverages LLMs to integrate both structural and textual data seamlessly within an embedding framework.

kNN-KGE:针对每个三元组将其表示为一个句子;随后将尾实体mask输入到模型中进行处理以推断出尾实体的身份;经过训练后,在LLMs中的相应位置编码被设计用于表示实体及其关联关系。
LMKE: 借助LLMs提出一种对比学习,用于改善KGE的嵌入生成学习。
LambdaKG: 为了更好地捕捉图结构的信息,在单步邻居实体中进行采样操作。将这些token连接起来,并作为一个完整的句子输入到LLM中。
LLM-augmented KG Completion
LLM as Encoders (PaE)
采用单编码器模型对实体与文本信息进行编码,并随后将编码结果传递给预测头以评估三元组的一致性。其中,预测头可选用多层感知机(MLP)或传统的知识图谱评分函数。

a.Joint Encoding
KG-BERT通过将三元组转换为文本并使用LLM进行编码后,在分类器中输入最后一层数据从而识别出该三元组的存在可能性。
MTL-KGC: 融入额外的辅助任务用于模型训练,如关系预测(PR)相关性排名(RR)。
该方法(PKGC)将包含三元组及其相关支持信息的内容转化为遵循预先设定模式的自然语言陈述以测定三元组(h,r,t)的有效性;随后将这些生成的自然语言陈述输入到大型语言模型中进行二分类训练;其中支持信息是通过verbalizing函数获取并参与这一过程。
LASS: 提出了两种嵌入:语义嵌入和结构嵌入。
b.MLM Encoding (Masked Language Model ,MLM)
MEMKGC: 该方法结合LLM技术用于mask尾实体预测,并在多任务学习框架下涉及实体识别以及基于实体文本描述的超类别(super-class)识别。
OpenWorld KGC: 构建了两个序列型的MLM模块组
- 实体描述预测(EDP)旨在通过给定文本描述来推导对应的实体。
- 基于不完整的三元组预测(ITP)则通过补充缺失的部分来推断出可能存在的实体。
c.Separated Encoding
将三元组(h, r, t)拆分为(h, r)与t两个部分。接着分别将这两个子部分输入到LLM中进行分析。最后通过隐藏层的连接机制评估这两个子部分之间的关联程度。
StAR: 使用Siamese-style text encoder对文本进行处理后生成distinct contextual representations.
- LLM as Generators (PaG)
SimKGC: 基于Siamese文本编码器设计了一种新的知识图谱生成方法,在这一框架下对比学习被应用于编码过程中的各个步骤;首先,在对三元组进行编码表示时采用了一种双分支结构;其次,在分析正负样本间的相似性时引入了自适应加权机制以提升模型性能
CSPromp-KG: 基于参数高效的提示学习(parameter-efficient prompt learning)技术来防止过拟合文本信息
Parameter-efficient prompt learning旨在一种在模型参数数量有限的情况里有效地提取提示信息的方法。
LP-BERT: 采用了Masked Language Model Encoding以及Separated Encoding这两种编码策略。主要包含预训练与微调两个主要的学习阶段。在预训练阶段采用Masked Language Model机制,在微调过程中对各个编码信息应用对比学习方法。
LLM as Generators (PaG)

GenKGC: 命名了一种关系引导演示技术;这种技术包含具有相同属性或关联的不同三元组;这些三元组设计用于帮助模型学习其内部知识。
KGT5: 采用T5的简单小架构,不采用预训练的参数,而是随机初始化。
KG-S2S: KG-S2S通过新增一个特定的属性来优化现有标准三元组的知识图谱结构,并将其扩展为四元组形式(h, r, t, m),其中m代表新增的一个属性。这种设计能够有效适应不同领域的知识图谱需求。
AutoKG: 对于闭源的大语言模型(LLM),AutoKG基于prompt机制,并输入头实体及预设关系模式的基础上推导出尾部实体。
Comparison between PaE and PaG
PaE:
- 为LLMs新增一个预测头
- 固定LLMs参数后仅需训练预测头
- 推理阶段需计算每个实体的得分,并输出得分最高的那个。
- 模型无法生成从未见过的实体类型。
PaG:
- 具备直接使用的优势
- 高效生成尾实体;
- 能够生成未曾见过的实体。
- 如何设计高质量的prompt
LLM-augmented KG Construction
包含以下步骤:
基于实体识别技术实现核心引用解决的方法用于关系抽取任务,并通过端到端知识图谱构建过程从LLMs中提取知识图谱
1-3是常规步骤。

Entity Discovery
从非结构化的数据中发现并提取实体。
Recognizing Named Entities (NER): identifying and tagging named entities within textual data with their locations and types.
根据跨度将NER分为三个子任务:
-
Flat NER:对每个token进行单独标注。
-
Nested NER:Nested NER指的是命名实体在识别过程中能够形成包含关系的过程。
- span-based method:span-based方法则通过枚举所有可能候选跨度,并将其归类为具体实体类型(包括非实体类别)。
- Parsing-based method:Parsing-based方法不仅揭示了嵌套NER与成分句法分析之间的相似性(能够预测出嵌套以及互不重叠的关系),还成功地将这种语义关系应用到了NER模型中。- Discontinuous NER:命名实体跨度是不连续的
GenerativeNER: 通过序列生成机制解决不同NER子任务
This system employs a sequence-to-sequence large language model(LSTM-based) equipped with a pointer mechanism in order to generate an entity sequence.
指针机制(Pointer Mechanism): 一种特殊的序列生成注意力模型,在处理序列数据时能够直接定位到输入序列的关键位置以获取信息,并不依赖于生成固定词汇表中的词来完成任务。其核心在于通过关注输入序列特定位置的元素来实现对后续输出结果的指导作用;其结果表明:模型通过识别并聚焦输入序列的关键点从而实现了对目标数据的有效捕捉与处理过程。
Entity Typing(ET)和命名实体识别(NER)是两个相关但不同的任务。
- NER 任务的主要目标是在文本中识别并分类具有特定意义的命名实体。
- 另一个任务的主要目标是为给定文本中的实体赋予相应的类型标签,并不仅仅局限于确定其边界。
- 另一个任务依赖于NER的结果来明确实体的存在情况。
Entity Typing (ET): 基于语言模型的编码机制将提及、文本背景以及可能的类型进行编码处理。
LDET: 用ELMo进行嵌入;LSTM进行序列编码
BOX4Types:强调type dependency的重要性,并通过BERT模型将这些隐藏向量及其对应的类型进行编码。
LRN: 探究标签间的内在与外在关联。通过BERT提取上下文及实体的表示后, 对输出向量进行处理以完成逻辑推理过程, 并结合归纳推理方法完成整体分析。
MLMET: 为BERT MLM构建输入样本,使用[mask]标签来预测类型标签。
LITE: 将ET视为文本推理任务。
Entity Linking (EL): 实体识别。通过将文本中的实体提及与知识图谱中的相应实体进行对应。
ELQ: 采用先进的双编码器架构设计,在同一过程中集成执行提及检测与链接任务,从而为 downstream问答系统提供可靠的支持。
该领域:将实体提及识别任务从欧几里得空间匹配转换为一个序列对序列(sequence-to-sequence)模型。
基于传统技术,许多现有的实体链接系统都采用了基于向量空间的技术进行实体识别。
为了实现这一目标,在构建系统的初期阶段,会将实际存在的实体名称与知识库中的概念通过数学模型嵌入到一个统一的向量空间中。
接下来系统会通过计算它们在该空间中的距离或相似度值来判断是否属于同一实体。
Coreference Resolution(CR)
找到文本中相同实体或事件的所有表达式(即mentions)。
a.Within-document CR
b.Cross-document CR
Relation Extraction(RE)
a.Sentence-level RE
Curriculum-RE::在训练过程中逐渐增加数据集的难度。
b.Document-level RE (DocRE)
End-to-End KG Construction
使用两个大型语言模型(LLMs)来构建知识图谱(KGs)。
construct knowledge graphs from raw text data, which is composed of two specialized language models each equipped with fine-tuning capabilities. Initially, these models undergo training on named entity recognition tasks to enable them to identify entities within raw text data. Subsequently, an innovative approach utilizing a 2-model BERT architecture specifically designed for relation extraction is proposed. This architecture incorporates two distinct BERT-based classifiers: one dedicated to identifying relation types and another that employs binary classification to determine directional relationships between entity pairs. Once predicted triples and relations are generated, they are utilized to systematically build and populate the knowledge graph.
通过一个精炼的语言模型来校准由大型语言模型构建的知识图谱
PiVE [165] introduces an iterative verification framework with prompting, employing a smaller LLM such as T5 to correct errors within knowledge graphs generated by a larger LLM, for instance, ChatGPT.
Distilling Knowledge Graphs from LLMs

LLM-augmented KG-to-text Generation
目标:
produce precise and detailed textual descriptions that faithfully represent or clearly convey the input knowledge graph data.
问题:
insufficient training and poor generation quality.
方法
- utilize knowledge from large language models
- build a large-scale, lightly supervised KG-text corpus
leverage knowledge from LLMs

缺点:未集成KGs中的图语义信息,主要依赖于LLMs的知识来建立实体间的关系,并最终生成文本内容。
Constructing large weakly KG-text aligned Corpus
Knowledge Graph to graph transformation dataset derived from Wikipedia contains 1.3 million unsupervised KG-to-graph training examples proposed by Jin et al. in year 172.
Jin et al. [172] offer a 1.3 million-scale unsupervised KG-to-graph training dataset within the Wikipedia corpus.
LLM-augmented KG Question Answering
目标:
The system is designed to determine solutions for English or other natural language queries by leveraging organized data within structured knowledge bases.
难点:
retrieve related facts and extend the reasoning advantage of KGs to QA
LLMs as Entity/relation Extractors
Recognize entities and relationships mentioned in natural language-based questions by accessing relevant facts stored in KGs.
使用LLMs作为关系预测的分类器
Lukovnikov et al. pioneered the application of LLMs as a means of performing relational reasoning tasks.
利用LLMs识别实体及其关联,随后,在构建的知识图谱中利用提取的 entity-relation 对查询相应的答案
utilize large language models (LLMs) to identify named entities and relationships. Once these entity-relation pairs are extracted, they can query the answer within knowledge graphs (KGs).
LLMs as Answer Reasoners
to reason over the retrieved facts and generate answers
LLMs直接输出答案
The system combines the retrieved facts alongside queries and potential response candidates, where a represents potential answer candidates. It then inputs these into LLMs in order to forecast answer scores.

SYNERGIZED LLMS + KGS
Knowledge Representation
将LLMs中的知识和KGs中的知识对齐。
organize the information from the text corpus and KGs to model them within a coherent framework.

Reasoning
研究人员协同大型语言模型和知识图谱以自动执行多种应用的推理任务。
FUTURE DIRECTIONS
KGs for Hallucination Detection in LLMs
Integrate large language models and knowledge graphs to create a generalized fact-checking model capable of detecting hallucinations across domains.
KGs for Editing Knowledge in LLMs
update their internal knowledge base responding to changes in real-world situations.
KGs for Black-box LLMs Knowledge Injection
The process of enabling efficient knowledge injection into black-box LLMs remains a significant challenge for us to address.
Numerous state-of-the-art large-scale language models, such as ChatGPT, exclusively offer APIs accessible only to users and developers, rendering them effectively opaque or untraceable to the public.
Multi-Modal LLMs for KGs
Making full use of representations across various modalities would pose a major obstacle for future research in KGs.
connecting the dots between multiple-modality large language models and knowledge graph structure poses a significant hurdle in this domain, calling for continued exploration and innovation.
LLMs for Understanding KG Structure
The scale of the KGs poses a challenge in linearizing the entire KG as input data.
Construct LLMs that can understand the knowledge graph's structure in a direct manner and perform reasoning tasks on this structure.
Synergized LLMs and KGs for Birectional Reasoning
Through combining their strengths, we can develop a robust system that leverages both the contextual understanding inherent to LLMs and the structured knowledge representation inherent to KGs.
