Knowledge Graph Enhanced Large Language Model Editing Strategies

Knowledge Graph Enhanced Large Language Model Editing Strategies

πŸ’‘ Paper Title:

Knowledge Graph Enhanced Large Language Model Editing, ACL Findings, 2024

πŸ”— Paper Link:

https://arxiv.org/abs/2402.13593

Background and Motivation

Large language models excel in various tasks due to their powerful generative capabilities and the rich knowledge they contain. However, issues such as outdated knowledge and factual errors may exist within these models, limiting their reliability in practical applications. In critical fields like medical diagnosis or legal consulting, outdated and incorrect knowledge can lead to severe consequences. Accurately and effectively updating the knowledge within large models has become an important problem that needs to be addressed. Traditional fine-tuning methods can update models but face issues like parameter corruption and catastrophic forgetting. To tackle these problems, knowledge editing tasks have emerged, aiming to precisely update specific knowledge within large models without negatively impacting unrelated knowledge or the overall performance of the model.

Despite existing research achieving some results in knowledge editing, challenges remain in capturing knowledge changes related to the target knowledge. Specifically, current research focuses on editing individual pieces of knowledge, such as modifying knowledge from (s,r,o) to (s,r,o*). However, changing a single piece of knowledge often triggers related changes in other knowledge. For example, modifying “LeBron James plays for the Miami Heat” to “LeBron James plays for the Los Angeles Lakers” necessitates updating “LeBron James works in Miami” to “LeBron James works in Los Angeles”. Existing editing methods fail to account for the impact of related knowledge changes caused by modifying target knowledge, which limits the generalized capability of the edited model. The black-box nature of large models makes it extremely complex to uncover the relationships between internal knowledge, further complicating the detection of these related knowledge changes during the editing process.

Knowledge Graph Enhanced Large Language Model Editing Strategies

Figure 1 An example of knowledge editing in large models. A single edit may trigger changes in related knowledge.

To solve this problem, we propose a knowledge graph enhanced model editing method (GLAME, Graphs for LArge language Model Editing). GLAME introduces external knowledge graphs to capture the changes in related knowledge brought about by target knowledge updates, thereby alleviating the inability to explicitly model knowledge dependencies due to the black-box nature of large models. Additionally, we designed an editing module for graph-structured data, allowing for the editing of changing related knowledge into specific parameters of the large model, achieving collaborative editing of target knowledge and its related knowledge, breaking the limitations of existing methods that can only edit isolated knowledge and struggle to generalize.

Model Method

The overall architecture of the GLAME model is illustrated in the following figure, consisting of two main modules:
(1) Knowledge Graph Enhancement Module (KGA): Constructs subgraphs using external knowledge graphs to capture changes in related knowledge caused by knowledge editing;
(2) Graph Data Editing Module (GKE): Injects edited knowledge and its changing related knowledge into specific parameters of the large model using a relational graph neural network (RGNN) encoded subgraph.

Knowledge Graph Enhanced Large Language Model Editing Strategies

Figure 2 Schematic diagram of the GLAME model architecture.

Each module operates as follows:
  • Knowledge Graph Enhancement Module (KGA)
The KGA module constructs a subgraph for each editing sample using external knowledge graphs. This subgraph contains the new edited knowledge and changing related knowledge:

a. Target Knowledge Matching and Sampling: In the knowledge editing task, each editing sample contains a subject s, relation r, original object o, and a new object o*. To capture the affected knowledge, we match the most relevant entity in the external knowledge graph (like Wikidata) using o*. Then, centered on this entity, we sample its neighboring entities and their relations to obtain a subgraph containing new related relations.

b. Knowledge Representation Extraction: We extract the hidden vectors corresponding to the entities and relations in the subgraph from the shallow layers of our large model as the initial representation of nodes and edges in the subgraph, allowing for explicit modeling of dependencies between knowledge representations.

  • Graph Data Editing Module (GKE)
The GKE module primarily injects graph-structured knowledge (subgraph) containing changes in related relations into the parameters of the large model to complete knowledge editing. Based on the ROME framework, we need to calculate the original representation of the large model for the edited subject at the localization layerKnowledge Graph Enhanced Large Language Model Editing Strategiesand the target knowledge representationKnowledge Graph Enhanced Large Language Model Editing Strategiesto complete the editing:
a. Encoding Subgraph to Enhance Subject Representation: Using a relational graph neural network (RGNN), we encode the constructed subgraph to enhance the representation of subject s. The enhanced representation contains not only the target editing knowledge but also information about new related knowledge.
b. Original Representation Extraction: When the large model processes the subject entity, we extract the hidden vector corresponding to the entity as the knowledge representation of the subject in the large modelKnowledge Graph Enhanced Large Language Model Editing Strategies.
c. Parameter Update: After obtaining the original representationKnowledge Graph Enhanced Large Language Model Editing Strategiesand new representationKnowledge Graph Enhanced Large Language Model Editing Strategies, we can achieve the mapping relationship between the two representations in the intermediate layer of the large model based on the ROME framework, resulting in updated model parameters after establishing the new mappingKnowledge Graph Enhanced Large Language Model Editing Strategies, thus updating specific parameters of the large model:

Knowledge Graph Enhanced Large Language Model Editing Strategies

Experimental Results

The experimental results of each model on the CounterFact, CounterFactPlus, and MQuAKE datasets are shown in Tables 1 and 2:

Table 1 Performance metrics of each model on the CounterFact and CounterFactPlus datasets

Knowledge Graph Enhanced Large Language Model Editing Strategies

Table 2 Performance metrics of each model on the MQuAKE dataset

Knowledge Graph Enhanced Large Language Model Editing Strategies

The experimental results show that GLAME achieved the highest performance in the overall evaluation metric Edit Score on the CounterFact and CounterFactPlus datasets. Compared to the existing best baseline model, GLAME improved the Portability Score, which reflects the ability to capture related knowledge, by 11.76% and 10.98%, respectively. In the MQuAKE dataset, GLAME’s average metrics improved by 5.9% across different difficulty tasks, with increases of 12.45% and 16.75% on the most complex 4-hops reasoning task.
To prove that simply introducing more additional information does not necessarily improve performance, we designed two baseline methods, ROME-KG and MEMIT-KG, which directly edit the multi-hop information contained in the graph into the large model using the existing effective methods ROME and MEMIT. Compared to the original methods, ROME-KG and MEMIT-KG showed a significant decline in performance. ROME-KG requires multiple adjustments to the model’s parameters to edit higher-order relations, which may damage the original model parameters; MEMIT-KG indiscriminately introduces a large amount of information into the LLM, potentially affecting the strength of constraints on the target knowledge. GLAME, suitable for graph structures, can integrate multiple related knowledge changes into the model with a single edit, greatly reducing damage to the model and enhancing the utilization of external knowledge graphs.

Contributions of This Paper

  • Explored the importance of capturing the changes in related relationships triggered by a single edit during the knowledge editing process. By collaboratively editing target knowledge and its related knowledge, the generalized capability of the edited large model is enhanced.

  • Introduced external knowledge graphs into the knowledge editing task of large language models, utilizing the structured characteristics of knowledge graphs to explicitly relate changes in target knowledge and its related knowledge. Proposed a new knowledge editing method GLAME, achieving collaborative editing of target knowledge and its related knowledge through two key modules.

  • Demonstrated improvements in editing effectiveness and generalized capability of GLAME through experiments on multiple standard datasets.

Leave a Comment