Efficient Knowledge Infusion via KG-LLM Alignment (2024)

Abstract: To tackle the problem of domain-specific knowledge scarcity within large language models (LLMs), knowledge graph-retrievalaugmented method has been proven to be an effective and efficient technique for knowledge infusion. However, existing approaches face two primary challenges: knowledge mismatch between public available knowledge graphs and the specific domain of the task at hand, and poor information compliance of LLMs with knowledge graphs. In this paper, we leverage a small set of labeled samples and a large-scale corpus to efficiently construct domain-specific knowledge graphs by an LLM, addressing the issue of knowledge mismatch. Additionally, we propose a three-stage KG-LLM alignment strategy to enhance the LLM’s capability to utilize information from knowledge graphs. We conduct experiments with a limited-sample setting on two biomedical question-answering datasets, and the results demonstrate that our approach outperforms existing baselines.

heading: 1 Introduction
text: Recent advancements in large language models (LLMs), such as ChatGPT, have demonstrated impressive capabilities in general-purpose content creation (OpenAI, 2022; Touvron et al., 2023). Nevertheless, their proficiency in domain-specific applications, particularly in the medical field, is notably constrained by insufficient knowledge (Bao et al., 2023; Zhang et al., 2023; Han et al., 2023b). To enhance the domain-specific performance of LLMs, the primary strategies for knowledge infusion include two main approaches: continual pretraining on domain-specific corpora and retrievalaugmented method, which involves integrating external information into the models.
Compared to continual pre-training, the retrievalaugmented approach is gaining popularity in
∗Both authors contributed equally to this work.
knowledge-intensive scenarios due to its cost efficiency and enhanced traceability (Lewis et al., 2020; Lan et al., 2023). Some retrievalaugmented methods involve integrating LLMs with resources directly such as professional literature, news articles and tables through supervised finetuning (Borgeaud et al., 2022; Hu et al., 2023). However, the knowledge required by the model may be scattered among vast amounts of data, and directly retrieving from raw data instances will introduce noise inevitably, preventing the model from effectively utilizing the information. To mitigate this issue, leveraging structured knowledge, especially knowledge graphs (KGs), is an effective method (Moiseev et al., 2022; Ranade and Joshi, 2024; Wang et al., 2023).
However, the existing KG-retrieval-augmented methods still encounter two principal challenges. The first challenge pertains to knowledge mismatch. While many existing strategies utilize publicly available KGs for knowledge infusion, the knowledge demanded by domain-specific tasks is frequently of a highly specialized nature, leading to a substantial likelihood that the KG might not cover all the requisite information, or might even present gaps. The second challenge involves poor information compliance. The structured format of triples in KGs diverges from the free-flowing format of natural language (Li et al., 2021; Ke et al., 2021) and the target text often includes additional information that is not found in the triples. This disparity can lead to confusion within LLMs, which could result in outputs from the trained model that do not align with the information incorporated from the KG, particularly in scenarios with a scarcity of supervised examples.
In this work, we construct a domain-specific corpus-based knowledge graph efficiently by LLMs and develop a knowledge infusion approach to enhance the ability of LLMs to utilize graph information, enabling them to generate comprehensive,
2986
logical, and low-hallucination responses. Firstly, we train a knowledge extraction model based on an LLM using a small amount of labeled data. Then, we obtain a domain knowledge graph that resolves knowledge mismatch by performing extraction on unsupervised domain-specific corpora and reducing errors in the results through simple post-processing. Subsequently, we propose a novel three-phase KG-LLM alignment framework to optimize the exploitation of KG content by LLMs. The framework consists of the following stages:
• In the initial pre-learning phase, we synthesize substantial triples-to-text generation task examples derived from the previously mentioned extraction outcomes. We then train a Low-Rank Adapter (LoRA) (Hu et al., 2022), designated as K-LoRA, to assimilate the process of KG infusion and acquire proficiency in the domain-specific linguistic modality.
• The subsequent phase involves supervised fine-tuning. For each question-answer pair in the training set, we retrieve knowledge graph based on the question, concatenate the resultant subgraph into the input and proceed to train an additional LoRA. This process is designed to refine the model’s output, tailoring it to the specific demands of the given task.
• The final phase is the alignment with knowledge graph feedback (AKGF). In this phase, we extract knowledge triples from the generated responses and compare them with the KG to provide evaluative feedback on the knowledge correctness. This feedback serves as a basis for further fine-tuning the model to achieve more comprehensive, more logical, and less hallucinatory content.
To simulate a realistic context where specialized annotations are scarce, we conduct experiments on limited-sample datasets constructed based on two public biomedical question answering datasets, BioASQ (Nentidis et al., 2022) and CMedQA (Cui and Han, 2020). In summary, our main contributions are as follows:
1) We propose a modular knowledge infusion framework. Building upon the efficiently constructed KG, our approach aligns LLMs with the KG through lightweight parameter adjustment, addressing issues of knowledge mismatch and poor information compliance.
Experimental results demonstrate that our method significantly outperforms the baselines.
2) We introduce two innovative strategies, namely "pre-learning" and "AKGF", aiming at forging a stronger link between KGs and LLMs. In pre-learning, we demonstrate that triples-to-text task can serve as a simple and effective knowledge infusion strategy. In AKGF, we illustrate that KGs can function as automated evaluators for the knowledge correctness of generated responses.

heading: 2 Related Works
text: Retrieval-augmented LLMs. Retrievalaugmented generation methods (Izacard and Grave, 2021; Lewis et al., 2020; Min et al., 2023; Borgeaud et al., 2022) retrieve relevant information from an external database for the query and enable the LLM to generate results using this information. ChainRAG (Xu et al., 2023) focuses on addressing the problem of incorrect knowledge retrieved by information retrieval systems, which can mislead the LLM or disrupt its reasoning chain through their interaction. While these methods enhance factuality, they also introduce new hallucinations. To address this challenge, WebBrain (Qian et al., 2023) incorporates both specific information and general knowledge, which are intertwined with text snippets and used as references to complete the task.
LLM-augmented KG Construction. AutoKG (Yu et al., 2021) proposes a framework for constructing a KG from unstructured documents using information extraction (IE) and internal semantic alignment. Since the graphs constructed by IE typically suffer from edge sparsity and node redundancy, Wu et al. (2023) have applied contrastive pre-training and node clustering to overcome this issue. Leveraging the capabilities of LLMs, Zhu et al. (2023) designs prompts for various knowledge graph construction tasks. Another line of research has aimed to extract knowledge from LLMs to construct KGs (Bosselut et al., 2019; Hao et al., 2023; West et al., 2022). Additionally, PiVe (Han et al., 2023a) utilizes iterative verification prompts to rectify errors in KGs generated by larger LLMs.

heading: 3 Methodology
text: Figure 1 illustrates the proposed framework, which is referred to as Enhanced LLM with Knowledge
Pre-learning and Feedback (ELPF).

heading: 3.1 Efficient construction of domain KGs
text: For tasks within a specific domain, publicly available knowledge graphs fail to meet our needs frequently, which is referred to as knowledge mismatch. To counter this issue, a viable solution is to gather a large corpus of domain-specific documents and establish a domain-specific knowledge graph utilizing that corpus. For one unsupervised document d ∈ D, the process of KG construction can be formalized as Formula 1.
{Sa,P, Oa} = F(d) (1)
where F is KG construction system, Sa is set of subjects, P is set of defined relationships and Oa is set of objects.
The knowledge triples in the results are organized in the form of Formula 2.
Td = [< s1, p1, o11 >, ..., < sj , pk, ojk >] (2)
where ojk = ojk1|ojk2|...|ojkl. These triples are assembled and merged based on the same subjectrelation pair. For example, "Rome" and "Florence" are both cities of Italy, so the instance should be represented as "<Italy, City, Rome|Florence>".
However, traditional methods of constructing such graphs can be intricate and often depend on
substantial manual labor. Here we have designed an efficient KG construction workflow that requires only minimal annotation, leveraging the advanced semantic comprehension capabilities of LLM. We have streamlined the procedure into three stages: "knowledge triples extraction", "error removal", and "entity resolution".
Initially, we examine prevalent standards or seek guidance from domain experts to define a schema, which is the set and definitions of entity and relation categories in the domain, and then we manually annotate a small set of examples (≈ 100) to generate training data in the format of "text>knowledge triples". Subsequently, we fine-tune an LLM using LoRA, which is a popular parameterefficient fine-tuning method. Upon merging the trained LoRA parameters into the base model, we perform inference on extensive corpora to derive knowledge triples. Finally, we employ simple postprocessing strategies to minimize errors within the extracted triples:
1. Remove results with incorrect output format, such as triples lacking a subject.
2. Remove results where either the subject or object does not appear in the original text.
3. Remove results where the relationship is not in the defined schema.
4. Remove results where the subject and object
are the same. In the entity resolution phase, we utilize an opensource text embedding tool1 and set a similarity threshold. If the cosine similarity of two subject nodes surpass this threshold, we regard them as equivalent and subsequently combine their respective subgraphs. This merging process contributes to the construction of a comprehensive domainspecific knowledge graph.
We perform a quality assessment on 200 samples of the extracted results from our experimental datasets, where the precision (the ratio of correct triples to the total number of generated triples) surpasses 85%. In our preliminary experiments, we employed conventional supervised learning methods for extraction (specifically, joint entity and relation extraction based on BERT (Eberts and Ulges, 2019), with a sample size greater than 2000) and the eventual evaluation precision was only around 0.8. This is currently a prevalent approach in building knowledge graphs; hence, we consider achieving a precision of approximately 0.85 through postprocessing under the current construction workflow to be acceptable. For additional details and statistical outcomes, please refer to Appendix A.

heading: 3.2 Pre-learning with K-LoRA
text: Given that the triple form of KGs deviates from the natural language, LLMs exhibit limited proficiency in processing it. Moreover, acquiring copious amounts of annotated data in specialized domains frequently poses a challenge. Consequently, even with fine-tuning, it remains challenging to enhance the model’s capability to leverage information from KGs. We hypothesize that it might be feasible to devise a method for low-cost, extensive data construction that enables the model to assimilate the task format in advance. Fortunately, by inverting the extraction process described earlier, we can create a "triples-to-text" generation task. With extensive fine-tuning on a multitude of instances, the model can be trained to recognize the information format infused by the KG. Additionally, as the target text is domain-specific, the model is able to acquire the unique linguistic style associated with that domain. To boost the fine-tuning process’s efficiency, we continue to utilize LoRAbased SFT. We refer to the LoRA obtained in this step as K-LoRA.
1https://github.com/shibing624/text2vec

heading: 3.3 SFT with KG retrieval
text: Pre-learning enables LLMs to better comprehend inputs in the triple form. However, it does not directly resolve specific tasks. Consequently, further refinement through fine-tuning with supervised learning examples remains essential. We adhere to the normal procedure of KG-retrieval-augmented methods (Lewis et al., 2020; Pan et al., 2024), which involves retrieving pertinent subgraphs from the previously established domain-specific KG and modifying the input accordingly. The comprehensive input construction is designed to adhere to the following template:
[KG]: {gq} [Instruction]: Refer to the KG and answer the following question: {q}
An initial observation reveals that the subjects and relations inherent in the subgraphs exhibit a significant correlation with the core purpose of the input query. To leverage this observation, we employ an open-source embedding tool1 to encode all (s, p) pairs within the knowledge graph. Subsequently, we apply the same embedding tool to encode the input query. This approach facilitates the calculation of similarity scores between the query’s embedding and those of the top-k (s, p) pairs. Finally, we retrieve the corresponding objects from the original knowledge graph for each (s, p) pair and reconstruct them into triples. These triples are subsequently integrated with the input to provide subgraph information. To maximize the benefits provided by K-LoRA, it is crucial to ensure that the representation of the subgraph remains consistent with the format used during the pre-learning phase.

heading: 3.4 AKGF
text: After SFT, the model may still exhibit hallucinations in its responses due to issues such as overfitting. Inspired by the RLHF (Reinforcement Learning with Human Feedback) approach (Ziegler et al., 2020; Ouyang et al., 2022), we hope that the knowledge graph can serve as an automated evaluator, providing feedback on knowledge correctness of the current response, thereby guiding the model towards further optimization.
First, we generate a variety of responses for each query by employing diverse input formats or random seeds. Subsequently, we incorporate the knowledge graph to score and rank these responses.
The scoring process entails the utilization of the extraction system described in Section 3.1 to extract triples from these responses, which are then compared with the knowledge graph to ascertain their correctness. The reward is determined by the number of correctly matched knowledge triples. The formula for calculating the reward is represented by Formula 3.
reward = log(rspo + α ∗ re) (3)
where α is a hyperparameter, rspo represents the number of SPO matches, and re represents the number of entity matches. For more details on the specific implementation process, please refer to Algorithm 1, where Jcard represents the Jaccard similarity coefficient (Levandowsky and Winter, 1971). Appendix B demonstrates our automatic reward scoring mechanism using a case example.
To facilitate the training process, we utilize the Direct Preference Optimization (DPO) (Rafailov et al., 2023) training strategy, which mitigates sensitivity to reward values, thereby yielding more stable training process. For a comprehensive introduction to the DPO, please refer to Appendix C. This strategy involves creating pairs of samples according to their reward values. It is crucial to discard any pairs where the difference in rewards is not significant (i.e., rewardpos − rewardneg ≥ thresh) and handle issues like repetitive generation in positive samples. To assess the extent of duplication within the positive samples, we can determine the ratio of unique clauses to the overall count of clauses following the deduplication process. Should this ratio fall below a predefined threshold, it would indicate the presence of considerable duplication within the sample, which will be dropped then. By utilizing the knowledge graph for automated evaluation, this method eliminates the requirement of manual scoring, thereby reducing labor costs. Another advantage of this approach is that it is not limited by the quantity of supervised samples, which allows for better learning of knowledge correctness.

heading: 4 Experimental Settings and Results

heading: 4.1 Datasets
text: We select two biomedical question-answering datasets, CMedQA (Cui and Han, 2020) and BioASQ (Nentidis et al., 2022), for evaluating our model because both demand extensive domainspecific knowledge. CMedQA is a comprehen-
Algorithm 1 Constructing pairwise samples Input: Unsupervised questions Q, graph with entities N g
and SPOs {Sg,P, Og} 1: for q ← Q do 2: answers = F(q) 3: for answer ← answers do 4: {Sa,P, Oa} = Fie(answer) 5: rspo ← 0, re ← 0 6: for {sg, p, og} ← {Sg,P, Og} do 7: if Jcard({nas , p, nao}, {sg, p, og}) ≥
threshsim then 8: rspo ← rspo + 1 9: end if
10: end for 11: for ng ← N g do 12: if na = ng then 13: re ← re + 1 14: end if 15: end for 16: reward = log(rspo + α ∗ re) 17: end for 18: for anspos, ansneg ← answers× answers do 19: if rewardpos − rewardneg < thresh then 20: Drop the pairwise sample 21: end if 22: if anspos contains a lot of repetitive content then 23: Drop the pairwise sample 24: end if 25: end for 26: end for Output: pairwise samples [Anspos, Ansneg]
sive dataset of Chinese medical questions and answers, consisting of over 10,000 pairs. In contrast, BioASQ is an English biomedical dataset that includes 4,719 question and answer pairs and 57,360 reference passages. To simulate a scenario with limited samples, we randomly choose 500 instances from each dataset for training and designate 1,000 instances from each for testing. For CMedQA, we employ the answer texts from the non-selected QA pairs as corpora to construct a knowledge graph in a weakly supervised manner. Similarly, with BioASQ, we use all the provided reference passages as the domain-specific corpora.

heading: 4.2 Evaluation Metric
text: In our evaluation, we employ multiple metrics, including BLEU (n=4), ROUGE-1, ROUGE-2, and ROUGE-L, to assess the performance of the models. In addition to these automated metrics, we also perform manual evaluations based on five dimensions: fluency, relevance to the question, correctness of the core viewpoint, diversity & completeness, and knowledge hallucination, using reference answers as a benchmark. Since it is challenging to assign an absolute score through manual evalua-
tion, we sample 200 entries and rank the outputs of models under different settings according to various dimensions. A smaller ranking score indicates better performance, e.g. "1" means the best performance.

heading: 4.3 Experimental Settings
text: During the pre-learning stage, we perform finetuning of K-LoRA on base LLMs. The learning rate and number of epochs in the pre-learning stage are 5e-5 and 3. During the supervised fine-tuning stage, we establish the similarity threshold for subgraph retrieval to 0.9, and select the top-5 subgraphs. For more hyper-parameters and details, please refer to Appendix D.

heading: 4.4 Baselines
text: Base LLMs: Taking into account the constraints on machine resources and practical use cases, we require models with less than 10B parameters. On the CMedQA dataset, we choose ChatGLM2-6B (Zeng et al., 2023) as base model. On the BioASQ dataset, we choose Llama2-chat-7B (Touvron et al., 2023) as base model. Both of the models are initialized with HuggingFace’s pre-trained checkpoints23. Additionally, we opt to utilize the API of ChatGPT-3.5. For the base LLMs, we present the results of querying the model in a zero-shot scenario. Moreover, to compare the difference with basic continual pretraining method, we conduct continual pre-training on the base LLMs using the aforementioned constructed unsupervised corpus. For the settings of hyper-parameters of continual pre-training, please refer to the Appendix D. No-retrieval Models: We evaluate the performance of base LLMs and continual pre-trained LLMs after LoRA-based SFT with the constructed training set, where the inputs do not contain any retrieval results. Retrieval-based Models: For KG-level retrieval, we utilize the state-of-the-art KG-to-text method called GAP (Colas et al., 2022) as a baseline. GAP enhances KG-to-text generation by incorporating graph-aware elements into pre-trained language models. For document-level retrieval, we compare our approach with the representative method called RAG (Lewis et al., 2020). RAG ensures that the text retrieval source aligns with the unsupervised corpus used for KG construction. The retrieval
2https://huggingface.co/THUDM/chatglm2-6b 3https://huggingface.co/meta-llama/Llama-2-7b-chat-hf
method employed here is the same as the subgraph retrieval approach discussed in Section 3.3. We place the top-2 retrieved passages on the inputs, then perform LoRA-based SFT and direct query ChatGPT-3.5.

heading: 4.5 Main Results
text: Our results on the CMedQA and BioASQ datasets are shown in Table 1. We observe that the zeroshot querying method achieved ROUGE scores that are close to those obtained through supervised finetuning. However, it is worth noting that the zeroshot querying method results in significantly lower BLEU scores on both datasets. These results indicate that the zero-shot querying method does not effectively balance the professionalism and fluency of the generated text. Consequently, this method may not be suitable for generating domain-specific text that meets the desired criteria.
As for basic 2-shot RAG experiment on ChatGPT-3.5, although there is an improvement compared to the zero-shot baseline for both, the improvement on CMedQA is more pronounced. Case analysis reveals that CMedQA’s corresponding corpus is from question-and-answer pairs, whereas BioASQ consists of lengthy paragraphs, which leads to differences in passage format and retrieval quality. This may suggest two things: i. Simple RAG heavily relies on the retriever’s capability; ii. Simple RAG is dependent on the format of the text passages.
In terms of fine-tuning-based methods, our model shows improvements across various metrics. On the CMedQA dataset, our model achieves a 1.03 ROUGE-L improvement and a 1.03 BLEU improvement compared to the vanilla LoRA-based SFT method. On the BioASQ dataset, we have achieved a 1.12 improvement in ROUGE-L and a 0.74 improvement in BLEU. It is worth noting that our method achieves a significant performance improvement even compared to continual pre-training followed by fine-tuning. These results highlight the effectiveness of our proposed KG collaborative method in enhancing the performance of finetuning for LLMs. Compared to the GAP method, our approach not only exhibits significant improvements but also offers the advantage of not requiring the full-parameter joint training of a graph encoder with a pre-trained model like GAP. In comparison to RAG, which focuses on document retrieval, our method achieves higher ROUGE scores but
lower BLEU scores on the BioASQ dataset. This difference may be attributed to the document retrieval system’s ability to recall more extensive information. On the other hand, the process of constructing a KG introduces information loss, which results in ELPF generation relying more on the implicit knowledge of LLM itself when the subgraph is insufficient, leading to lower accuracy. At the same time, document retrieval also introduces more noise, leading to some answers deviating from the original question.

heading: 5 Analysis

heading: 5.1 Ablation Studies
text: We conduct several ablation experiments to evaluate the effectiveness of each module. These experiments involve the individual removal of K-LoRA, KG prompt, and AKGF, as well as the simultaneous removal of both K-LoRA and AKGF. The results of these experiments, including ROUGE and BLEU scores, can be found in Table 2. Additionally, the manual evaluation results for BioASQ are presented in Figure 2. Here are the key observations from our analysis:
(1) Removing K-LoRA leads to the most significant performance drop, reflected in ROUGE, BLEU, and the diversity of knowledge. The main reason is that the format of triples-to-text training samples is similar to the format of the subsequent fine-tuning task, allowing the model to better incorporate the knowledge implied by the input. (2) AKGF has a less significant impact on ROUGE and BLEU metrics. This is because the alignment objective is not focused on replicating the target answer, but rather on incorporating comprehensive, effective, and accurate domain knowledge, even if it is not particularly relevant to the question. It improves the diversity of knowledge, as well as the correctness of viewpoints, and reduces hallucinations, achieving the goal of alignment. (3) The results of manual evaluation indicate that the ablated
models with knowledge integration demonstrate improvements over the baseline model that relies solely on fine-tuning, in terms of knowledge correctness (question relevance, viewpoint correctness, and hallucinations) and knowledge diversity. Our ELPF method outperforms others across all dimensions, demonstrating its effectiveness. Appendix E presents a specific case, which allows for a more intuitive understanding of the effectiveness of the answers output by different models.

heading: 5.2 In-depth Analysis of K-LoRA
text: To further analyze the overall impact of K-LoRA on the model, we examine its effects on domain awareness and the alignment of generated text with the knowledge graph. K-LoRA aims to enable the
LLM to pre-learn within the current domain and generate text with the assistance of the knowledge graph in a weakly supervised manner. Regarding domain awareness, as illustrated in Figure 3, we observe a reduction in loss during the model training process and find that the model fused with K-LoRA not only has a smaller initial loss but also converges faster. This indicates that the model develops a certain level of awareness of the current domain through the training and weight fusion of K-LoRA. Therefore, K-LoRA serves as a straightforward and efficient approach for domain learning. In terms of the information compliance of the generated text to the knowledge graph, we analyze the text generated with and without K-LoRA, as shown in Figure 4. We notice that although the same knowledge graph information is provided, the original model does not effectively utilize this knowledge graph for generation. On the other hand, the model integrated with K-LoRA relies more on the knowledge graph and generates answers that are closer to the reference answers. This is because the task format of pre-learning and SFT is similar, and K-LoRA enhances the model’s ability to adapt to input from the knowledge graph.

heading: 5.3 Knowledge Completeness
text: As our approach depends on information from the knowledge graph, this section explores the impact of the knowledge graph’s completeness on our method. The completeness of knowledge can be measured by the size and quality of the knowledge graph. First, we explore the influence of graph size. We offer various sizes of KG, including full (100%), 80%, 60%, 40%, 20%, and 0%. The size control is achieved by randomly removing a certain proportion of nodes from the entire graph. Next, we investigate the impact of graph quality. We construct a set of target data to simulate the upper limit of model performance. The target data consists of triples extracted from the reference answers that correspond to the questions. The results are shown in Table 3. Firstly, we find that reducing the size of the knowledge graph does lead to a decrease in performance, but it is not a purely positive relationship. This is because our knowledge graph contains noise, and the model needs to balance between useful information and noise during the learning process. The model cannot effectively learn when the graph is sparse, resulting in even worse performance compared to not incorporating the graph information. Secondly, we observe that
the current results still exhibit a certain gap when compared to the results obtained from the target data. This indicates that there is room for improvement in the quality of the graph constructed by LLMs and the subgraph retrieval method. We will address these issues in future work.

heading: 6 Conclusions
text: In this work, we propose a framework for efficiently infuse domain knowledge into LLMs. By employing efficient construction of domain knowledge graphs and a three-stage KG-LLM alignment process, we address the issues of knowledge mismatch and poor information compliance. Experiments demonstrate that our method significantly improves the quality of text generation and knowledge correctness in limited sample scenarios. We hope our work will provide insight into the challenge of connecting KG with LLMs in future exploration.
Limitations
Although ELPF is relatively friendly in terms of sample size and computational resources, this method still has certain limitations. Since the construction of the domain knowledge graph is required in both SFT and AKGF, the ELPF method is highly dependent on the quality of the graph construction. However, our graph is established based on weak supervision signals, so there are inevitably noises in the results. Insufficient noise handling can affect the effectiveness of the method. Furthermore, because the self-built domain knowledge graph (KG) is incomplete, it is challenging to detect knowledge errors unless they conflict with known knowledge. Additionally, determining the relevance of the knowledge to the query is a vague concept that is difficult to assess. Therefore, to enhance the stability and versatility of alignment,
we have adopted a more conservative strategy in AKGF. This approach somewhat limits the optimization space. However, in actual vertical domain application scenarios, the positive reward or conflict penalty strategies can be adjusted according to the actual situation to achieve better results. Finally, our method focuses on domain-specific text generation. However, due to the limited availability of appropriate public datasets, we only conducted experiments on medical domain texts. This limitation may pose a risk to the generalized ability of our findings in other scenarios.

heading: A Weakly Supervised Domain-specific IE System Construction
text: For the annotation standard of the CMedQA dataset, we referred to the CMeIE v2 dataset4, which is a large-scale Chinese medical domain relation extraction dataset. For BioASQ, we referred to BioRED (Luo et al., 2022), an English medical relation extraction dataset annotated on the PubMed data source.
The types of relationship defined in the CMedQA dataset are: ["Differential Diagnosis", "Pathological Typing", "Clinical Manifestation", "Adjuvant Therapy", "Pharmacotherapy", "Surgical Treatment", "Etiology", "Synonyms", "Imaging Examination", "Auxiliary Examination", "Department of Consultation", "Complications", "Laboratory Test", "Susceptible Population", "Genetic Factors", "High-risk Factors", "Pathogenesis", "Site of Onset", "Medical History", "Incidence Rate", "Prognosis", "Age of Onset", "Prevention", "Posttreatment Symptoms", "Pathophysiology", "Transmission Route", "Peak Season", "Histological Examination", "Stage", "Radiotherapy", "Screening", "Chemotherapy", "Risk Assessment Factors", "Metastatic Sites", "Prevalence Area", "Mortality Rate"].
The types of relationship defined in the BioASQ dataset are: ["Association", "isa", "Negative_Correlation", "Positive_Correlation"].
For each reference dataset, we only utilized its relational schema and manually annotated 100 samples sampled from unsupervised corpora.
4https://tianchi.aliyun.com/dataset/95414
During manual annotation, we assigned two annotators for blind labeling and one quality control personnel for inspection. The final inter-annotator agreement was 0.9, and the accuracy of acceptance was 0.97. During the training, we employed the generative information extraction paradigm and trained a LoRA on top of an LLM. The hyperparameter settings were consistent with those in the SFT stage.
Statistical details of the constructed graph are provided in Table 4. The symbol "#" denotes a sign for counting. We performed a quality assessment on 200 samples of the extracted results from experimental datasets and calculated the precision (the ratio of correct triples to the total number of generated triples).

heading: B Automated Reward Function
text: In AKGF, we primarily propose an automated reward scoring mechanism that integrates a Knowledge Graph (KG). Here, we will demonstrate this process through a specific case study as show in Figure 5. For detailed information about the reward calculation, please refer to Algorithm 1.

heading: C Direct Preference Optimiz ation (DPO)
text: Construct a static pairwise dataset D = {xi, yiω, yil}Ni=1 according to Section 3.3, where yω represents the positive samples and yl represents the negative samples, and then perform reward modeling. According to DPO, the reward model rϕ(x, y) is trained using a negative log-likelihood loss as follows:
L = −E(x,yω ,yl)∼D[log θ(rϕ(x, yω)− rϕ(x, yl)]
where θ is the logistic function. In the context of LMs, the network rϕ(x, y) is often initialized from the SFT model πSFT (y|x) with the addition of a linear layer on top of the final transformer layer that produces a single scalar prediction for the reward value. To ensure a reward function with lower variance, prior works normalize the rewards, such that E(x,y)∼D[rϕ(x, y)] = 0 for all x. During the DPO RL phase, use the learned reward function
to provide feedback to the language model, with the optimization objective as follows:
J = max πθ Ex∼D,y∼πθ(y|x)[(rϕ(x, y)]
−βDKL[πθ(y|x)||πref (y|x)]
where β is a parameter that controls deviation from the baseline reference policy πref , and constraints on the KL divergence ensure that the reward strategy does not deviate too far from the baseline reference strategy (SFT). We also analyzed the impact of the value of the β parameter on the training process and selected an optimal parameter for subsequent training, as seen in Table 6.
D Implementation Details
We conduct experiments on four A100 80GB GPUs and two V100 32GB GPUs. For details of the parameters used in the experimental training at each stage, please refer to Table 5. As for continual pretraining, we fine-tune full parameter of the LLM with batch_size=4, epochs=3, learning_rate=5e-5.

heading: E Case Study
text: We evaluate the effectiveness of the model through several case studies, as shown in Figure 6. ELPF provided concise and relatively comprehensive answers regarding the characteristics and main causes of fetal intestinal echoes. It mentioned both physiological and pathological situations. ELPF (w/o AKGF) is close to ELPF in performance. However, the other answers were not as complete. ELPF (w/o K-LoRA&AKGF) only mentions the physiological condition, while ELPF (w/o K-LoRA) only addresses the pathological factors. Untrained models like ChatGPT-3.5 and Llama2-chat-7B exhibit obvious hallucinations.

heading: Future Work
text: We hope our work will provide insight into the challenge of connecting KG with LLMs in future exploration. Limitations
Although ELPF is relatively friendly in terms of sample size and computational resources, this method still has certain limitations. Since the construction of the domain knowledge graph is required in both SFT and AKGF, the ELPF method is highly dependent on the quality of the graph construction. However, our graph is established based on weak supervision signals, so there are inevitably noises in the results. Insufficient noise handling can affect the effectiveness of the method. Furthermore, because the self-built domain knowledge graph (KG) is incomplete, it is challenging to detect knowledge errors unless they conflict with known knowledge. Additionally, determining the relevance of the knowledge to the query is a vague concept that is difficult to assess. Therefore, to enhance the stability and versatility of alignment,
we have adopted a more conservative strategy in AKGF. This approach somewhat limits the optimization space. However, in actual vertical domain application scenarios, the positive reward or conflict penalty strategies can be adjusted according to the actual situation to achieve better results. Finally, our method focuses on domain-specific text generation. However, due to the limited availability of appropriate public datasets, we only conducted experiments on medical domain texts. This limitation may pose a risk to the generalized ability of our findings in other scenarios