A medical knowledge graph completion method and system based on large language model
By adopting path-based algorithms and node-first functions in medical knowledge graph completion, combined with large language models, the data sparsity and incompleteness problems are solved, interpretability is enhanced and hallucination phenomena is reduced, and the optimized knowledge graph is realized Construction and automation completion have improved the accuracy of medical decision-making.
Patent Information
- Application Number
- CN202411330430.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-09-24
AI Technical Summary
There is data sparsity and incompleteness in the construction process of existing medical knowledge graphs, which makes it difficult to support medical decision-making and reasoning. In addition, large language models lack structured information and interpretability when completing knowledge graphs, which are prone to hallucinations.
Path-based algorithm and node-first function are used to pre-train all paths of the target triple, and the optimal neighbor node is selected to obtain the relationship embedding vector and the trained node-first function. Generate virtual path markers through the path text alignment adapter and splice them with the text embed vectors, and enter a large language model to evaluate the rationality of triples.
By capturing the path characteristics between entities, the interpretability of medical knowledge graphs is enhanced, the occurrence of hallucinations is reduced, the process of building knowledge graphs is optimized, and automated completion is achieved, improving the accuracy of medical decision-making and reasoning is improved. .
Smart Images

Figure CN118863046B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing technology, and in particular to a medical knowledge graph completion method and system based on a large language model. Background Art
[0002] As a structured knowledge representation and management method, knowledge graph consists of a series of fact triplets. In recent years, knowledge graph has shown significant practicality in the medical field and has been applied to disease risk assessment, auxiliary diagnosis and treatment, medical quality control, and knowledge-based question answering.
[0003] Large knowledge bases usually have a long-tail distribution, that is, a few common entities and relations occupy most of the references, while a large number of low-frequency entities face the problem of sparse data. In the field of medicine, this situation is particularly serious. Many rare diseases or specific treatments often lack relevant information, making it difficult to obtain comprehensive information during reasoning. In addition, large-scale medical knowledge graphs are often incomplete and lack certain important medical facts, which further limits the performance of medical knowledge graphs in medical applications.
[0004] Most medical knowledge graphs are manually built by medical experts, which is expensive and laborious, and therefore often fails to meet the rapidly changing medical information needs. In this case, the problems of long-tail distribution and data sparsity are more prominent, making it difficult to fully utilize the information of many rare diseases and specific treatments. In the prior art, when using large language models for knowledge graph completion, there are two methods: directly inputting text triples (KG-LLaMA) or combining knowledge graph embedding with the model of a large language model (KoPA). However, the former ignores the structured information of the knowledge graph, the latter lacks interpretability, and both are prone to hallucinations. Therefore, the shortcomings of the prior art mainly include the lack of structured information and interpretability, and susceptibility to hallucinations.
[0005] Therefore, there is an urgent need for a medical knowledge graph completion method and system based on a large language model, which can optimize the construction process of the medical knowledge graph and automatically complete the medical knowledge graph, thereby ensuring that the knowledge graph can better support medical decision-making and reasoning, and improve the efficiency and accuracy of clinical practice. Summary of the invention
[0006] In order to solve the above technical problems, the present invention provides a medical knowledge graph completion method and system based on a large language model, which can optimize the construction process of the medical knowledge graph and automatically complete the medical knowledge graph, thereby ensuring that the knowledge graph can better support medical decision-making and reasoning, and improve the efficiency and accuracy of clinical practice.
[0007] The present invention provides a method for completing a medical knowledge graph based on a large language model, which specifically includes the following steps:
[0008] S1. Obtain an initial medical knowledge graph; wherein the initial medical knowledge graph includes a number of triples, each of which includes a head entity, a relationship, and a tail entity;
[0009] S2. Pre-train all paths of the target triplet using a path-based algorithm and a node priority function, screen out a preset number of optimal neighbor nodes of the target tail entity, and obtain the relationship embedding vector of the path to which the optimal neighbor node belongs, as well as the trained node priority function; wherein the path represents a sequence of relationships between the target head entity, the target tail entity, and other nodes;
[0010] S3. According to the trained node priority function, the paths to which the selected optimal neighbor nodes belong are scored, and the path scores are sorted from large to small, and the top N paths are selected as important paths;
[0011] S4, inputting the relation embedding vectors of the N important paths into the path text alignment adapter to obtain virtual path labels;
[0012] S5, input the text description into the embedding layer of the large language model to obtain the embedding vector of the text, concatenate the virtual path tag and the embedding vector of the text, and input them into the large language model together, and output whether the target triple is correct;
[0013] S6. Complete the initial medical knowledge graph based on the correct target triples outputted to obtain the final medical knowledge graph.
[0014] Furthermore, in S2, a path-based algorithm and a node priority function are used to pre-train all paths of the target triple, and a preset number of optimal neighbor nodes of the target tail entity are screened out to obtain the relational embedding vector of the path to which the optimal neighbor node belongs, including:
[0015] S21. Use a path-based algorithm to pre-train all paths of the target triplet. The calculation formula is as follows:
[0016] ;
[0017] Among them, h q (u,v) represents the embedding vector of the target head entity u and the target tail entity v under the target relation q, Z u→v represents the path set between the target head entity u and the target tail entity v, P represents any path in the path set, and w q (x, r, y) represents the embedding vector of a triple (x, r, y) under the target relation q;
[0018] S22. Use the node priority function to calculate the priority of the node, and select the optimal neighbor nodes of a preset number of target tail entities. The calculation formula is as follows:
[0019] ;
[0020] ;
[0021] Among them, s uq (t) is the node priority function, s uq (t) (x) represents the priority of entity x on the path from target head entity u to target relation q at time step t, and are two feedforward neural networks with different parameters, Represents the concatenation operation of two vectors, is the sigmoid function, h q (t) (u,x) represents the embedding vector of the head entity u and the tail entity x under the relation q at time step t; s uq (t-1) represents the node priority function at the (t-1) time step, represents the set of triples with node v as the tail entity, X (t) Represents the optimal neighbor node set obtained by the node priority function;
[0022] S23, the calculated relationship embedding vector of the path to which the optimal neighbor node belongs.
[0023] Furthermore, in S2, it is also necessary to train the path-based algorithm by minimizing a global loss, and the calculation formula is as follows:
[0024] ;
[0025] Among them, L represents the global loss, c(u,q,v) represents the reasonableness probability of the triplet (u,q,v), n represents the number of negative samples, i represents the i-th negative sample, the triplet (u,q,v) represents the positive sample, and the triplet (u i ',q,v i ') represents a negative sample, which is obtained by replacing the head entity or tail entity of the positive sample.
[0026] Furthermore, in S3, the paths to which the selected optimal neighbor nodes belong are scored according to the trained node priority function, and the calculation formula is as follows:
[0027] ;
[0028] Among them, sq (P) represents the score of path P, |P| represents the length of path P, t represents the time step, (x,r,y) represents a triple (x,r,y), x represents the head entity in the triple, S uq (t-1) Represents the normalization factor.
[0029] Furthermore, in S4, the relation embedding vectors of N important paths are input into the path text alignment adapter to obtain virtual path labels, and the calculation formula is as follows:
[0030] ;
[0031] Among them, Z(q,q -1 ) indicates a virtual path tag, f p represents the path text alignment adapter, q represents the relationship between the target head entity and the target tail entity, q -1 represents the inverse relationship between the target head entity and the target tail entity, q N Relation embedding vector representing important paths, Z u→v|q Represents a set of important paths.
[0032] Furthermore, in S5, the text description is input into the embedding layer of the large language model to obtain the embedding vector of the text, the virtual path tag and the embedding vector of the text are concatenated and input into the large language model together, and the output is whether the target triple is correct, including:
[0033] S51. Input the text description into the embedding layer of the large language model to obtain the embedding vector of the text:
[0034] ;
[0035] Among them, T e The embedding vector representing the text, represents the embedding layer in the large language model, j1, j2, ..., j m A sequence representing a text description;
[0036] S52: Splice the virtual path tag as a prefix to the front end of the text embedding vector, input the spliced vectors into the large language model, and output whether the target triple is correct:
[0037] ;
[0038] in, It represents the module after the embedding layer of the large language model. Outputs represents the output of the large language model, and the output content is whether the target triple is correct.
[0039] Furthermore, in S51, the text description is input into the embedding layer of the large language model, and further includes:
[0040] The text description is input into the embedding layer of the large language model in the format of a path-aware prompt template; wherein the text description includes a triple of instructions, paths, and targets, and the instructions are used to describe the tasks that the large language model needs to perform.
[0041] The present invention also provides a medical knowledge graph completion system based on a large language model, which is used to implement any of the above-mentioned medical knowledge graph completion methods based on a large language model, and the system includes:
[0042] A data acquisition module is used to acquire an initial medical knowledge graph; wherein the initial medical knowledge graph includes a number of triples, each of which includes a head entity, a relationship, and a tail entity;
[0043] A pre-training module, connected to the data acquisition module, is used to pre-train all paths of the target triplet using a path-based algorithm and a node priority function, screen out a preset number of optimal neighbor nodes of the target tail entity, and obtain the relationship embedding vector of the path to which the optimal neighbor node belongs, as well as the trained node priority function; wherein the path represents a sequence of relationships between the target head entity, the target tail entity, and other nodes;
[0044] The important path reasoning module is connected to the pre-training module and is used to score the paths to which the selected optimal neighbor nodes belong according to the trained node priority function, sort the path scores from large to small, and select the top N paths as important paths;
[0045] A mapping module, connected to the important path reasoning module, is used to input the relationship embedding vectors of N important paths into the path text alignment adapter to obtain virtual path labels;
[0046] The prediction module is connected to the mapping module and is used to input the text description into the embedding layer of the large language model to obtain the embedding vector of the text, concatenate the virtual path tag and the embedding vector of the text, and input them into the large language model together to output whether the target triple is correct;
[0047] The knowledge graph completion module is connected to the prediction module and is used to complete the initial medical knowledge graph according to the output result of the correct target triple to obtain the final medical knowledge graph.
[0048] The embodiments of the present invention have the following technical effects:
[0049] The present invention captures the path features between entities through self-supervised learning using a path-based algorithm and a node priority function. This method can select the most representative path from many paths and integrate it into a large language model. The path can provide explanation for inferring whether the target triple is reasonable. The path is equivalent to evidence supporting the prediction result, so that the structured information of the medical knowledge graph can be obtained, the interpretability of the medical knowledge graph is enhanced, the occurrence of hallucinations is reduced, and the large model is prevented from being unable to answer questions or answering answers that seem reasonable but are actually wrong. It optimizes the construction process of the medical knowledge graph and automatically completes the medical knowledge graph, thereby ensuring that the knowledge graph can better support medical decision-making and reasoning, improve the efficiency and accuracy of clinical practice, and thereby improve the reliability of decision-making based on the medical knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0051] Figure 1 It is a flowchart of a method for completing a medical knowledge graph based on a large language model provided by an embodiment of the present invention;
[0052] Figure 2 It is a logic diagram of a medical knowledge graph completion method based on a large language model provided by an embodiment of the present invention;
[0053] Figure 3 It is a structural diagram of a medical knowledge graph completion system based on a large language model provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.
[0055] First, the terms in this application are explained:
[0056] Knowledge graph: Knowledge graph is a technology used to represent and store structured knowledge. It consists of entities, relationships, and attributes, and describes the relationship between entities through the connection relationship between nodes and edges. Knowledge graph can help people better understand information, thereby improving the accuracy and efficiency of search and recommendation systems.
[0057] Knowledge graph embedding: Knowledge graph embedding is the process of mapping entities and relations in the knowledge graph to a low-dimensional continuous vector space. By learning these vector representations, the semantic relations and semantic similarities between entities can be captured. Knowledge graph embedding can be used for tasks such as knowledge graph reasoning and entity relationship classification.
[0058] Large language model: A large language model is a natural language processing model trained using large-scale text data, usually using a neural network to model the probability distribution of language. Large language models perform well in tasks such as text generation, translation, and question answering. For example, the recently successful GPT series of models are based on large language models.
[0059] Beam search: Beam search is a search algorithm used to select the most likely output in a sequence generated by a neural network. In beam search, the model retains the most likely candidates by setting a "beam width" based on the probability distribution generated at each time step. At the next time step, the algorithm generates a probability distribution again based on the current set of candidates and continues to retain the most likely options until the complete sequence is generated or the maximum number of steps set is reached. This can improve the quality and accuracy of the generated sequence and avoid falling into local optimal solutions.
[0060] This paper proposes a medical knowledge graph completion method based on a large language model. Figure 1 is a flowchart of a method for completing a medical knowledge graph based on a large language model provided by an embodiment of the present invention. Figure 2 is a logic diagram of a medical knowledge graph completion method based on a large language model provided by an embodiment of the present invention, see Figure 1 and Figure 2 , specifically including the following steps:
[0061] S1. Obtain the initial medical knowledge graph.
[0062] Among them, the initial medical knowledge graph contains several triples, and the triples include head entity, relationship, and tail entity.
[0063] S2. Pre-train all paths of the target triplet using a path-based algorithm and a node priority function, screen out a preset number of optimal neighbor nodes of the target tail entity, obtain the relational embedding vector of the path to which the optimal neighbor node belongs, and the trained node priority function.
[0064] Among them, the path represents a sequence of relationships between the target head entity, the target tail entity and other nodes; for example, Figure 2 Path 1 in: r3-r8-r 11 The path-based algorithm used in this embodiment is the A*Net algorithm.
[0065] S21. Use a path-based algorithm to pre-train all paths of the target triplet. The calculation formula is as follows:
[0066] ;
[0067] in, is a summation operation, is a matrix multiplication operation, h q (u,v) represents the embedding vector of the target head entity u and the target tail entity v under the target relation q, Z u→v represents the path set between the target head entity u and the target tail entity v, P represents any path in the path set, and w q (x, r, y) represents the embedding vector of a triple (x, r, y) under the target relation q.
[0068] Furthermore, since the number of paths is exponential, in order to solve this problem, this embodiment uses the A*Net algorithm to obtain the top N most important paths, and the above formula is expressed as:
[0069] ;
[0070] Among them, Z u→v|q It represents the set of paths from the target head entity u to the target tail entity v under the target relation q, that is, the set of important paths. This formula indicates that the sum of all paths from the target head entity u to the target tail entity v is approximately equal to the sum of the important paths from the target head entity u to the target tail entity v under the condition of the target relation q.
[0071] The above formula can be further expressed as:
[0072] ;
[0073] in, Represents an indicator function of a learnable parameter, t=0, which is 0 time step , specifically: That is, when hour, ,when hour, . represents the neighbor node set of node v at the current t step, represents the set of triples with node v as the tail entity. The first line of this formula represents the boundary conditions of the iteration, which is parameterized by the embedding vector of the target relation q, and the second line of the formula represents the process of iteration from the (t-1) time step to the tth time step.
[0074] S22. Use the node priority function to calculate the priority of the node, and select the optimal neighbor nodes of a preset number of target tail entities. The calculation formula is as follows:
[0075] ;
[0076] The formula for the iteration process from the (t-1) time step to the t time step can be restated as:
[0077] ;
[0078] Among them, s uq (t) is the node priority function, s uq (t) (x) represents the priority of entity x on the path from target head entity u to target relation q at time step t, and are two feedforward neural networks with different parameters, Represents the concatenation operation of two vectors, is the sigmoid function, h q (t) (u,x) represents the embedding vector of the head entity u and the tail entity x under the relation q at time step t; s uq (t-1) represents the node priority function at the (t-1) time step, represents the set of triples with node v as the tail entity, X (t) Represents the optimal neighbor node set obtained by the node priority function.
[0079] S23, the calculated relationship embedding vector of the path to which the optimal neighbor node belongs.
[0080] Furthermore, it is necessary to train the A*Net algorithm by minimizing a global loss. The calculation formula is as follows:
[0081] ;
[0082] Among them, L represents the global loss, c(u,q,v) represents the rationality probability of the triple (u,q,v), and c(u,q,v) can be calculated according to h q (u,v) is obtained by calculating the sigmoid function, n represents the number of negative samples, i represents the i-th negative sample, the triple (u,q,v) represents the positive sample, and the triple (ui ',q,v i ') represents a negative sample, which is obtained by replacing the head entity or tail entity of the positive sample.
[0083] S3. According to the trained node priority function, the paths to which the selected optimal neighbor nodes belong are scored, and the path scores are sorted from large to small, and the top N paths are selected as important paths.
[0084] Specifically, according to the trained node priority function, the path to which the selected optimal neighbor node belongs is scored, and the calculation formula is as follows:
[0085] ;
[0086] Among them, s q (P) represents the score of path P, |P| represents the length of path P, that is, the sum of the steps in the path, t represents the time step, (x, r, y) represents a triple (x, r, y), x represents the head entity in the triple, S uq (t-1) represents the normalization factor, i.e., the maximum value of the node priority among all possible entities x at the (t-1) time step. This value is used to normalize the priority score of each step.
[0087] in, , represents the maximum node score among all neighbor nodes of node x at the (t-1) time step.
[0088] For example, given a triple (u, q, v), the score of the path between u and v is obtained by the node priority function:
[0089] Suppose there is a path u—r1—w—r2—e—r3—v;
[0090] Path length |p|=3;
[0091] When t=1, calculate the neighbor node priority of node x at t=0. At this time, node x is node u, the denominator is the maximum neighbor node score of node x, and the numerator is the score of the next node w in the path. The numerator divided by the denominator is s1;
[0092] When t=2, calculate the neighbor node priority of node x at t=1. At this time, node x is node w, the denominator is the maximum neighbor node score of node w, and the numerator is the score of the next node e in the path of w. The numerator divided by the denominator is s2;
[0093] At t=3, calculate the neighbor node priority of node x at t=2. At this time, node x is node e, the denominator is the maximum neighbor node score of node e, and the numerator is the score of the next node v in the path. The numerator divided by the denominator is s3;
[0094] The score of this path is (s1+s2+s3) / |p|=(s1+s2+s3) / 3.
[0095] Furthermore, the path scores are used for sorting, and the higher the score, the more important it is. Sort the path scores from large to small, and select the top N paths as important paths. The important paths are obtained by performing a beam search on the priority function of each step. The beam search can set a hyperparameter, that is, a threshold for the number of paths, such as setting N=10 to obtain the 10 most important paths.
[0096] S4. Input the relation embedding vectors of N important paths into the path text alignment adapter to obtain virtual path labels.
[0097] Specifically, compared with the text tag representation space of the large language model, the embedding vector of the relationship and the embedding vector of the text are located in different representation spaces. In order to make up for this gap, a path text alignment adapter is used in this embodiment. The path text alignment adapter is composed of a linear layer and acts as a simple projection layer. After parameter optimization, the path text alignment adapter can learn the mapping from path information to text representation, so that the relationship embedding vectors of N important paths and the embedding vector of the text are mapped to the same representation space, and the relationship embedding vector in the same representation space as the embedding vector of the text is used as a virtual path marker.
[0098] Specifically, the relationship embedding vectors of N important paths are input into the path text alignment adapter to obtain the virtual path mark. The calculation formula is as follows:
[0099] ;
[0100] Among them, Z(q,q -1 ) indicates a virtual path tag, f p represents the path text alignment adapter, q represents the relationship between the target head entity and the target tail entity, q -1 represents the inverse relationship between the target head entity and the target tail entity, q N Relation embedding vector representing important paths, Z u→v|q Represents a set of important paths.
[0101] S5. Input the text description into the embedding layer of the large language model to obtain the embedding vector of the text, concatenate the virtual path tag and the embedding vector of the text, and input them into the large language model together, and output whether the target triple is correct.
[0102] S51. Input the text description into the embedding layer of the large language model to obtain the embedding vector of the text:
[0103] ;
[0104] Among them, T e The embedding vector representing the text, represents the embedding layer in the large language model, j1, j2, ..., j m Represents a sequence of text descriptions.
[0105] Furthermore, the text description is input into the embedding layer of the large language model in the format of the path-aware prompt template; wherein the text description includes a triplet of instructions, paths, and targets, and the instructions are used to describe the tasks that the large language model needs to perform. The path-aware prompt template is a text template, and the template contains three parts: instructions, related paths, and input triplet. The instructions describe the tasks that the large model needs to do, that is, judging whether the input triplet is correct. Since the large language model used has been trained with general instruction fine-tuning, the path-aware prompt template designed in this embodiment is consistent with its instruction fine-tuning template, which is conducive to enhancing the alignment effect and improving the accuracy of the large language model input.
[0106] S52: Splice the virtual path tag as a prefix to the front end of the text embedding vector, input the spliced vectors into the large language model, and output whether the target triple is correct:
[0107] ;
[0108] in, It represents the module after the embedding layer of the large language model. Outputs represents the output of the large language model, and the output content is whether the target triple is correct.
[0109] S6. Complete the initial medical knowledge graph based on the correct target triples outputted to obtain the final medical knowledge graph.
[0110] The present invention captures the path features between entities through self-supervised learning using a path-based algorithm and a node priority function. This method can select the most representative path from many paths and integrate it into a large language model. The path can provide explanation for inferring whether the target triple is reasonable. The path is equivalent to evidence supporting the prediction result, so that the structured information of the medical knowledge graph can be obtained, the interpretability of the medical knowledge graph is enhanced, the occurrence of hallucinations is reduced, and the large model is prevented from being unable to answer questions or answering answers that seem reasonable but are actually wrong. It optimizes the construction process of the medical knowledge graph and automatically completes the medical knowledge graph, thereby ensuring that the knowledge graph can better support medical decision-making and reasoning, improve the efficiency and accuracy of clinical practice, and thereby improve the reliability of decision-making based on the medical knowledge graph.
[0111] The embodiment of the present invention further provides a medical knowledge graph completion system based on a large language model, which is used to implement the medical knowledge graph completion method based on a large language model described in the above embodiment. Figure 3 is a schematic diagram of the structure of a medical knowledge graph completion system based on a large language model provided by an embodiment of the present invention, see Figure 3 , the system includes:
[0112] A data acquisition module is used to acquire an initial medical knowledge graph; wherein the initial medical knowledge graph includes a number of triples, each of which includes a head entity, a relationship, and a tail entity;
[0113] A pre-training module, connected to the data acquisition module, is used to pre-train all paths of the target triplet using a path-based algorithm and a node priority function, screen out a preset number of optimal neighbor nodes of the target tail entity, and obtain the relationship embedding vector of the path to which the optimal neighbor node belongs, as well as the trained node priority function; wherein the path represents a sequence of relationships between the target head entity, the target tail entity, and other nodes;
[0114] The important path reasoning module is connected to the pre-training module and is used to score the paths to which the selected optimal neighbor nodes belong according to the trained node priority function, sort the path scores from large to small, and select the top N paths as important paths;
[0115] A mapping module, connected to the important path reasoning module, is used to input the relationship embedding vectors of N important paths into the path text alignment adapter to obtain virtual path labels;
[0116] The prediction module is connected to the mapping module and is used to input the text description into the embedding layer of the large language model to obtain the embedding vector of the text, concatenate the virtual path tag and the embedding vector of the text, and input them into the large language model together to output whether the target triple is correct;
[0117] The knowledge graph completion module is connected to the prediction module and is used to complete the initial medical knowledge graph according to the output result of the correct target triple to obtain the final medical knowledge graph.
[0118] It should be noted that the terms used in the present invention are only for describing specific embodiments, rather than limiting the scope of the present application. As shown in the present specification, unless the context clearly indicates an exception, the words "one", "a", "a kind of" and / or "the" do not specifically refer to the singular, but may also include the plural. The terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method or device. In the absence of more restrictions, the elements defined by the sentence "include one..." do not exclude the presence of other identical elements in the process, method or device including the elements.
[0119] It should also be noted that the terms "center", "up", "down", "left", "right", "vertical", "horizontal", "inside", "outside", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. Unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", etc. should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0120] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the technical solutions of the embodiments of the present invention.
Claims
1. A method for completing a medical knowledge graph based on a large language model, characterized in that: The specific steps include: S1. Obtain an initial medical knowledge graph; wherein the initial medical knowledge graph includes a plurality of triples, each of which includes a head entity, a relationship, and a tail entity; S2. Pre-train all paths of the target triplet using a path-based algorithm and a node priority function, screen out a preset number of optimal neighbor nodes of the target tail entity, and obtain the relationship embedding vector of the path to which the optimal neighbor node belongs, as well as the trained node priority function; wherein the path represents a sequence of relationships between the target head entity, the target tail entity, and other nodes; Specifically include: S21. Use a path-based algorithm to pre-train all paths of the target triplet. The calculation formula is as follows: ; Among them, h q (u,v) represents the embedding vector of the target head entity u and the target tail entity v under the target relation q, Z u→v represents the path set between the target head entity u and the target tail entity v, P represents any path in the path set, and w q (x, r, y) represents the embedding vector of a triple (x, r, y) under the target relation q; S22. Calculate the priority of the node using the node priority function, and select the optimal neighbor nodes of a preset number of target tail entities. The calculation formula is as follows: ; ; Among them, s uq (t) is the node priority function, s uq (t) (x) represents the priority of entity x on the path from target head entity u to target relation q at time step t, and are two feedforward neural networks with different parameters, Represents the concatenation operation of two vectors, is the sigmoid function, h q (t) (u,x) represents the embedding vector of the head entity u and the tail entity x under the relation q at time step t; s uq (t-1) represents the node priority function at the (t-1) time step, represents the set of triples with node v as the tail entity, X (t) Represents the optimal neighbor node set obtained by the node priority function; S23, the calculated relationship embedding vector of the path to which the optimal neighbor node belongs; S3. According to the trained node priority function, the paths to which the selected optimal neighbor nodes belong are scored, and the path scores are sorted from large to small, and the top N paths are selected as important paths; S4, inputting the relation embedding vectors of the N important paths into the path text alignment adapter to obtain virtual path labels; The calculation formula is as follows: ; Among them, Z(q,q -1 ) indicates a virtual path tag, f p represents the path text alignment adapter, q represents the relationship between the target head entity and the target tail entity, q -1 represents the inverse relationship between the target head entity and the target tail entity, q N Relation embedding vector representing important paths, Z u→v|q represents the set of important paths; S5, inputting the text description into the embedding layer of the large language model to obtain an embedding vector of the text, concatenating the virtual path tag and the embedding vector of the text and inputting them into the large language model together, and outputting whether the target triple is correct; S6. Complete the initial medical knowledge graph according to the output result of the correct target triple to obtain the final medical knowledge graph.
2. According to claim 1, a method for completing a medical knowledge graph based on a large language model is characterized in that: In S2, it is also necessary to train the path-based algorithm by minimizing a global loss, and the calculation formula is as follows: ; Among them, L represents the global loss, c(u,q,v) represents the reasonableness probability of the triplet (u,q,v), n represents the number of negative samples, i represents the i-th negative sample, the triplet (u,q,v) represents the positive sample, and the triplet (u i ',q,v i ') represents a negative sample, which is obtained by replacing the head entity or tail entity of the positive sample.
3. According to claim 2, a method for completing a medical knowledge graph based on a large language model is characterized in that: In S3, the paths to which the selected optimal neighbor nodes belong are scored according to the trained node priority function, and the calculation formula is as follows: ; Among them, s q (P) represents the score of path P, |P| represents the length of path P, t represents the time step, (x,r,y) represents a triple (x,r,y), x represents the head entity in the triple, S uq (t-1) Represents the normalization factor.
4. According to claim 3, a method for completing a medical knowledge graph based on a large language model is characterized in that: In S5, the text description is input into the embedding layer of the large language model to obtain the embedding vector of the text, the virtual path mark and the embedding vector of the text are concatenated and input into the large language model together, and whether the target triple is correct is output, including: S51. Input the text description into the embedding layer of the large language model to obtain the embedding vector of the text: ; Among them, T e The embedding vector representing the text, represents the embedding layer in the large language model, j1, j2, ..., j m A sequence representing a text description; S52: splice the virtual path mark as a prefix to the front end of the embedding vector of the text, input the spliced vectors into the large language model, and output whether the target triple is correct: ; in, It represents the module after the embedding layer of the large language model. Outputs represents the output of the large language model, and the output content is whether the target triple is correct.
5. According to claim 4, a method for completing a medical knowledge graph based on a large language model is characterized in that: In the step S51, the text description is input into the embedding layer of the large language model, and further includes: The text description is input into the embedding layer of the large language model in the format of a path-aware prompt template; wherein the text description includes a triple of instructions, paths, and targets, and the instructions are used to describe the tasks that the large language model needs to perform.
6. A medical knowledge graph completion system based on a large language model, used to implement a medical knowledge graph completion method based on a large language model as described in any one of claims 1 to 5, characterized in that: The system includes: A data acquisition module, used to acquire an initial medical knowledge graph; wherein the initial medical knowledge graph includes a plurality of triples, each of which includes a head entity, a relationship, and a tail entity; A pre-training module, connected to the data acquisition module, is used to pre-train all paths of the target triplet using a path-based algorithm and a node priority function, screen out a preset number of optimal neighbor nodes of the target tail entity, and obtain the relationship embedding vector of the path to which the optimal neighbor node belongs, as well as the trained node priority function; wherein the path represents a sequence of relationships between the target head entity, the target tail entity, and other nodes; Specifically, the path-based algorithm is used to pre-train all paths of the target triplet. The calculation formula is as follows: ; Among them, h q (u,v) represents the embedding vector of the target head entity u and the target tail entity v under the target relation q, Z u→v represents the path set between the target head entity u and the target tail entity v, P represents any path in the path set, and w q (x, r, y) represents the embedding vector of a triple (x, r, y) under the target relation q; The node priority function is used to calculate the priority of the node and filter out the optimal neighbor nodes of the preset number of target tail entities. The calculation formula is as follows: ; ; Among them, s uq (t) is the node priority function, s uq (t) (x) represents the priority of entity x on the path from target head entity u to target relation q at time step t, and are two feedforward neural networks with different parameters, Represents the concatenation operation of two vectors, is the sigmoid function, h q (t) (u,x) represents the embedding vector of the head entity u and the tail entity x under the relation q at time step t; s uq (t-1) represents the node priority function at the (t-1) time step, represents the set of triples with node v as the tail entity, X (t) Represents the optimal neighbor node set obtained by the node priority function; The calculated relationship embedding vector of the path to which the optimal neighbor node belongs; An important path reasoning module is connected to the pre-training module and is used to score the paths to which the selected optimal neighbor nodes belong according to the trained node priority function, sort the path scores from large to small, and select the top N paths as important paths; A mapping module, connected to the important path reasoning module, is used to input the relationship embedding vectors of N important paths into a path text alignment adapter to obtain a virtual path label; The calculation formula is as follows: ; Among them, Z(q,q -1 ) indicates a virtual path tag, f p represents the path text alignment adapter, q represents the relationship between the target head entity and the target tail entity, q -1 represents the inverse relationship between the target head entity and the target tail entity, q N Relation embedding vector representing important paths, Z u→v|q represents the set of important paths; A prediction module, connected to the mapping module, for inputting the text description into the embedding layer of the large language model to obtain an embedding vector of the text, concatenating the virtual path tag and the embedding vector of the text and inputting them into the large language model together, and outputting whether the target triple is correct; The knowledge graph completion module is connected to the prediction module and is used to complete the initial medical knowledge graph according to the output result of the correct target triple.
Citation Information
Patent Citations
Multi-layer gradually-enhanced geological disaster knowledge graph and automatic completion method of multi-layer gradually-enhanced geological disaster knowledge graph
CN111639196A
Reinforcement learning-based affair graph completion method and related equipment thereof
CN114238656A