A Method and System for Training Large Language Models in the Medical Field Based on Knowledge Graph Augmentation

By employing fine-grained parsing and multi-dimensional relational path reasoning, combined with graph structure embedding and dynamic injection, high-quality training samples are generated. This addresses the issues of irrelevant knowledge interference and insufficient temporal logic in existing technologies, thereby improving the training efficiency and accuracy of medical large language models.

CN121998101BActive Publication Date: 2026-06-30FUZHOU ZHONGKANG INTELLIGENT TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
FUZHOU ZHONGKANG INTELLIGENT TECHNOLOGY CO LTD
Filing Date
2026-04-08
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing methods fail to effectively combine text context and graph semantic matching degree to dynamically adjust fusion weights, resulting in irrelevant knowledge interference or key knowledge loss. Furthermore, they do not consider the temporal logic of medical diagnosis and treatment, making it difficult to adapt to multi-task scenarios such as medical question answering, medical record generation, and diagnostic reasoning.

Method used

By acquiring medical corpora and knowledge graphs, fine-grained semantic parsing is performed to generate unstructured entity sequences. Multidimensional association path reasoning is then carried out based on pathological semantic association edges. Graph structure embedding is dynamically injected to generate enhanced training samples, and standardized instruction encoding and model parameter iterative optimization are performed.

Benefits of technology

It provides professional and complete semantic support, significantly improving the training efficiency, professional reasoning accuracy, and output stability of the medical big language model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121998101B_ABST
    Figure CN121998101B_ABST
Patent Text Reader

Abstract

This invention relates to the field of machine learning technology, and discloses a method and system for training a large-scale medical language model based on knowledge graph enhancement. The method includes: acquiring a medical corpus and knowledge graph; generating entity sequences through fine-grained semantic parsing; extracting multi-hop subgraphs through multi-dimensional association path reasoning; dynamically injecting text into the graph based on dynamic weights to generate enhanced training samples; parsing and encoding into a standardized instruction set; and iteratively optimizing to obtain the target model. This invention improves the training efficiency and professional reasoning capabilities of a large-scale medical language model through adaptive knowledge fusion and standardized instruction encoding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine learning technology, and in particular to a method and system for training large language models in the medical field based on knowledge graph enhancement. Background Technology

[0002] Existing methods mostly employ static knowledge injection, failing to dynamically adjust fusion weights based on the matching degree between text context and graph semantics, resulting in interference from irrelevant knowledge or the loss of key knowledge;

[0003] Existing methods for extracting subgraphs only consider semantic relevance and do not take into account the temporal logic of medical diagnosis and treatment, resulting in the order of subgraph nodes not matching the clinical reasoning chain;

[0004] Existing methods lack a standardized instruction template library for medical scenarios, and the training sample format is inconsistent, making it difficult to adapt to multi-task scenarios such as medical question answering, medical record generation, and diagnostic reasoning. Summary of the Invention

[0005] This invention provides a method and system for training large language models in the medical field based on knowledge graph enhancement, in order to solve the problems mentioned in the background art.

[0006] To achieve the above objectives, the present invention provides a method for training a large language model in the medical field based on knowledge graph enhancement, comprising:

[0007] A1. Obtain a medical corpus and a medical knowledge graph in the medical field;

[0008] A2. Perform fine-grained semantic parsing on the original medical text records in the medical corpus to generate unstructured entity sequences in the medical field;

[0009] A3. Based on the pathological semantic association edges of the medical domain knowledge graph, the unstructured entity sequence is mapped to the medical domain knowledge graph for multi-dimensional association path reasoning, and multi-hop subgraphs related to the original medical text records are extracted as a subset of the structured semantic graph of the medical domain;

[0010] A4. Dynamically inject the structured semantic graph subset into the corresponding entity positions of the original medical text record in a graph structure embedding manner to generate enhanced training samples in the medical field;

[0011] A5. Perform structured parsing on the enhanced training samples and encode the parsed samples into a standardized training instruction set for the medical field;

[0012] A6. Based on the standardized training instruction set, the parameters of the initial language processing model in the medical field are iteratively optimized to obtain the target medical language processing model in the medical field.

[0013] In a preferred embodiment, acquiring a medical corpus and a medical knowledge graph in the medical field includes:

[0014] Raw medical data is collected from authoritative medical data sources, and the raw medical data is cleaned to obtain an initial corpus in the medical field.

[0015] The data documents in the initial corpus are parsed for chapter structure and clinical entity recognition. Based on the identified clinical entities, the parsed data is semantically annotated to construct a medical corpus in the medical field.

[0016] Extract concept nodes from a pre-defined medical ontology library and clinical guidelines, and establish hierarchical relationships, attribute relationships, and logical reasoning rules between the concept nodes based on the semantic relationships between them, so as to construct an initial knowledge graph of the medical field.

[0017] By performing path pruning on the initial knowledge graph, a medical domain knowledge graph is obtained.

[0018] In a preferred embodiment, the step of performing fine-grained semantic parsing on the original medical text records in the medical corpus to generate an unstructured entity sequence in the medical field includes:

[0019] Sentence boundary recognition and clause segmentation are performed on the original medical text records in the medical corpus to obtain text fragments of the original medical text records;

[0020] The text fragment is tagged with part-of-speech tags to identify the core entities and attribute entities in the text fragment;

[0021] Dependency parsing is performed on the core entity and the attribute entity to obtain the semantic modification relations of the text fragment;

[0022] Based on the core entity, the attribute entity, and the semantic modification relationship, the text fragments are spliced ​​together according to their original order in the original medical text record to generate an unstructured entity sequence in the medical field.

[0023] In a preferred embodiment, the step of mapping the unstructured entity sequence to the medical domain knowledge graph based on the pathological semantic association edges for multidimensional association path reasoning includes:

[0024] The entities in the unstructured entity sequence are semantically similar to the nodes in the medical domain knowledge graph to generate a node mapping set in the medical domain.

[0025] Starting from the nodes in the node mapping set, a breadth-first traversal is performed along the pathological semantic association edges in the medical domain knowledge graph to obtain the candidate path set of the medical domain.

[0026] Based on the semantic relevance of the pathological semantic association edges, each path in the candidate path set is scored in multiple dimensions.

[0027] Based on preset standard thresholds, the scored paths are filtered one by one to obtain the set of filtered paths in the medical field.

[0028] In a preferred embodiment, the step of extracting a multi-hop subgraph related to the original medical text record as a subset of the structured semantic graph in the medical field includes:

[0029] Extract the nodes covered by the paths in the filtered path set, and combine them with the pathological semantic association edges to construct the initial subgraph of the medical field;

[0030] The initial subgraph is subjected to connectivity detection, and the disconnected branches in the initial subgraph are fused according to the semantic associations between entities in the unstructured entity sequence to obtain the connected subgraph of the medical field.

[0031] Based on the connected subgraph, the order of entity appearance in the original medical text record is determined; based on the order of entity appearance, the connected subgraph is topologically sorted, and the sorted subgraph is encapsulated into a graph data structure as a subset of the structured semantic graph in the medical field.

[0032] In a preferred embodiment, dynamically injecting the subset of the structured semantic graph into the corresponding entity location of the original medical text record in a graph-structured embedding manner includes:

[0033] Graph neural network encoding is performed on the nodes in the structured semantic graph subset to generate graph embedding vectors corresponding to the nodes;

[0034] Context encoding is performed on the entities in the original medical text record to obtain the context embedding vector corresponding to the entity;

[0035] Based on the graph embedding vector and the context embedding vector, the dynamic injection weight of the entity is calculated, wherein the formula for calculating the dynamic injection weight is:

[0036] ;

[0037] In the formula, For the first The dynamic injection weights of the entities, It is an exponential function. This is a function for calculating vector similarity. For the first The graph embedding vector corresponding to each entity. For the first The graph embedding vector corresponding to each entity. For the first The context embedding vector corresponding to each entity. For the first The context embedding vector corresponding to each entity. The preset temperature coefficient, This is the sum of all entities in the original medical text record;

[0038] According to the dynamic injection weights, the graph embedding vector and the context embedding vector are weighted and fused to obtain the enhanced embedding vector for the medical field.

[0039] In a preferred embodiment, generating the enhanced training samples in the medical field includes:

[0040] The enhanced embedding vector is used to replace the original embedding representation of the corresponding entity in the original medical text record to obtain the entity-enhanced text sequence in the medical field;

[0041] Position encoding is performed on the entity-enhanced text sequence to obtain the position-enhanced text sequence in the medical field;

[0042] The location-enhanced text sequence is restructured according to the structure of the original medical text record to obtain the enhanced training samples in the medical field.

[0043] In a preferred embodiment, the step of performing structured parsing on the enhanced training samples and encoding the parsed samples into a standardized training instruction set for the medical field includes:

[0044] The enhanced training samples are parsed to obtain a set of structured components.

[0045] Entity boundaries are identified for the components in the structured component set to obtain the key medical entities of the components;

[0046] Semantic role annotation is performed on the key medical entities to determine their semantic relationships and functional roles, which are then integrated into the fine-grained semantic annotation results of the enhanced training samples.

[0047] Based on the preset instruction template library, the structured component set is matched with the fine-grained semantic annotation results to obtain the target instruction template of the enhanced training sample;

[0048] The component content in the structured component set is filled in according to the placeholder positions in the target instruction template to obtain the formatted instruction text of the enhanced training sample.

[0049] The formatted instruction text is serialized and encoded to obtain the standardized training instruction set for the medical field.

[0050] In a preferred embodiment, the step of iteratively optimizing the parameters of the initial language processing model in the medical field based on the standardized training instruction set to obtain the target medical language processing model in the medical field includes:

[0051] Based on the training batches of the standardized training instruction set, batch training data in the medical field is generated.

[0052] The initial language processing model in the medical field is used to perform forward propagation on each instruction in the training batch to obtain the predicted output sequence of the training batch.

[0053] The difference between the predicted output sequence and the corresponding label sequence in the training batch is measured to obtain the loss metric value of the training batch.

[0054] Based on the loss metric, backpropagation is performed on the trainable parameters in the initial language processing model to obtain the gradient values ​​of the trainable parameters;

[0055] Based on the gradient value, the trainable parameters are iteratively updated to obtain the target medical language processing model in the medical field.

[0056] To address the aforementioned problems, this invention also provides a knowledge graph-based augmented large language model training system for the medical field, the system comprising:

[0057] The data acquisition module is used to acquire medical corpora and medical knowledge graphs in the medical field.

[0058] The semantic parsing module is used to perform fine-grained semantic parsing on the original medical text records in the medical corpus to generate unstructured entity sequences in the medical field.

[0059] The graph construction module is used to map the unstructured entity sequence to the medical domain knowledge graph based on the pathological semantic association edges of the medical domain knowledge graph, perform multi-dimensional association path reasoning, and extract multi-hop subgraphs related to the original medical text records as a subset of the structured semantic graph of the medical domain.

[0060] An enhanced training module is used to dynamically inject the subset of the structured semantic graph into the corresponding entity positions of the original medical text record in a graph structure embedding manner, thereby generating enhanced training samples in the medical field. The enhanced training module includes:

[0061] Graph neural network encoding units are used to generate graph embedding vectors;

[0062] Context encoding unit, used to generate context embedding vector;

[0063] The dynamic weight calculation unit is used to calculate dynamically injected weights based on vector similarity.

[0064] Vector fusion unit, used for weighted fusion to generate enhanced embedding vectors;

[0065] The instruction encoding module is used to perform structured parsing of the enhanced training samples and encode the parsed samples into a standardized training instruction set for the medical field.

[0066] The parameter optimization module is used to perform iterative parameter optimization on the initial language processing model in the medical field based on the standardized training instruction set, so as to obtain the target medical language processing model in the medical field.

[0067] Compared with the prior art, the present invention has the following beneficial effects:

[0068] 1. This invention accurately extracts text entity sequences through dual-source construction of medical corpora and knowledge graphs and fine-grained semantic parsing. It combines pathological semantic association edges to complete multi-hop association path reasoning and automatically extracts a subset of structured semantic graphs that highly match the medical text, providing professional and complete semantic support for model training.

[0069] 2. This invention employs a graph-structured embedding dynamic injection mechanism to fuse graph features with textual context representation, generating high-quality enhanced training samples. It unifies the input format through standardized instruction encoding, and then completes iterative optimization of model parameters based on loss metrics and gradient backpropagation, significantly improving the training efficiency, professional inference accuracy, and output stability of the medical large language model. Attached Figure Description

[0070] Figure 1 This is a flowchart illustrating a method for training a large language model in the medical field based on knowledge graph enhancement, according to an embodiment of the present invention.

[0071] Figure 2 This is a functional module diagram of a knowledge graph-based large language model training system for the medical field, provided in an embodiment of the present invention.

[0072] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0073] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0074] This application provides a method for training a large language model in the medical field based on knowledge graph enhancement. The execution entity of this method includes, but is not limited to, at least one of the following electronic devices that can be configured to execute the method provided in this application: a server, a terminal, etc. In other words, the method can be executed by software or hardware installed on a terminal device or a server device. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cluster of cloud servers. The server can be an independent server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0075] Reference Figure 1 The diagram shown is a flowchart illustrating a knowledge graph-based method for training a large language model in the medical field, according to an embodiment of the present invention. In this embodiment, the knowledge graph-based method for training a large language model in the medical field includes:

[0076] A1. Obtain a medical corpus and a medical knowledge graph in the medical field;

[0077] In this embodiment of the invention, obtaining a medical corpus and a medical knowledge graph in the medical field includes:

[0078] Raw medical data is collected from authoritative medical data sources, and the raw medical data is cleaned to obtain an initial corpus in the medical field.

[0079] The data documents in the initial corpus are parsed for chapter structure and clinical entity recognition. Based on the identified clinical entities, the parsed data is semantically annotated to construct a medical corpus in the medical field.

[0080] Extract concept nodes from a pre-defined medical ontology library and clinical guidelines, and establish hierarchical relationships, attribute relationships, and logical reasoning rules between the concept nodes based on the semantic relationships between them, so as to construct an initial knowledge graph of the medical field.

[0081] By performing path pruning on the initial knowledge graph, a medical domain knowledge graph is obtained.

[0082] We collected publicly available raw medical data from authoritative medical data sources such as medical and health databases, clinical databases of top-tier public hospitals, and authoritative medical journal publication platforms. The collected data included all types of medical information such as clinical medical records, treatment guidelines, medical literature, and examination reports. Redundant content was removed, errors were corrected, invalid formats were filtered, and privacy information was desensitized for each piece of raw medical data. After completing all the cleaning operations, we obtained the initial corpus in the medical field.

[0083] All data documents in the initial corpus are disassembled layer by layer according to the text structure of the table of contents paragraphs, clarifying the category of each part. At the same time, the disease names, symptoms, examination items, treatment methods, and drug names appearing in the documents are accurately identified. All identified content is determined as clinical entities. Then, according to the medical meanings corresponding to the clinical entities, uniform and standardized semantic tags are added to the parsed data. After completing all annotation operations, a medical corpus in the medical field is constructed.

[0084] The system extracts standard concepts of diseases, symptoms, examinations, drugs, and treatment methods from a pre-defined medical ontology. Simultaneously, it extracts professional concepts of diagnosis and treatment procedures, applicable conditions, and contraindications from clinical guidelines. All extracted content is designated as concept nodes. Based on the actual association logic in the medical scenario, hierarchical relationships, attribute relationships of feature descriptions, and logical reasoning rules for diagnosis and treatment are established for the concept nodes. After all relationships are established, an initial knowledge graph for the medical field is constructed.

[0085] Duplicate paths, invalid association paths, and paths without practical reasoning meaning in the initial knowledge graph are located and removed, while core paths that can support medical semantic understanding and clinical logical reasoning are retained. After completing all path pruning operations, a medical domain knowledge graph with a simplified structure, clear associations, and efficient reasoning is obtained.

[0086] The beneficial effects are that by collecting and cleaning data from authoritative medical data sources, redundant and erroneous information and desensitized private content can be removed, ensuring that the initial corpus is pure and standardized, thus laying a high-quality data foundation for subsequent corpus construction.

[0087] By performing chapter analysis, entity recognition, and semantic annotation on the initial corpus, core clinical information can be accurately extracted, forming a standardized medical corpus and improving the usability and professionalism of medical text data.

[0088] An initial knowledge graph is constructed based on medical ontology and clinical guidelines, and multi-level semantic association and reasoning rules are established to systematize medical knowledge and provide reliable support for semantic reasoning.

[0089] Path pruning of the initial knowledge graph can remove invalid and redundant paths, simplify the graph structure, improve the efficiency of subsequent association reasoning, and reduce the computational cost of model training.

[0090] A2. Perform fine-grained semantic parsing on the original medical text records in the medical corpus to generate unstructured entity sequences in the medical field;

[0091] In this embodiment of the invention, the step of performing fine-grained semantic parsing on the original medical text records in the medical corpus to generate an unstructured entity sequence in the medical field includes:

[0092] Sentence boundary recognition and clause segmentation are performed on the original medical text records in the medical corpus to obtain text fragments of the original medical text records;

[0093] The text fragment is tagged with part-of-speech tags to identify the core entities and attribute entities in the text fragment;

[0094] Dependency parsing is performed on the core entity and the attribute entity to obtain the semantic modification relations of the text fragment;

[0095] Based on the core entity, the attribute entity, and the semantic modification relationship, the text fragments are spliced ​​together according to their original order in the original medical text record to generate an unstructured entity sequence in the medical field.

[0096] The original medical text records in the medical corpus are analyzed word by word to determine the start and end positions of sentences. Sentence boundaries are located based on commonly used sentence end markers in medical texts. Long sentences are then segmented into independent clauses according to semantic completeness. All the segmented content is combined to form text fragments of the original medical text records. The original medical text records are derived from a cleaned and annotated standard corpus in the medical field.

[0097] Each word in the obtained text fragment is categorized and labeled with its lexical attributes. A part-of-speech tagging model based on bidirectional long short-term memory network and conditional random field is used to label words as fixed part-of-speech categories such as nouns, verbs, and adjectives. After the tagging is completed, core entities representing medical subjects and attribute entities representing descriptive information are selected. Both core entities and attribute entities are derived from the lexical tagging results of the text fragment.

[0098] A dependency parser based on graph neural networks is used to analyze the sentence component dependencies of the identified core entities and attribute entities. The description and limiting role of each attribute entity on the core entity are determined one by one, and the modification association and pointing relationship between the core entity and the attribute entity are clarified. The results of the analysis are directly used as the semantic modification relationship of the text segment. The semantic modification relationship comes from the entity dependency association determination within the text segment.

[0099] The identified core entities and attribute entities are organized according to the semantic modification relationships obtained from the analysis. Then, the text fragments are systematically spliced ​​together in strict accordance with the order in which they appear in the original medical text records, preserving the original semantic structure of the entities and relationships. After splicing, an unstructured entity sequence in the medical field is generated. The unstructured entity sequence completely preserves the semantic information and entity structure of the original medical text.

[0100] The beneficial effects are that sentence boundary recognition and clause segmentation of original medical texts can break down long texts into semantically complete text fragments, reducing the difficulty of subsequent parsing and laying a clear textual foundation for entity and relation extraction.

[0101] By tagging text fragments with part-of-speech tags and distinguishing between core and attribute entities, key medical information can be accurately located, irrelevant information can be avoided, and the completeness and accuracy of medical entity recognition can be improved.

[0102] By clarifying the semantic modification relationships between entities through dependency parsing, the inherent logic of medical texts can be restored, entity associations can be clearly depicted, and a reliable semantic basis can be provided for knowledge graph mapping.

[0103] The system concatenates entities and semantic relationships in the original text order to generate an unstructured sequence, fully preserving the semantic and structural information of the text, enabling fine-grained parsing, and adapting to the multi-hop reasoning requirements of subsequent knowledge graphs.

[0104] A3. Based on the pathological semantic association edges of the medical domain knowledge graph, the unstructured entity sequence is mapped to the medical domain knowledge graph for multi-dimensional association path reasoning, and multi-hop subgraphs related to the original medical text records are extracted as a subset of the structured semantic graph of the medical domain;

[0105] In this embodiment of the invention, the step of mapping the unstructured entity sequence to the medical domain knowledge graph based on the pathological semantic association edges of the medical domain knowledge graph for multi-dimensional association path reasoning includes:

[0106] The entities in the unstructured entity sequence are semantically similar to the nodes in the medical domain knowledge graph to generate a node mapping set in the medical domain.

[0107] Starting from the nodes in the node mapping set, a breadth-first traversal is performed along the pathological semantic association edges in the medical domain knowledge graph to obtain the candidate path set of the medical domain.

[0108] Based on the semantic relevance of the pathological semantic association edges, each path in the candidate path set is scored in multiple dimensions.

[0109] Based on preset standard thresholds, the scored paths are filtered one by one to obtain the set of filtered paths in the medical field.

[0110] The extraction of multi-hop subgraphs related to the original medical text records, as a subset of the structured semantic graph in the medical field, includes:

[0111] Extract the nodes covered by the paths in the filtered path set, and combine them with the pathological semantic association edges to construct the initial subgraph of the medical field;

[0112] The initial subgraph is subjected to connectivity detection, and the disconnected branches in the initial subgraph are fused according to the semantic associations between entities in the unstructured entity sequence to obtain the connected subgraph of the medical field.

[0113] Based on the connected subgraph, the order of entity appearance in the original medical text record is determined; based on the order of entity appearance, the connected subgraph is topologically sorted, and the sorted subgraph is encapsulated into a graph data structure as a subset of the structured semantic graph in the medical field.

[0114] Each entity in the unstructured entity sequence is semantically compared with each node in the medical domain knowledge graph. A BERT-based semantic matching model is used, where entity names and node names are encoded into semantic vectors and cosine similarity is calculated. ROC analysis of 1000 manually labeled medical entity-node pairs determines a similarity threshold of 0.85. At this threshold, the F1 score reaches its optimal value of 0.88. A successful match is defined as a similarity threshold greater than or equal to 0.85. Entities and nodes with perfect or highly similar semantics are bound together. All bound entities and nodes form a node mapping set for the medical domain. The unstructured entity sequence is derived from fine-grained semantic parsing results of medical texts, and the medical domain knowledge graph is derived from a standardized knowledge system constructed from medical ontology and clinical guidelines.

[0115] Starting from each node in the node mapping set, the search extends outwards according to the existing pathological semantic association edges in the medical knowledge graph. All nodes directly and indirectly connected to the starting node are visited in sequence. The maximum number of hops is set to 3 hops, which is based on the length of the typical clinical reasoning chain of "symptom-examination-diagnosis-treatment" in medical treatment guidelines. This covers the main diagnostic and treatment logic to ensure the clinical relevance of the path. Each extended path is fully recorded. All recorded paths are combined to form a candidate path set in the medical field. The pathological semantic association edges are derived from the semantic association relationships between disease symptoms, examinations, and treatments constructed in the knowledge graph.

[0116] For each path in the candidate path set, a comprehensive score is given based on the closeness of the medical meaning of the pathological semantic association edges on the path. The scoring is based on multiple dimensions, including the rationality of pathological logic, semantic coherence, and diagnostic matching degree. Each dimension uses a scoring standard of 0-1 points. The final total score is the weighted sum of the scores of the three dimensions, with weights of 0.4, 0.3, and 0.3, respectively. The total score of each path is obtained by summing the scores of each dimension. The scoring result directly reflects the degree of association and fit between the path and the original medical entity.

[0117] The score of each path in the candidate path set is compared with a pre-set standard threshold. The standard threshold is set to 0.7. Paths with scores greater than or equal to the standard threshold are retained, while paths with scores lower than the standard threshold are removed. All retained paths are combined to form a filtered path set in the medical field. The standard threshold is derived from the general normative requirements of knowledge reasoning in the medical field.

[0118] The system retrieves all node information from all paths in the filtered path set, combines these nodes with the existing pathological semantic association edges in the medical knowledge graph, uses nodes as the basic elements of the graph structure, and pathological semantic association edges as the connection relationships between nodes, and builds an initial subgraph for the medical field according to the association methods of the original knowledge graph. The filtered path set comes from the results of multi-dimensional association path reasoning and scoring in the previous knowledge graph, and the pathological semantic association edges come from the standard semantic connection relationships between disease symptom examination and treatment in the medical knowledge graph.

[0119] A complete connectivity test is performed on the initial subgraph, checking the connection status between nodes one by one to identify disconnected branches that are independent and unconnected. Then, referring to the semantic relationships between entities in the unstructured entity sequence, a fusion algorithm based on entity co-occurrence frequency and semantic similarity is used to merge and connect these scattered disconnected branches, so that all nodes form a complete and interconnected whole through pathological semantic association edges, resulting in a connected subgraph in the medical field. The unstructured entity sequence is derived from the fine-grained semantic parsing results of the original medical text records.

[0120] Based on the order in which entities appear in the original medical text records, the order of corresponding nodes in the connected subgraph is determined. Then, the nodes and pathological semantic association edges in the connected subgraph are topologically sorted according to the order in which the entities appear, so that the subgraph structure is consistent with the semantic order of the original medical text. The sorted subgraph is then encapsulated and organized according to the standard graph data structure, and finally serves as a subset of the structured semantic graph in the medical field. The original medical text records are derived from standardized medical text data that has been cleaned and annotated in the medical corpus.

[0121] Performance validation experiments: Datasets: PubMedQA medical question-answering dataset (1000 entries) + self-built clinical medical record dataset (500 entries); Comparison models: Baseline model: LLaMA-2-7B (without knowledge graph augmentation) Model in this application: Med-LLM trained using this method; Evaluation metrics: Accuracy: Baseline 723% vs. this application 847%, F1 score: Baseline 071 vs. this application 083, Number of training convergence rounds: Baseline 8 rounds vs. this application 3 rounds (efficiency improvement of 625%), Ablation experiments: Without dynamic weights (fixed α=0.5): Accuracy 812%, Without graph structure embedding: Accuracy 785%, Complete method: Accuracy 847%, thus demonstrating that both dynamic weights and graph embedding contribute to performance.

[0122] The beneficial effect is that by conducting semantic similarity matching between entities and knowledge graph nodes, the correspondence between text entities and graph nodes can be accurately established, forming a standardized node mapping set, which provides a reliable mapping basis for subsequent path reasoning.

[0123] Starting from the mapping node, a breadth-first traversal along the pathological semantic association edges can be performed to fully explore multi-hop associations between entities, generate a comprehensive candidate path set, and ensure the integrity of the pathological reasoning path.

[0124] Scoring candidate paths from multiple dimensions can quantitatively assess the semantic fit between the path and medical text, objectively measure the value of the path, and provide a scientific quantitative basis for path selection.

[0125] By filtering scoring paths according to thresholds, a set of filtered paths can be obtained, which can eliminate low-relevance invalid paths and retain high-value reasoning paths, thereby improving the accuracy and efficiency of subsequent subgraph construction.

[0126] By extracting the nodes covered by the filtered paths and combining them with pathological semantic association edges to construct an initial subgraph, a basic graph structure strongly related to the text can be quickly formed, providing a stable skeleton for subsequent semantic graph construction.

[0127] By performing connectivity checks on the initial subgraph and fusing branches according to entity semantic associations, isolated nodes in the subgraph can be eliminated, forming a complete and interconnected structure, thus strengthening the overall relevance of medical knowledge.

[0128] By topologically sorting connected subgraphs according to the order of text entities and encapsulating them into a standard graph structure, the graph order can be consistent with the text semantics, improving the adaptability and usability of the structured semantic graph subset.

[0129] A4. Dynamically inject the structured semantic graph subset into the corresponding entity positions of the original medical text record in a graph structure embedding manner to generate enhanced training samples in the medical field;

[0130] In this embodiment of the invention, dynamically injecting the subset of the structured semantic graph into the corresponding entity position of the original medical text record in a graph structure embedding manner includes:

[0131] Graph neural network encoding is performed on the nodes in the structured semantic graph subset to generate graph embedding vectors corresponding to the nodes;

[0132] Context encoding is performed on the entities in the original medical text record to obtain the context embedding vector corresponding to the entity;

[0133] Based on the graph embedding vector and the context embedding vector, the dynamic injection weight of the entity is calculated, wherein the formula for calculating the dynamic injection weight is:

[0134] ;

[0135] In the formula, For the first The dynamic injection weights of the entities, It is an exponential function. This is a function for calculating vector similarity. For the first The graph embedding vector corresponding to each entity. For the first The graph embedding vector corresponding to each entity. For the first The context embedding vector corresponding to each entity. For the first The context embedding vector corresponding to each entity. The preset temperature coefficient, This is the sum of all entities in the original medical text record;

[0136] According to the dynamic injection weights, the graph embedding vector and the context embedding vector are weighted and fused to obtain the enhanced embedding vector for the medical field.

[0137] The generation of enhanced training samples in the medical field includes:

[0138] The enhanced embedding vector is used to replace the original embedding representation of the corresponding entity in the original medical text record to obtain the entity-enhanced text sequence in the medical field;

[0139] Position encoding is performed on the entity-enhanced text sequence to obtain the position-enhanced text sequence in the medical field;

[0140] The location-enhanced text sequence is restructured according to the structure of the original medical text record to obtain the enhanced training samples in the medical field.

[0141] Each node in the structured semantic graph subset is input into a graph neural network for feature extraction. The graph neural network uses a graph attention network with two layers, a hidden layer dimension of 768, and four attention heads. It uses a pre-trained medical knowledge graph embedding as initialization. The graph neural network extracts the attribute features of the node itself and the connection features between the node and the surrounding pathological semantic association edges layer by layer. All extracted features are integrated and converted into a fixed-length vector form to generate the graph embedding vector corresponding to the node. The structured semantic graph subset is derived from the connected subgraph constructed after reasoning and screening of medical domain knowledge graphs.

[0142] For each entity in the original medical text records, contextual features are extracted by combining the text content before and after the entity. The BioBERT pre-trained language model is used as the context encoder. This model is pre-trained on biomedical literature. The input is a complete sentence containing the entity, and the output is the hidden layer vector of the entity position as the context embedding vector. The dimension is 768, which fully preserves the semantic environment information of the entity in the original medical text. The extracted contextual features are converted into vectors of uniform length to obtain the context embedding vector corresponding to the entity. The original medical text records are from a medical corpus that has been cleaned, labeled and semantically parsed.

[0143] The feature dimensions of the graph embedding vector and the context embedding vector are compared one by one to calculate the feature matching degree and complementarity between the two sets of vectors. Based on the matching and complementarity results, the allocation ratio of the graph embedding vector and the context embedding vector is determined. This ratio is the dynamic injection weight of the entity. The dynamic injection weight is entirely determined by the actual semantic association between the two sets of vectors.

[0144] Based on the calculated dynamic injection weights, the graph embedding vector and the context embedding vector are weighted separately. The two weighted vectors are then fused by feature overlay, retaining the core semantic information of both vectors and eliminating redundant features. Finally, an enhanced embedding vector for the medical field is generated, which contains both text context semantics and knowledge graph structured semantics.

[0145] No. The graph embedding vector corresponding to each entity is obtained by modeling the entity relationships in the original medical text records using a graph structure. Entities are treated as nodes in the graph structure, and the relationships between entities are treated as edges in the graph structure. The graph neural network iteratively learns the features of the nodes and edges to output the graph embedding vector corresponding to each entity.

[0146] No. The context embedding vector corresponding to each entity is obtained by semantically encoding the text context content in the original medical text record where the entity is located. The text sequence containing the entity is input into a pre-trained language model, and the model extracts and encodes the semantic features of the text context, outputting the context embedding vector corresponding to the entity.

[0147] The preset temperature coefficient is a fixed value set manually. The temperature coefficient adopts an annealing strategy during the training process. The initial value is 0.1, and it decays by 10% after each round of training, eventually converging to 0.05. It is used to regulate the distribution amplitude of the index calculation results and directly participates in the product operation of the vector similarity calculation results.

[0148] The sum of all entities in the original medical text record is the total number of entities obtained after entity identification and statistics of the original medical text record. This number determines the range of all entities covered by the summation operation of the index calculation results.

[0149] The vector similarity calculation function calculates the similarity between two input vectors by summing the products of their corresponding dimensions and then dividing by the product of their respective magnitudes. This calculation process directly inputs the first... The graph embedding vector corresponding to the entity and the _th entity The similarity result between two entities is output by considering the context embedding vectors corresponding to each entity.

[0150] The exponential function uses the natural constant as the base, multiplies the similarity value output by the vector similarity calculation function by the preset temperature coefficient, and uses the result as the exponent to calculate the corresponding exponential operation result.

[0151] Each entity in the original medical text record is calculated using the vector similarity and exponential function to obtain its corresponding exponential result. Then, the exponential results corresponding to all entities are added together to obtain the total summation result.

[0152] The first Dividing the result of the exponentiation operation for the nth entity by the sum of the results of the exponentiation operations for all entities yields the nth... Dynamically inject weights into each entity.

[0153] No. The dynamic injection weight of an entity is used to characterize the importance of the entity in the overall entity set of the original medical text record. This weight achieves differentiated quantitative allocation of the importance of different entities by integrating the entity's own graph structure association features and text context semantic features.

[0154] The generated enhanced embedding vectors are precisely mapped to the target entity positions in the original medical text records. The original initial embedding representation of the entity is completely replaced with the enhanced embedding vector. The replacement process maintains the original order and structure of the text sequence. After the replacement, an entity-enhanced text sequence in the medical field is obtained. The enhanced embedding vectors are derived from the result of dynamic weighted fusion of graph embedding vectors and context embedding vectors. The original medical text records are derived from cleaned and annotated medical corpus data.

[0155] Each character and entity position in the entity-enhanced text sequence is sequentially labeled. Independent positional feature information is assigned to each position according to the reading order of the text from front to back. The positional feature information is combined with the entity-enhanced text sequence position by position so that the sequence carries complete positional order information. The positional encoding uses sine and cosine functions to generate absolute positional codes. After processing, a position-enhanced text sequence in the medical field is obtained. The positional encoding rules are formulated based on the standard positional representation method of natural language text processing.

[0156] The position-enhanced text sequence is rearranged according to the original paragraph structure, sentence structure and entity distribution structure of the original medical text record to restore the complete chapter format of the original medical text. The recombined text sequence is structurally completely consistent with the original medical text. After the recombination, a medical domain-enhanced training sample that can be directly used for model training is obtained. The structure of the original medical text record comes from the standardized medical text chapter format in the medical corpus.

[0157] The beneficial effect is that by using graph neural networks to encode the nodes of structured semantic graphs to generate graph embedding vectors, the pathological associations and entity attribute features in the knowledge graph can be fully extracted, providing professional knowledge support for text enhancement.

[0158] Contextual encoding of medical text entities yields contextual embedding vectors, which can fully preserve the semantic information of entities in the clinical context, ensuring the accuracy and completeness of text features.

[0159] Dynamically injected weights are calculated based on graph embedding and context embedding, which can adaptively quantify the fusion ratio of knowledge and text features, thereby achieving differentiated feature enhancement and improving the rationality of fusion.

[0160] By dynamically weighting and fusing the two types of vectors, the structured features of the knowledge graph and the contextual features of the text can be efficiently combined to generate enhanced embedding vectors that combine professionalism and contextual information.

[0161] By replacing the original entity embedding representation with enhanced embedding vectors, the professional semantics of the knowledge graph can be deeply integrated into the text entities, strengthening the expression of medical entity features and improving the richness of the professional semantics of the text.

[0162] Positional encoding of entity-enhanced text sequences can inject ordered positional information into the text sequence, preserve the logical order of medical texts, and enhance the model's ability to understand the structure of text sequences.

[0163] By reorganizing the positional augmentation sequence according to the original medical text structure, the text's chapter format and semantic integrity can be restored, generating standardized and uniform augmented training samples that are adapted to the model training input requirements.

[0164] A5. Perform structured parsing on the enhanced training samples and encode the parsed samples into a standardized training instruction set for the medical field;

[0165] In this embodiment of the invention, the step of performing structured parsing on the enhanced training samples and encoding the parsed samples into a standardized training instruction set for the medical field includes:

[0166] The enhanced training samples are parsed to obtain a set of structured components.

[0167] Entity boundaries are identified for the components in the structured component set to obtain the key medical entities of the components;

[0168] Semantic role annotation is performed on the key medical entities to determine their semantic relationships and functional roles, which are then integrated into the fine-grained semantic annotation results of the enhanced training samples.

[0169] Based on the preset instruction template library, the structured component set is matched with the fine-grained semantic annotation results to obtain the target instruction template of the enhanced training sample;

[0170] The component content in the structured component set is filled in according to the placeholder positions in the target instruction template to obtain the formatted instruction text of the enhanced training sample.

[0171] The formatted instruction text is serialized and encoded to obtain the standardized training instruction set for the medical field.

[0172] The enhanced training samples are decomposed layer by layer according to paragraph division, sentence division, and semantic unit division, separating independent content units such as title field, symptom description field, examination result field, diagnosis conclusion field, and treatment suggestion field. A rule parser based on regular expressions and domain dictionary is used, combined with the chapter title keywords of medical text for boundary recognition. All separated content units together form a structured component set of enhanced training samples. The enhanced training samples are derived from the entity enhancement and position encoding processing results that integrate knowledge graph semantics and text context semantics.

[0173] Lexical boundaries and entity ranges are determined for the text content of each independent component in the structured component set. A BERT-based named entity recognition model is used, which is fine-tuned on medical domain corpora. It can identify 15 types of medical entities, including diseases, symptoms, examinations, drugs, treatments, and body parts. It accurately locates the start and end positions of medical concepts such as diseases, symptoms, examination items, drugs, treatments, and body parts. The located concepts are identified as the key medical entities of the component. The identification criteria for key medical entities are derived from the standard entity definitions in the medical domain knowledge graph.

[0174] The identified key medical entities are functionally categorized and their relationships are labeled in a medical context. A deep neural network model based on semantic role labeling is used. The input is the sentence in which the entity is located, and the output is the semantic role of the entity in the clinical context. The labeling content includes the entity's role as the cause, symptom, examination, treatment, and target organ in the diagnosis and treatment process. At the same time, the causal relationship, correspondence relationship, and constraint relationship between entities are clarified. All the labeled content is integrated to form the fine-grained semantic labeling results of the enhanced training samples. The labeling rules are formulated according to the clinical semantic norms in the medical field.

[0175] A pre-built instruction template library contains over 500 standard instruction templates for medical scenarios. Each template includes a fixed natural language instruction prefix, placeholder structure, and output format constraints. Template types cover tasks such as diagnostic reasoning, treatment plan generation, examination result interpretation, and medical record summary generation. The template library is constructed through a combination of manual organization and automatic clustering, covering the main application scenarios of medical language processing.

[0176] Various standard templates suitable for medical scenarios are retrieved from a pre-built instruction template library. The field types of the structured component set are matched item by item with the entity roles and template features of the fine-grained semantic annotation results. The matching adopts a template selection model based on multi-label classification. The input is the joint feature vector of the structured component set and the semantic annotation results, and the output is the most suitable template identifier. The template that is completely compatible with the structure and semantics of the current sample is selected as the target instruction template for the enhanced training sample. The instruction template library is derived from the standardized instruction design specifications of medical text tasks.

[0177] The actual content of each component in the structured component group is filled one by one according to the placeholder positions reserved in the target instruction template, so that the text content is completely combined with the instruction template. The original semantics and order of the components are kept unchanged during the filling process. After filling, the formatted instruction text of the enhanced training sample is obtained. The placeholder positions are set according to the standard logical structure of medical instructions.

[0178] The formatted instruction text is serialized using JSON format, converting the text into fixed-format encoded data that the model can directly read. All the converted encoded data are then aggregated to form a standardized training instruction set for the medical field. The serialization encoding rules are based on the standard input format for training artificial intelligence models.

[0179] The beneficial effect is that by performing text structure analysis on the enhanced training samples, complex medical texts can be decomposed into a set of standardized structured components, clarifying the boundaries of text semantic units and providing a clear foundation for subsequent instruction encoding.

[0180] Entity boundary recognition of structured components can accurately locate key medical entities, extract core diagnostic and treatment information, enhance medical text features, and improve the accuracy of subsequent semantic annotation and instruction generation.

[0181] Semantic role labeling of key medical entities can clarify the clinical semantic relationships and functional roles between entities, generate fine-grained labeling results, and ensure the professionalism and accuracy of medical semantic understanding.

[0182] By matching target templates with the instruction template library, it can quickly adapt to medical task scenarios, unify instruction generation standards, simplify the conversion process from samples to training instructions, and improve coding efficiency.

[0183] By using template placeholders to structure and fill component content, scattered medical information can be integrated into formatted instruction text, ensuring that the instruction logic is rigorous, the format is consistent, and it adapts to the model input requirements.

[0184] Serialization encoding of formatting instructions can convert them into a standardized instruction set that the model can directly read, unify the training data format, and improve the model training stability and convergence speed.

[0185] A6. Based on the standardized training instruction set, the parameters of the initial language processing model in the medical field are iteratively optimized to obtain the target medical language processing model in the medical field.

[0186] In this embodiment of the invention, the step of iteratively optimizing the parameters of the initial language processing model in the medical field based on the standardized training instruction set to obtain the target medical language processing model in the medical field includes:

[0187] Based on the training batches of the standardized training instruction set, batch training data in the medical field is generated.

[0188] The initial language processing model in the medical field is used to perform forward propagation on each instruction in the training batch to obtain the predicted output sequence of the training batch.

[0189] The difference between the predicted output sequence and the corresponding label sequence in the training batch is measured to obtain the loss metric value of the training batch.

[0190] Based on the loss metric, backpropagation is performed on the trainable parameters in the initial language processing model to obtain the gradient values ​​of the trainable parameters;

[0191] Based on the gradient value, the trainable parameters are iteratively updated to obtain the target medical language processing model in the medical field.

[0192] The standardized training instruction set is grouped according to the preset training batch size, and all instructions are sequentially assigned to different training batches. Each batch contains a fixed number of instruction data. After all groups are completed, batch training data in the medical field is generated. The standardized training instruction set comes from the processing results of medical text structured parsing and formatted instruction encoding.

[0193] Each batch of batched training data is sequentially input into the initial language processing model for the medical field. This initial language processing model adopts a large language model based on the Transformer decoder architecture, specifically the LLaMA-2-7B model structure, which contains 32 Transformer layers, a hidden layer dimension of 4096, 32 attention heads, and 7 billion model parameters. The model weights are initialized using general domain pre-trained parameters. The model extracts features and performs semantic calculations for each instruction layer by layer according to the internal network structure, completing the forward propagation process from input to output. Finally, the model outputs the prediction results of the current batch of instructions. All prediction results are combined to form the prediction output sequence of the training batch. The initial language processing model is a basic language model that has not been optimized for medical field data.

[0194] The predicted output sequence obtained from the training batch is compared position by position and content by content with the pre-annotated real label sequence of the batch. The cross-entropy loss function is used as the difference measure. The negative log-likelihood is calculated for the output at each position. The semantic difference and numerical difference between the two are calculated. All differences are summarized and quantified to obtain the loss measure of the training batch. The real label sequence comes from the standard annotation results of the medical corpus and is used to measure the accuracy of the model prediction.

[0195] Based on the calculated loss metric, error information is propagated backward from the output layer to the input layer of the initial language processing model. The contribution of each trainable parameter to the error is calculated layer by layer, and the contribution is quantified into gradient values. The AdamW optimizer is used for gradient calculation, with the initial learning rate set to 2e-5 and the weight decay coefficient set to 0.01. The gradient value directly reflects the direction and magnitude of parameter adjustment. Trainable parameters include the weights and biases within the model.

[0196] Based on the calculated gradient values, the trainable parameters of the initial language processing model are adjusted and updated parameter by parameter, modifying the parameter values ​​in the direction of reducing the loss metric. The complete process of forward propagation, loss calculation, backpropagation, and parameter update is repeated. The number of training rounds is set to 3. After each round of training, the model is evaluated on the validation set. The model with the lowest loss on the validation set is selected as the final model. This process continues until the model's prediction performance reaches a stable standard, and finally, the target medical language processing model in the medical field is obtained through optimization.

[0197] The beneficial effects are that batch training data can be divided according to a standardized training instruction set, which can realize the standardized grouping of training data, improve the parallel efficiency of data reading and model training, and reduce resource consumption.

[0198] By performing forward propagation on batch instructions to obtain the predicted output sequence, the medical semantic features in the instructions can be fully explored, providing accurate prediction basis for model parameter optimization.

[0199] The loss value is obtained by measuring the difference between the predicted output and the label sequence. This can quantify the model's prediction bias, provide a clear error guide for backpropagation, and improve the targeting of parameter optimization.

[0200] Calculating parameter gradients using backpropagation based on loss values ​​can accurately pinpoint the direction and magnitude of model parameter adjustments, avoiding invalid iterations and accelerating model convergence.

[0201] By iteratively updating the model parameters based on the gradient values, the model's medical semantic understanding and reasoning capabilities can be continuously optimized, ultimately generating a high-precision target language processing model adapted to medical scenarios.

[0202] like Figure 2 The diagram shown is a functional block diagram of a medical field large language model training system based on knowledge graph enhancement provided in an embodiment of the present invention.

[0203] The knowledge graph-based augmented medical language model training system of this invention can be installed in an electronic device. Depending on the functions implemented, the knowledge graph-based augmented medical language model training system may include a data acquisition module, a semantic parsing module, a graph construction module, an augmented training module, an instruction encoding module, and a parameter optimization module. The module described in this invention can also be called a unit, which refers to a series of computer program segments that can be executed by the processor of an electronic device and can perform a fixed function, stored in the memory of the electronic device.

[0204] In this embodiment, the functions of each module / unit are as follows:

[0205] The data acquisition module is used to acquire a medical corpus and a medical knowledge graph in the medical field.

[0206] The semantic parsing module is used to perform fine-grained semantic parsing on the original medical text records in the medical corpus to generate unstructured entity sequences in the medical field.

[0207] The graph construction module is used to map the unstructured entity sequence to the medical domain knowledge graph based on the pathological semantic association edges of the medical domain knowledge graph to perform multi-dimensional association path reasoning, and extract multi-hop subgraphs related to the original medical text records as a subset of the structured semantic graph of the medical domain.

[0208] The enhanced training module is used to dynamically inject the subset of the structured semantic graph into the corresponding entity positions of the original medical text record in a graph structure embedding manner, thereby generating enhanced training samples in the medical field. The enhanced training module includes:

[0209] Graph neural network encoding units are used to generate graph embedding vectors;

[0210] Context encoding unit, used to generate context embedding vector;

[0211] The dynamic weight calculation unit is used to calculate dynamically injected weights based on vector similarity.

[0212] Vector fusion unit, used for weighted fusion to generate enhanced embedding vectors;

[0213] The instruction encoding module is used to perform structured parsing of the enhanced training samples and encode the parsed samples into a standardized training instruction set for the medical field.

[0214] The parameter optimization module is used to perform iterative parameter optimization on the initial language processing model in the medical field based on the standardized training instruction set, so as to obtain the target medical language processing model in the medical field.

[0215] In the several embodiments provided by this invention, it should be understood that the disclosed methods and systems can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.

[0216] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0217] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.

[0218] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0219] This application embodiment can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.

[0220] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A method for training a large language model in the medical field based on knowledge graph enhancement, characterized in that: The method includes: A1. Obtain a medical corpus and a medical knowledge graph in the medical field; A2. Perform fine-grained semantic parsing on the original medical text records in the medical corpus to generate unstructured entity sequences in the medical field; A3. Based on the pathological semantic association edges of the medical domain knowledge graph, the unstructured entity sequence is mapped to the medical domain knowledge graph for multi-dimensional association path reasoning, and multi-hop subgraphs related to the original medical text records are extracted as a subset of the structured semantic graph of the medical domain; A4. Dynamically inject the structured semantic graph subset into the corresponding entity positions of the original medical text record using graph structure embedding to generate enhanced training samples for the medical domain, including: Graph neural network encoding is performed on the nodes in the structured semantic graph subset to generate graph embedding vectors corresponding to the nodes; Context encoding is performed on the entities in the original medical text record to obtain the context embedding vector corresponding to the entity; Based on the graph embedding vector and the context embedding vector, the dynamic injection weight of the entity is calculated, wherein the formula for calculating the dynamic injection weight is: ; In the formula, For the first The dynamically injected weights of the entities, It is an exponential function. This is a function for calculating vector similarity. For the first The graph embedding vector corresponding to each entity. For the first The graph embedding vector corresponding to each entity. For the first The context embedding vector corresponding to each entity. For the first The context embedding vector corresponding to each entity. The preset temperature coefficient, This is the sum of all entities in the original medical text record; According to the dynamic injection weight, the graph embedding vector and the context embedding vector are weighted and fused to obtain the enhanced embedding vector in the medical field; The enhanced embedding vector is used to replace the original embedding representation of the corresponding entity in the original medical text record to obtain the entity-enhanced text sequence in the medical field; Position encoding is performed on the entity-enhanced text sequence to obtain the position-enhanced text sequence in the medical field; The location-enhanced text sequence is restructured according to the structure of the original medical text record to obtain the enhanced training samples in the medical field. A5. Perform structured parsing on the enhanced training samples and encode the parsed samples into a standardized training instruction set for the medical field; A6. Based on the standardized training instruction set, the parameters of the initial language processing model in the medical field are iteratively optimized to obtain the target medical language processing model in the medical field.

2. The method for training a large language model in the medical field based on knowledge graph enhancement as described in claim 1, characterized in that, The acquisition of a medical corpus and a medical knowledge graph in the medical field includes: Raw medical data is collected from authoritative medical data sources, and the raw medical data is cleaned to obtain an initial corpus in the medical field. The data documents in the initial corpus are parsed for chapter structure and clinical entity recognition. Based on the identified clinical entities, the parsed data is semantically annotated to construct a medical corpus in the medical field. Extract concept nodes from a pre-defined medical ontology library and clinical guidelines, and establish hierarchical relationships, attribute relationships, and logical reasoning rules between the concept nodes based on the semantic relationships between them, so as to construct an initial knowledge graph of the medical field. By performing path pruning on the initial knowledge graph, a medical domain knowledge graph is obtained.

3. The method for training a large language model in the medical field based on knowledge graph enhancement as described in claim 1, characterized in that, The step of performing fine-grained semantic parsing on the original medical text records in the medical corpus to generate unstructured entity sequences in the medical field includes: Sentence boundary recognition and clause segmentation are performed on the original medical text records in the medical corpus to obtain text fragments of the original medical text records; The text fragment is tagged with part-of-speech tags to identify the core entities and attribute entities in the text fragment; Dependency parsing is performed on the core entity and the attribute entity to obtain the semantic modification relations of the text fragment; Based on the core entity, the attribute entity, and the semantic modification relationship, the text fragments are spliced ​​together according to their original order in the original medical text record to generate an unstructured entity sequence in the medical field.

4. The method for training a large language model in the medical field based on knowledge graph enhancement as described in claim 1, characterized in that, The pathological semantic association edges based on the medical domain knowledge graph map the unstructured entity sequence to the medical domain knowledge graph for multi-dimensional association path reasoning, including: The entities in the unstructured entity sequence are semantically similar to the nodes in the medical domain knowledge graph to generate a node mapping set in the medical domain. Starting from the nodes in the node mapping set, a breadth-first traversal is performed along the pathological semantic association edges in the medical domain knowledge graph to obtain the candidate path set of the medical domain. Based on the semantic relevance of the pathological semantic association edges, each path in the candidate path set is scored in multiple dimensions. The multiple dimensions include the rationality of pathological logic, semantic coherence, and diagnostic-treatment matching degree, with weights of 0.4, 0.3, and 0.3 for each dimension, respectively. Based on a preset standard threshold of 0.7, the scored paths are filtered one by one, and paths with scores greater than or equal to the standard threshold are retained to obtain the filtered path set in the medical field.

5. The method for training a large language model in the medical field based on knowledge graph enhancement as described in claim 4, characterized in that, The extraction of multi-hop subgraphs related to the original medical text records, as a subset of the structured semantic graph in the medical field, includes: Extract the nodes covered by the paths in the filtered path set, and combine them with the pathological semantic association edges to construct the initial subgraph of the medical field; The initial subgraph is subjected to connectivity detection, and the disconnected branches in the initial subgraph are fused according to the semantic associations between entities in the unstructured entity sequence to obtain the connected subgraph of the medical field. Based on the connected subgraph, the order of entity appearance in the original medical text record is determined; based on the order of entity appearance, the connected subgraph is topologically sorted, and the sorted subgraph is encapsulated into a graph data structure as a subset of the structured semantic graph in the medical field.

6. The method for training a large language model in the medical field based on knowledge graph enhancement as described in claim 1, characterized in that, The step of performing structured parsing on the enhanced training samples and encoding the parsed samples into a standardized training instruction set for the medical field includes: The enhanced training samples are parsed to obtain a set of structured components. Entity boundaries are identified for the components in the structured component set to obtain the key medical entities of the components; Semantic role annotation is performed on the key medical entities to determine their semantic relationships and functional roles, which are then integrated into the fine-grained semantic annotation results of the enhanced training samples. Based on the preset instruction template library, the structured component set is matched with the fine-grained semantic annotation results to obtain the target instruction template of the enhanced training sample; The component content in the structured component set is filled in according to the placeholder positions in the target instruction template to obtain the formatted instruction text of the enhanced training sample. The formatted instruction text is serialized and encoded to obtain the standardized training instruction set for the medical field.

7. The method for training a large language model in the medical field based on knowledge graph enhancement as described in claim 1, characterized in that, The step of iteratively optimizing the parameters of the initial language processing model in the medical field based on the standardized training instruction set to obtain the target medical language processing model in the medical field includes: Based on the training batches of the standardized training instruction set, batch training data in the medical field is generated. The initial language processing model in the medical field is used to perform forward propagation on each instruction in the training batch to obtain the predicted output sequence of the training batch. The difference between the predicted output sequence and the corresponding label sequence in the training batch is measured to obtain the loss metric value of the training batch. Based on the loss metric, backpropagation is performed on the trainable parameters in the initial language processing model to obtain the gradient values ​​of the trainable parameters; Based on the gradient value, the trainable parameters are iteratively updated to obtain the target medical language processing model in the medical field.

8. A training system for a large language model in the medical field based on knowledge graph enhancement, characterized in that: The system for implementing the knowledge graph-based large language model training method for the medical field as described in claim 1, the system comprising: The module comprises a data acquisition module, a semantic parsing module, a graph construction module, a reinforcement training module, an instruction encoding module, and a parameter optimization module, among which: The output of the data acquisition module is connected to the input of the semantic parsing module, and is used to output a medical corpus and a medical domain knowledge graph. The output of the semantic parsing module is connected to the input of the graph construction module, and is used to output an unstructured entity sequence; The output of the graph construction module is connected to the input of the enhancement training module, and is used to output a subset of structured semantic graphs; The enhanced training module includes: Graph neural network encoding units are used to generate graph embedding vectors; Context encoding unit, used to generate context embedding vector; The dynamic weight calculation unit is used to calculate dynamically injected weights based on vector similarity. Vector fusion unit, used for weighted fusion to generate enhanced embedding vectors; The output of the instruction encoding module is connected to the input of the parameter optimization module, and is used to output a standardized training instruction set; The parameter optimization module is used to output the target medical language processing model.