Knowledge graph-based medical field large model pre-training and fine-tuning method and device
By screening high-quality data and encoding medical knowledge graphs to pre-train a large language model, and designing instructions to fine-tune the data format, the problem of insufficient professionalism of large language models in the medical field is solved, realizing the efficient application and interpretability of the model in the medical field.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU COOPER MEDICAL TECH CO LTD
- Filing Date
- 2024-10-09
- Publication Date
- 2026-07-24
AI Technical Summary
Existing large language models lack sufficient professionalism when applied in the medical field. They lack the necessary professional knowledge and logical reasoning ability, making it difficult to process complex clinical information and provide accurate diagnostic or treatment recommendations.
High-quality data is selected by training a reward model, pre-trained by combining it with an encoded medical knowledge graph, and instructions are designed to fine-tune the data format to fine-tune the large language model, ensuring that the model can understand and use structured medical knowledge for reasoning.
This improves the professionalism and interpretability of large language models in the medical field, ensures the reliability and consistency of inference results, and enhances the model's application capabilities in the medical field.
Smart Images

Figure CN119514674B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of large-scale model training technology in the medical vertical domain, specifically involving a method and apparatus for pre-training and fine-tuning large-scale medical models based on knowledge graphs. Background Technology
[0002] In recent years, with the rapid development of artificial intelligence technology, Large Language Models (LLMs) have achieved significant breakthroughs in the field of Natural Language Processing (NLP), demonstrating powerful language understanding and generation capabilities and changing the way humans interact with machines at an unprecedented pace. These large language models, such as the GPT series, BERT, and their derivatives, are trained on massive amounts of text data using deep learning techniques. They have not only learned the complex structures of human language but are also capable of performing a variety of tasks, from simple text classification and sentiment analysis to complex question-answering systems and text creation, greatly expanding the application boundaries of natural language processing.
[0003] However, despite the remarkable achievements of large language models in general natural language processing, their performance often falls short when applied to highly specialized fields such as medicine. The medical field is highly specialized and complex, involving a large number of technical terms, concepts, and relationships, which places higher demands on the professional knowledge reserves and reasoning capabilities of large language models.
[0004] The medical field is a knowledge-intensive and highly specialized industry with a vast and constantly evolving knowledge system. From basic anatomy and physiology to complex pathology and pharmacology, and cutting-edge technologies such as gene editing and immunotherapy, medical knowledge covers a wide range of topics, from microscopic to macroscopic, and from basic to clinical applications. Furthermore, the medical field is filled with numerous technical terms, abbreviations, and unique expressions, all of which pose a significant challenge to the ability to understand language models.
[0005] Current large language models primarily rely on general text data from the internet for training. While this data is massive, it often lacks the specialization and depth required in the medical field. Consequently, these models frequently struggle to handle medical-related tasks due to a lack of necessary expertise.
[0006] Furthermore, medical decisions often require logical reasoning and judgment based on complex clinical information, including but not limited to the patient's medical history, symptoms, signs, laboratory test results, and imaging data. However, existing large language models still have shortcomings in logical reasoning and contextual understanding, making it difficult to comprehensively consider multiple factors and make accurate diagnostic or treatment recommendations like professional doctors.
[0007] Therefore, it is necessary to further explore innovative training methods for large-scale models in the medical vertical field, such as combining traditional free text corpus training with medical knowledge graph training to achieve pre-training and fine-tuning of large language models, so as to solve the problem of insufficient professionalism of existing general-purpose large language models when applied in the medical field. Summary of the Invention
[0008] In view of the above, the purpose of this invention is to provide a method and apparatus for pre-training and fine-tuning a large-scale language model in the medical field based on knowledge graphs. This method involves training a reward model to select high-quality data, combining it with an encoded knowledge graph, and then alternately pre-training a large language model. The pre-trained large language model is then fine-tuned using instructions to obtain the model's inference results and inference paths. This improves the professionalism of the large language model in the medical field and ensures the interpretability, transparency, and knowledge consistency of the inference results. This is crucial for AI applications in high-risk fields such as medicine. Furthermore, the method and apparatus provided by this invention also demonstrate how to effectively inject domain-specific structured knowledge into a large-scale language model, thus providing new ideas for the development of large models in other professional fields. This method has broad technical promotion value and points the way for the development of artificial intelligence towards a more professional and reliable direction.
[0009] To achieve the above-mentioned objectives, the present invention provides the following technical solution:
[0010] This invention provides a method for pre-training and fine-tuning large-scale medical models based on knowledge graphs, comprising the following steps:
[0011] A reward model was trained using the collected medical-related text data and its quality annotation results. The trained reward model was then used to filter out high-quality data from newly acquired medical-related text data.
[0012] The medical knowledge graph is encoded into a text format that can be processed by a large language model. High-quality data and the encoded medical knowledge graph are alternately input into the large language model in different batches for model pre-training.
[0013] The design includes a fine-tuning data format for instructions, knowledge graph reasoning paths, and generated answers. Training samples constructed using this fine-tuning data format are input into a pre-trained large language model for model fine-tuning. The fine-tuned large language model then outputs the final answer and reasoning path based on the user's new input instructions.
[0014] Preferably, training the reward model using collected medical-related text data and its quality annotation results includes:
[0015] Several medical topics were selected, and each topic corresponded to two medical-related texts of different quality. Through multi-dimensional evaluation, the two medical-related texts of different quality corresponding to each topic were manually labeled as labeled text pairs including high-quality text content and low-quality text content.
[0016] The reward model is trained using the direct preference optimization algorithm. Each topic-specific labeled text pair is input into the reward model. The reward model identifies high-quality text content in the labeled text pair and gives a corresponding quality score, as well as low-quality text content and gives a corresponding quality score.
[0017] Preferably, the step of using the trained reward model to filter high-quality data from newly acquired medical-related text data includes:
[0018] Newly acquired medical-related text data is input into the trained reward model, which outputs a corresponding quality score. Medical-related text data with quality scores higher than a set quality threshold are retained as high-quality data.
[0019] Preferably, the method further includes continuously optimizing the reward model, including:
[0020] The quality screening results are regularly sampled and manually verified by medical experts. The quality threshold is adjusted or the reward model is updated based on the verification results. New manually annotated text pairs are collected and the reward model is retrained regularly.
[0021] Preferably, the reward model uses the Qwen2-7B model as the base model.
[0022] Preferably, the process of encoding the medical knowledge graph into a text format for large language model processing includes:
[0023] Information in the medical knowledge graph exists in the form of triples, which include a head entity, a relation, and a tail entity. Each triple is encoded in the following format:
[0024] <|node_start|>Head entity<|node_end|><|relation_start|>Relation<|relation_end|><|node_start|>Tail entity<|node_end|>;
[0025] In this context, <|node_start|> and <|node_end|> are used to identify nodes in the medical knowledge graph, namely the head entity and the tail entity, while <|relation_start|> and <|relation_end|> are used to identify the relationships between nodes.
[0026] Preferably, a node-centric processing approach is used to capture the local structure of the knowledge graph. For each starting node, all associated triples are collected and a subgraph is formed. Each subgraph is put into a batch for input into a large language model for model pre-training.
[0027] Preferably, in the instruction fine-tuning data format, the instruction is the user's question or task description, the knowledge graph reasoning path is the medical knowledge graph reasoning steps required to answer the question, and the generated answer is the final answer derived based on the reasoning path.
[0028] Preferably, knowledge graph visualization technology is used to visualize the reasoning path output by the fine-tuned large language model.
[0029] To achieve the above-mentioned objectives, embodiments of the present invention also provide a knowledge graph-based large-scale model pre-training and fine-tuning device for the medical field, comprising: a data quality screening module, a model pre-training module, and a model fine-tuning module;
[0030] The data quality screening module is used to train a reward model using the collected medical-related text data and its quality labeling results, and then uses the trained reward model to screen out high-quality data from the newly acquired medical-related text data.
[0031] The model pre-training module is used to encode the medical knowledge graph into a text format that can be processed by the large language model. High-quality data and the encoded medical knowledge graph are alternately input into the large language model in different batches for model pre-training.
[0032] The model fine-tuning module is used to design an instruction fine-tuning data format that includes instructions, knowledge graph reasoning paths, and generated answers. The training samples constructed with the instruction fine-tuning data format are input into the pre-trained large language model for model fine-tuning. The fine-tuned large language model outputs the final answer and reasoning path based on the user's new input instructions.
[0033] Compared with the prior art, the beneficial effects of the present invention include at least the following:
[0034] (1) This invention automatically filters and retains high-quality data in medical-related text data by training a reward model, which effectively improves the quality and reliability of pre-training data for large language models and enhances the reliability and accuracy of pre-trained large language models.
[0035] (2) This invention introduces dual pre-training data sources. In addition to high-quality free text data, it also introduces encoded medical knowledge graph data as pre-training data. The medical knowledge graph contains rich medical concepts, entities and complex relationships between them, which enables the large language model to learn unstructured high-quality data and structured medical knowledge graph knowledge respectively, thereby improving the professionalism of the large language model in the medical field.
[0036] (3) This invention encodes medical knowledge graphs, enabling large language models to effectively encode and represent structured information in knowledge graphs. Through alternating training in different batches, the model can not only understand natural language but also understand the structure of knowledge graphs, thus improving the comprehensiveness and effectiveness of model pre-training.
[0037] (4) This invention fine-tunes the pre-trained large language model by designing a special instruction fine-tuning data format, so that the large language model can use the learned knowledge graph knowledge to reason, and finally train the model to generate reasoning paths based on knowledge graph, thereby improving the interpretability of the model in answering complex medical questions. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a flowchart illustrating the method for pre-training and fine-tuning large medical models based on knowledge graphs provided in this embodiment of the invention.
[0040] Figure 2 This is a schematic diagram of the structure of a knowledge graph-based large-scale medical model pre-training and fine-tuning device provided in an embodiment of the present invention. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the scope of protection of this invention.
[0042] The inventive concept of this invention is as follows: Addressing the lack of professionalism in the application of general-purpose large language models in the medical field, this invention provides a method and apparatus for pre-training and fine-tuning a large medical model based on a knowledge graph. In the pre-training stage, high-quality data is selected through a training reward model, and the knowledge graph is encoded using encoding techniques. The high-quality data and the encoded knowledge graph are used alternately during pre-training, allowing the model to learn unstructured text and structured knowledge respectively. In the fine-tuning stage, a special instruction is designed to fine-tune the data format input to the pre-trained large language model, enabling the model to output inference results and inference paths, thereby ensuring the interpretability, transparency, and knowledge consistency of the inference results.
[0043] Figure 1 This is a flowchart illustrating the knowledge graph-based pre-training and fine-tuning method for large-scale medical models provided in this embodiment of the invention. Figure 1 As shown in the embodiment, this method provides a pre-training and fine-tuning method for large medical models based on knowledge graphs, including the following steps:
[0044] S1. Train a reward model using the collected medical-related text data and its quality labeling results. Use the trained reward model to filter out high-quality data from the newly acquired medical-related text data.
[0045] In this embodiment, when pre-training a large language model in the medical field, the problem of inconsistent quality of content from a large number of medical knowledge websites crawled from the internet is encountered. Therefore, to ensure that high-quality data is used for model training, a data quality screening method based on the RLHF (Reinforcement Learning from Human Feedback) concept in reinforcement learning was developed. The core of this method is to train a reward model to evaluate the quality of web page content. The specific implementation steps are as follows:
[0046] (1) Data collection and labeling
[0047] First, a large amount of medical-related web content was collected. To train the reward model, manual annotation was performed, specifically including:
[0048] a) Select 1000 medical topics, with each topic corresponding to two webpages of different quality;
[0049] b) Medical experts evaluated the content of these web pages from multiple dimensions, including accuracy and harmfulness.
[0050] c) Based on the expert evaluation results, mark a pair of web pages for each topic, including one high-quality content and one low-quality content.
[0051] (2) Reward Model Training
[0052] Using the Qwen2-7B model as the base model, the reward model was trained using the DPO (Direct Preference Optimisation) algorithm. The training process is as follows:
[0053] a) Input: Each training sample contains pairs of web pages with high-quality and low-quality content on the same topic;
[0054] b) Objective: To enable the reward model to distinguish between high-quality and low-quality content and to provide corresponding scores;
[0055] c) Optimization: Through the DPO algorithm, the reward model learns human preferences and gradually improves its ability to judge content quality.
[0056] (3) Large-scale content rating
[0057] The trained reward model is used to score all the crawled medical web page content:
[0058] a) Input the content of each webpage into the reward model;
[0059] b) The model outputs a quality score, with a score range of 0 to 100. The quality score takes into account multiple aspects such as the accuracy, reliability, and harmfulness of the content.
[0060] (4) Data filtering
[0061] Data filtering is performed based on the scoring results from the reward model:
[0062] a) Set a quality threshold, which is set to 75 points in this example;
[0063] b) Only retain web page content with a quality score higher than the quality threshold. Data filtering can effectively filter out low-quality web pages that may contain misinformation or harmful content.
[0064] (5) Continuous optimization
[0065] To ensure the quality of screening and adapt to new content characteristics, the following measures are taken:
[0066] a) The results of the quality screening are regularly sampled and manually verified by medical experts.
[0067] b) Adjust the quality score threshold or update the reward model based on the verification results.
[0068] c) Collect new manually labeled data and retrain the reward model periodically.
[0069] This method effectively filters high-quality data from massive amounts of medical web content for pre-training large language models. This not only improves the quality of training data but also indirectly enhances the reliability and accuracy of the final large language model. Combining human expert judgment with machine learning techniques, this method efficiently processes large-scale data, laying a solid foundation for building a high-quality medical knowledge base and training reliable medical AI models.
[0070] S2 encodes the medical knowledge graph into a text format that can be processed by a large language model. High-quality data and the encoded medical knowledge graph are then alternately input into the large language model in different batches for model pre-training.
[0071] In this embodiment, for the pre-training of a large language model in the medical vertical domain, the encoding of the knowledge graph is a crucial step. A novel encoding method was developed to convert the structured medical knowledge graph information into a text format that the large language model can process. The specific implementation is as follows:
[0072] (1) Introduction of special markers
[0073] To distinguish and identify different elements of a knowledge graph within text, a series of special tokens were introduced:
[0074] <|node_start|> and <|node_end|>: used to identify nodes in a knowledge graph;
[0075] <|relation_start|> and <|relation_end|>: used to identify the relationship between nodes.
[0076] (2) Triple Encoding
[0077] Information in a knowledge graph exists in the form of triples (head entity, relation, tail entity). Each triple is encoded in the following format:
[0078] <|node_start|>Head entity<|node_end|><|relation_start|>Relation<|relation_end|><|node_start|>Tail entity<|node_end|>.
[0079] For example, for the triple ("aspirin", "for treatment", "fever"), the encoded text is:
[0080] Aspirin is used to treat fever.
[0081] (3) Node Centralization Processing
[0082] Considering the limited capacity of large language models and in order to better capture the local structure of knowledge graphs, a node-centric processing approach is adopted. For each starting node, all related triples are collected to form a subgraph. Each subgraph is put into a batch for input into the large language model for model pre-training.
[0083] (4) Batch generation strategy
[0084] A separation strategy was used when generating training batches:
[0085] a) Knowledge graph batch: contains encoded knowledge graph triples;
[0086] b) Regular text batch: Contains regular, high-quality free text data.
[0087] These two types of batches are used alternately during the pre-training of the large language model, but they are not mixed in the same batch. This approach can prevent two different types of data from interfering with each other, while allowing the large language model to learn structured knowledge and unstructured text separately.
[0088] S3 is designed with an instruction fine-tuning data format that includes instructions, knowledge graph reasoning paths, and generated answers. Training samples constructed with the instruction fine-tuning data format are input into the pre-trained large language model for model fine-tuning. The fine-tuned large language model then outputs the final answer and reasoning path based on the user's new input instructions.
[0089] In this embodiment, the medical vertical domain large language model employs an innovative knowledge graph reasoning mechanism during the fine-tuning phase, aiming to improve the reasoning ability and interpretability of the large language model. The specific technical implementation is as follows:
[0090] (1) Special instructions to fine-tune data format
[0091] A special instruction fine-tuning data format was designed, in which each training sample contains three key components:
[0092] a) Instruction: A description of the user's question or task;
[0093] b) Knowledge Graph Reasoning Path: The knowledge graph reasoning steps required to answer the question;
[0094] c) Generated Answer: The final answer derived from the reasoning path.
[0095] This format is designed to enable models to learn how to use knowledge graphs for reasoning and generate corresponding answers.
[0096] (2) Knowledge Graph Reasoning Path
[0097] A reasoning path is a series of connected knowledge graph triples, representing the reasoning process from a question to an answer. Each triple contains a structure of (entity 1, relation, entity 2). For example:
[0098] (Aspirin, used to treat fever) -> (Fever, a symptom of the common cold) -> (Common cold, recommended medication: ibuprofen).
[0099] Here, the symbol -> represents the reasoning logic, that is, the process from one reasoning result to another. This representation method enables large language models to learn and follow the knowledge graph structure obtained in the pre-training stage.
[0100] (3) Model training process
[0101] During the fine-tuning of the large language model, the large language model improves its reasoning ability by learning these special instructions to fine-tune the data format. The large language model not only learns to generate correct answers, but also learns how to construct reasonable reasoning paths. This training method ensures that the reasoning process of the large language model follows the knowledge graph knowledge learned during pre-training.
[0102] (4) Output of the reasoning stage
[0103] The finely tuned large language model, during inference, not only provides the final answer but also outputs the reasoning path used to arrive at that answer. This reasoning path reflects how the model utilizes information from the knowledge graph to answer questions.
[0104] (5) Visualization of reasoning path
[0105] Based on the reasoning path output by the large language model, existing knowledge graph visualization techniques are used for visualization. This visualization makes the reasoning process of the large language model more transparent and easier to understand, allowing users to clearly see how the model reasones step-by-step from the initial question to the final answer. By outputting the reasoning path and supporting its visualization, this approach significantly improves the model's interpretability and transparency. Users can not only see the final answer but also understand how the model arrived at that answer, which is particularly important in fields such as medicine where high reliability and interpretability are required. Since the reasoning process of the large language model follows the knowledge graph structure learned during the pre-training phase, this approach also helps ensure the consistency and reliability of the large language model's output, thereby reducing the possibility of the model generating answers inconsistent with known medical knowledge.
[0106] In summary, the knowledge graph-based pre-training and fine-tuning method for large-scale medical models provided in this invention overcomes the limitations of traditional large language models that rely solely on free text training. It organically integrates structured professional knowledge, which not only improves the model's performance in the medical field but also enhances its reasoning ability and interpretability. By generating knowledge graph-based reasoning paths, the model's decision-making process becomes more transparent. The pre-trained and fine-tuned large-scale medical language model has broad application prospects. In intelligent consultation, it can provide more accurate and professional medical advice and preliminary diagnostic suggestions; in decision support, it can provide doctors with evidence-based treatment recommendations; in medical research, it can assist in literature reviews, hypothesis generation, and experimental design; in medical education, it can provide medical students with personalized learning and simulation training; and in clinical trials, it can assist in patient screening, data analysis, and report generation.
[0107] Based on the same inventive concept, such as Figure 2 As shown, this embodiment of the invention also provides a knowledge graph-based medical large model pre-training and fine-tuning device 200, including: a data quality screening module 210, a model pre-training module 220, and a model fine-tuning module 230.
[0108] The data quality screening module 210 is used to train a reward model using the collected medical-related text data and its quality labeling results, and to use the trained reward model to screen out high-quality data from the newly acquired medical-related text data.
[0109] The model pre-training module 220 is used to encode the medical knowledge graph into a text format for processing by the large language model. High-quality data and the encoded medical knowledge graph are alternately input into the large language model in different batches for model pre-training.
[0110] The model fine-tuning module 230 is used to design an instruction fine-tuning data format that includes instructions, knowledge graph reasoning paths, and generated answers. The training samples constructed with the instruction fine-tuning data format are input into the pre-trained large language model for model fine-tuning. The fine-tuned large language model outputs the final answer and reasoning path based on the new instructions input by the user.
[0111] It should be noted that the knowledge graph-based medical large model pre-training and fine-tuning device provided in the above embodiments belongs to the same inventive concept as the knowledge graph-based medical large model pre-training and fine-tuning method. For details of its specific implementation process, please refer to the embodiments of the knowledge graph-based medical large model pre-training and fine-tuning method, which will not be repeated here.
[0112] The specific embodiments described above illustrate the technical solution and beneficial effects of the present invention in detail. It should be understood that the above description is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, additions, and equivalent substitutions made within the scope of the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for pre-training and fine-tuning large-scale medical models based on knowledge graphs, characterized in that, Includes the following steps: A reward model was trained using collected medical-related text data and its quality annotation results. The process included: selecting several medical topics, with each topic corresponding to two medical-related texts of different qualities; manually annotating the two texts of different qualities for each topic into labeled text pairs containing both high-quality and low-quality texts through multi-dimensional evaluation; training the reward model using a direct preference optimization algorithm, inputting the labeled text pairs for each topic into the reward model, which then identifies high-quality text content and assigns a quality score, as well as low-quality text content and assigns a quality score; and finally, using the trained reward model to filter high-quality data from newly acquired medical-related text data. The medical knowledge graph is encoded into a text format for processing by a large language model. This involves: information in the medical knowledge graph existing in the form of triples, each triple including a head entity, a relation, and a tail entity. Each triple is encoded as follows: <|node_start|>head entity<|node_end|><|relation_start|>relation<|relation_end|><|node_start|>tail entity<|node_end|>; where <|node_start|> and <|node_end|> identify the nodes in the medical knowledge graph, i.e., the head and tail entities, and <|relation_start|> and <|relation_end|> identify the relations between nodes; high-quality data and the encoded medical knowledge graph are alternately input into the large language model in different batches for model pre-training. The design includes a fine-tuning data format for instructions, knowledge graph reasoning paths, and generated answers. Training samples constructed using this fine-tuning data format are input into a pre-trained large language model for model fine-tuning. The fine-tuned large language model then outputs the final answer and reasoning path based on the user's new input instructions.
2. The method for pre-training and fine-tuning large medical models based on knowledge graphs according to claim 1, characterized in that, The process of using a trained reward model to filter high-quality data from newly acquired medical-related text data includes: Newly acquired medical-related text data is input into the trained reward model, which outputs a corresponding quality score. Medical-related text data with a quality score higher than a set quality threshold are retained as high-quality data.
3. The method for pre-training and fine-tuning large medical models based on knowledge graphs according to claim 2, characterized in that, The method also includes continuous optimization of the reward model, including: The quality screening results are regularly sampled and manually verified by medical experts. The quality threshold is adjusted or the reward model is updated based on the verification results. New manually annotated text pairs are collected and the reward model is retrained regularly.
4. The method for pre-training and fine-tuning large medical models based on knowledge graphs according to claim 1 or 3, characterized in that, The reward model uses the Qwen2-7B model as its base model.
5. The method for pre-training and fine-tuning large medical models based on knowledge graphs according to claim 1, characterized in that, A node-centric processing approach is adopted to capture the local structure of the knowledge graph. For each starting node, all related triples are collected and a subgraph is formed. Each subgraph is put into a batch for input into a large language model for model pre-training.
6. The method for pre-training and fine-tuning large medical models based on knowledge graphs according to claim 1, characterized in that, In the instruction fine-tuning data format, the instruction is the user's question or task description, the knowledge graph reasoning path is the medical knowledge graph reasoning steps required to answer the question, and the generated answer is the final answer derived based on the reasoning path.
7. The method for pre-training and fine-tuning large medical models based on knowledge graphs according to claim 1, characterized in that, Knowledge graph visualization technology is used to visualize the reasoning path output by the fine-tuned large language model.
8. A knowledge graph-based pre-training and fine-tuning device for large-scale medical models, implemented using the knowledge graph-based pre-training and fine-tuning method for large-scale medical models as described in any one of claims 1 to 7, characterized in that... include: Data quality screening module, model pre-training module, and model fine-tuning module; The data quality screening module is used to train a reward model using the collected medical-related text data and its quality labeling results, and then uses the trained reward model to screen out high-quality data from the newly acquired medical-related text data. The model pre-training module is used to encode the medical knowledge graph into a text format that can be processed by the large language model. High-quality data and the encoded medical knowledge graph are alternately input into the large language model in different batches for model pre-training. The model fine-tuning module is used to design an instruction fine-tuning data format that includes instructions, knowledge graph reasoning paths, and generated answers. The training samples constructed with the instruction fine-tuning data format are input into the pre-trained large language model for model fine-tuning. The fine-tuned large language model outputs the final answer and reasoning path based on the user's new input instructions.