KG -Adapter: Enabling Knowledge Graph Integration in Large Language Models through Parameter-Efficient Fine-Tuning (2024)

Abstract: Although large language models (LLMs) show remarkable capabilities and generalizability across various tasks, they are criticized for lack of expertise. One promising solution is to combine knowledge graphs (KGs) with LLMs, and recent studies focus on integrating KGs into LLMs through prompt-based methods. However, these approaches fail to use the structural information of the KGs, suffer from the problem of knowledge conflict, and over-reliance on super LLMs. To address these challenges, we propose KG-Adapter, a parameter-level KG integration method based on parameter-efficient fine-tuning (PEFT). Specifically, we introduce a novel adapter structure designed for decoder-only LLMs, which can encode KGs from both node-centered and relation-centered perspectives, and then perform joint reasoning with LLMs to generate responses end-to-end. Experiments with diverse models on four datasets for two different tasks all demonstrate significant improvements. With only 28M parameters trained, we make the 7B-parameter LLM outperform the previous full-parameter fine-tuned state-of-the-art method and comparable to the prompt-based ChatGPT methods.

## introduction large language models (llms), such as llama @xcite , mistral @xcite , @xcite , exhibit remarkable abilities in multiple natural language processing (nlp) tasks @xcite , and are even considered as "the sparks of artificial general intelligence" @xcite . however, llms are not the elixir nowadays, they are argued for lack of up-to-date knowledge @xcite and domain-specific expertise @xcite ; the problem of hallucination @xcite 2023; @xcite ; and the lack of interpretability @xcite . to address the above issues, a feasible approach is to combine knowledge graphs (kgs) with llms @xcite . kgs explicitly contain massive accurate factual knowledge and domain expertise in a structured format @xcite . they are easy to modify, can update new knowledge readily @xcite , and provide human-readable reasoning paths @xcite . recent works @xcite @xcite @xcite focus on combining kgs with llms through prompt-based methods or llms-as-agent @xcite approach. these methods first extract triplets from kgs by using llms through well-designed prompts (or other retrieval models), then linearize these triplets to textual form and concatenate them into the input. although these methods achieve success, they have flaws (figure 1 as an example): (1) llms cannot process structured kgs directly and the linearization may lose some underlying information @xcite @xcite ; (2) incorporating kgs via prompt-based methods suffers from the knowledge conflict problem @xcite , namely, the llms may completely ignore the knowledge provided in the context; (3) overreliance on super llms (e.g., chatgpt), which makes these methods achieve limited improvement on small-scale llms. different from the above methods, we endeavor to integrate structured kgs directly into the llms at the parameter level to solve these problems. while some early works @xcite @xcite have also attempted to inject kgs into pre-trained models at the parameter level, these approaches usually need pre-training or fullparameter fine-tuning, requiring inaccessible kgtext-aligned data and high training costs, or are based on encoder architectures, which are incompatible with current llms. specifically, inspired by the parameter-efficient fine-tuning (peft) @xcite , we propose a novel adapter structure, named kg-adapter, which contains a sub-word to entity hybrid initialization (sehi) and multiple kg-adapter layers, enabling llms to access structured kgs directly. the sehi initializes the kg representations by fusing the entity-level kg representations (from pre-trained kg embeddings) with the sub-wordlevel kg representations (from the word embedding of llm). between each llm layer, we insert a kg-adapter layer that encodes kg from both node-centric and relation-centric perspectives and performs joint reasoning via bi-directional crossattention to inject kg information into the llm. experimental results demonstrate the effectiveness of our approach on four datasets across two tasks. with only 28m trainable parameters, we enable the 7b model to outperform the full-parameter fine-tuned sota methods and achieve comparable performance to the prompt-based chatgpt methods. our contributions are summarized below: ## conclusion to enable llms to directly access structured kgs and overcome the limitations of current prompt-based approaches, i.e., the inability to utilize the structural information of kgs, the problem of knowledge conflicts, and the over-reliance on super llms. we propose a novel peft-based adapter structure, named kg-adapter, which is a plug-andplay adapter module applicable to various llms and requires only 28m parameters to train. benefiting from the internal gnn layer and m lp trip , kg-adapter can encode kgs from both node-centered and relation-centered perspectives to fully utilize the structure information in kgs. experiments on four datasets across two tasks show that our kg-adapter achieves superior performance over previous full-parameter fine-tuned sota methods and is comparable to the recent prompt-based chatgpt methods.