A method, medium and device for identifying the temporal relationship of clinical events

Through the medical knowledge graph and graph attention mechanism, combined with the multi-head attention mechanism, the characteristics of clinical events are automatically learned, and the complexity of clinical event timing relationship identification and long text processing problems in the existing technology are solved, achieving efficient timing relationship identification.

CN118898289BActive Publication Date: 2024-12-06CENT SOUTH UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411396668.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2024-12-06
Estimated Expiration
2044-10-09

AI Technical Summary

Technical Problem

The existing clinical event timing relationship recognition methods are complex and cannot be applied to long texts, making it difficult to effectively deal with complex timing relationships in clinical medical texts.

Method used

Using graph attention mechanism and multi-head attention mechanism based on medical knowledge graphs, identify medical entities through context coding models, generate standardized entity subgraphs, calculate comprehensive feature vectors of clinical events, and use CoT prompt learning to perform small samples on BioBERT model. Learn, identify timing relationships.

Benefits of technology

It improves the efficiency and accuracy of clinical event timing relationship recognition, can apply long text, reduces the need for artificial feature engineering, and enhances the performance of the model in complex data processing and the understanding of common sense knowledge in the field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118898289B_ABST
    Figure CN118898289B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of clinical medical text recognition, and to a method, medium and device for identifying the temporal relationship of clinical events. The identification method includes: obtaining two clinical events and their corresponding original clinical texts; identifying the medical entities in the two clinical events; generating a standardized entity subgraph based on a medical knowledge graph search; performing feature encoding on the two standardized entity nodes based on a graph attention mechanism to obtain a comprehensive feature vector of a clinical event pair; calculating the attention weights of each sentence in the original clinical text of the two clinical event pairs; selecting M sentences with the highest attention weights for reorganization to obtain a text fragment; performing few-sample learning based on CoT prompt learning to obtain a temporal relationship model that can output the temporal relationship between the two clinical events. The present invention improves the recognition efficiency of the temporal relationship and the accuracy when processing complex data, is suitable for the recognition of long texts, and adopts a CoT prompt learning method to fully stimulate the reasoning ability of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of clinical medical text recognition, and in particular to a method, medium and device for recognizing the temporal relationship of clinical events. Background Art

[0002] With the rapid development of electronic medical record systems, a large amount of clinical medical record data is stored in various medical systems. However, most of this data exists in the form of document-level unstructured text, which poses a huge challenge to identifying the temporal relationship of clinical events from the text. By effectively constructing the patient's timeline, we can better understand the patient's condition changes and treatment methods, thereby improving the quality of medical services and the patient's treatment effect. Clinical medical texts are highly specialized and contain a large number of complex medical terms and proper nouns, making semantic understanding and information extraction extremely difficult. In addition, there are often complex relationships between clinical events, and fine-grained extraction of the temporal relationship between these events further increases the complexity of the task.

[0003] The construction of the timeline of clinical events is an important part of clinical medical analysis. The methods of temporal relationship extraction have been evolving with the development of computer technology, from early rule-based methods to today's deep neural network-based methods.

[0004] In the early methods, researchers used manually defined rules and pattern matching techniques to apply predefined rules (such as keywords representing time) to clinical texts to identify sentences or phrases that match these patterns. And use feature engineering to extract features related to time relationships (such as time expression, event type, etc.) to improve the accuracy and coverage of rules. Other researchers have tried to use traditional machine learning methods, such as support vector machines (SVM), maximum entropy models (MaxEnt), conditional random fields (CRF), and random forests. These traditional machine learning methods are all based on feature engineering. The model trained by the SVM classifier classifies the temporal relationship between events based on the extracted features; MaxEnt uses the maximum entropy model to estimate the conditional probability of each category for prediction; CRF considers both contextual information and dependencies for sequence labeling; and the random forest model classifies temporal relationships through voting of multiple decision trees. The latest methods use complex deep neural network-based models, such as BERT, Transformer, graph neural networks (GNN), etc. These models can automatically learn features, reduce the need for manual feature engineering, and can capture complex semantic relationships and long-distance dependencies. The above methods are relatively complex, have a large demand for training data and computing power, and cannot adapt to the processing of long texts.

[0005] Therefore, it is necessary to provide a new method, medium and device for identifying the temporal relationship of clinical events to solve the above technical problems. Summary of the invention

[0006] The main purpose of the present invention is to provide a method, medium and device for identifying the temporal relationship of clinical events, aiming to solve the problem that the existing identification methods are relatively complex and cannot be applied to long texts.

[0007] To achieve the above-mentioned purpose, the present invention proposes a method for identifying the temporal relationship of clinical events, comprising:

[0008] S1: Obtain two clinical events and their corresponding original clinical texts; input the two clinical events into the context encoding model to identify the medical entities in the two clinical events;

[0009] S2: Generate a standardized entity subgraph related to medical entities based on medical knowledge graph search, where: the standardized entity subgraph includes nodes and relationships between nodes, and the nodes include two standardized entity nodes corresponding to two medical entities, intermediate nodes on the path between the two standardized entity nodes, and neighbor nodes of the standardized entity nodes and the intermediate nodes;

[0010] S3: Based on the graph attention mechanism, feature encoding is performed on two standardized entity nodes to generate the final feature vectors of two clinical events respectively, and the final feature vectors of the two clinical events are concatenated to obtain the comprehensive feature vector of the clinical event pair;

[0011] S4: Calculate the attention weights of the two clinical events on each sentence in the original clinical text, specifically:

[0012] S4.1. Encode the original clinical text using the context encoding model to obtain the embedding vector of each sentence in the original clinical text;

[0013] S4.2, based on the multi-head attention mechanism, the attention weights of the clinical event pairs on each sentence in the original clinical text are calculated according to the comprehensive feature vector of the clinical event pairs and the embedding vectors of each sentence;

[0014] S5: Select the M sentences with the highest attention weights, and reorganize the selected M sentences according to the order of appearance in the original clinical text to obtain text fragments;

[0015] S6: Based on CoT-prompted learning, few-shot learning is performed on the BioBERT model to obtain a temporal relationship model that can output the temporal relationship between two clinical events in the original clinical text.

[0016] Optionally, the S3 includes:

[0017] S3.1. Use the BioBERT model to generate the initial feature vectors of each node in the standardized entity subgraph ;

[0018] S3.2, based on the graph attention mechanism, calculate the attention coefficients between two standardized entity nodes and their neighbor nodes respectively;

[0019] S3.3, normalizing the attention coefficients obtained in S3.2 to obtain normalized attention coefficients;

[0020] S3.4. According to the normalized attention coefficient, weighted aggregation is performed on the information of the neighbor nodes of the two standardized entity nodes to obtain the neighbor aggregation vectors of the two standardized entity nodes respectively;

[0021] S3.5, aggregate the information of all intermediate nodes between two standardized entity nodes to obtain a path feature vector connecting the two standardized entity nodes;

[0022] S3.6. Based on the path feature vector and the neighbor aggregation vector of the two standardized entity nodes, the final feature vectors of the two standardized entity nodes are generated respectively, and the final feature vectors of the two clinical events are concatenated to obtain the comprehensive feature vector of the clinical event pair.

[0023] Optionally, in S3.2, the calculation formula of the attention coefficient is as follows:

[0024] ;

[0025] in: is the number of the current layer; is the first Standardized entity nodes of layers Its neighbor nodes The attention coefficient between is the number of the standardized entity node, which takes the value 1 or 2; Standardized entity node Neighbor node number of is the activation function; is the first The weight vector of the layer, Transpose it; is the first The weight matrix of the layer; and They represent the first Standardized entity nodes of layers The initial eigenvector and its neighbor nodes The initial eigenvector of Represents vector concatenation;

[0026] In S3.3, the calculation formula of the normalized attention coefficient is as follows:

[0027] ;

[0028] in: is the normalized attention coefficient; Standardized entity node The set of neighbor node numbers of express A neighbor node number in ; Is a standardized entity node and neighbor nodes The unnormalized attention coefficient between Standardized entity node and a neighbor node The unnormalized attention coefficient between ;

[0029] In S3.4, the calculation formula of the neighbor aggregation vector is as follows:

[0030] ;

[0031] in: Standardized entity node In the graph attention mechanism The neighbor aggregation vector of the layer, is a nonlinear activation function; Neighbor node In the graph attention mechanism The feature vector of the layer;

[0032] In S3.5, the calculation formula of the path characteristic vector is as follows:

[0033] ;

[0034] in: is the path feature vector between two standardized entity nodes; is the number of the intermediate node, The first The feature vector of the intermediate nodes, are the total number of two normalized entity nodes and intermediate nodes;

[0035] In S3.6, the calculation formula of the final eigenvector is as follows:

[0036] ;

[0037] in: Standardized entity node The final eigenvector of ;

[0038] The calculation formula of the comprehensive feature vector of clinical event pairs is as follows:

[0039] ;

[0040] in: is the comprehensive feature vector of clinical event pairs; Standardized entity node The final eigenvector of Standardized entity node The final feature vector of .

[0041] Optionally, the S4.2 includes:

[0042] S4.2.1. Linearly transform the comprehensive feature vector of the clinical event pair and the embedding vector of each sentence to obtain a linearly transformed comprehensive feature vector and a linearly transformed embedding vector;

[0043] S4.2.2, based on the multi-head attention mechanism, the attention scores of different attention heads of the clinical event pairs on each sentence are calculated according to the linearly transformed comprehensive feature vector and the linearly transformed embedding vector;

[0044] S4.2.3. In each attention head, the attention score of each sentence is normalized to obtain the normalized weight, and the final attention weight of the clinical event pair on each sentence is calculated based on the normalized weight.

[0045] Optionally, in S4.2.1, the calculation formula of the linear transformation is as follows:

[0046] ;

[0047] ;

[0048] in: Number the sentences. For the The embedding vector of each sentence; Represents the head number in the multi-head attention mechanism; For the The feature representation of clinical event pairs after linear transformation in each head, For the After linear transformation in the The embedding vector of each sentence; and They are used for and The weight matrix of the graph attention mechanism;

[0049] In S4.2.2, the calculation formula of the attention score is as follows:

[0050] ;

[0051] in: For clinical events in The first sentence The attention score of each attention head; for Dimensions; is transposed;

[0052] In S4.2.3, the calculation formula of the normalized weight is as follows:

[0053] ;

[0054] in: is the normalized weight, The function is used to normalize the attention scores into a probability distribution;

[0055] The calculation formula for the final attention weight is as follows:

[0056] ;

[0057] in: For clinical events in The final attention weight of the sentence; is the total number of attention heads.

[0058] Optionally, S6 includes:

[0059] S6.1. Use the OpenPrompt tool to create a prompt template, which includes: a text-encoded context fragment, a question asking about the temporal relationship between two clinical events, and a candidate set of temporal relationship types;

[0060] S6.2. Generate training samples and test samples based on the prompt template. In the training samples, the medical causal relationship between two clinical events is first answered, and then the temporal relationship between the two clinical events is judged based on the causal relationship and the context information of the text fragment; the test samples include the text-encoded context fragment, the question asking about the temporal relationship between the two clinical events, and the candidate set of the temporal relationship type;

[0061] S6.3. Use the training samples to train the BioBERT model to obtain a temporal relationship model that can output the temporal relationship between two clinical events in the original clinical text; and use the test samples to test and evaluate the temporal relationship model;

[0062] S6.4. The text fragments obtained in S5 are used to form a prompt template and input into the temporal relationship model. The temporal relationship model will first determine the medical causal relationship between the two clinical events, and then combine the context information of the text fragments in the prompt template to identify the temporal relationship between the two clinical events.

[0063] Optionally, in S6.1, medical causal relationships include causal relationships, conditional relationships, and hierarchical relationships; the two clinical events are clinical event A and clinical event B; the candidate set of temporal relationship types includes SIMULTANEOUS, OVERLAP, BEFORE, AFTER, and UNKNOWN, where: SIMULTANEOUS means simultaneous, OVERLAP means partial overlap, BEFORE means clinical event A is before clinical event B, AFTER means clinical event A is after clinical event B, and UNKNOWN means unknown.

[0064] Optionally, in S1, clinical events are medical events related to patients that occur during the medical process, and medical entities include disease names, drug names, symptom names, examination item names, food names, and department names.

[0065] In addition, the present invention also provides a computer-readable storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, the method for identifying the temporal relationship of clinical events as described above is implemented.

[0066] The present invention also provides an electronic device, comprising: at least one processor, at least one memory and computer program instructions stored in the memory, when the computer program instructions are executed by the processor, the method for identifying the temporal relationship of clinical events as described above is performed.

[0067] In the technical solution of the present invention, a standardized entity subgraph related to the medical entity determined in the original clinical text is generated based on the medical knowledge graph search, and then the standardized entity nodes are feature encoded based on the graph attention mechanism to obtain the comprehensive feature vector of the two clinical events, and the attention weight of the clinical event pair to each sentence is calculated based on the multi-head attention mechanism, and then the text fragment consisting of the M sentences with the highest attention weight constitutes a prompt template for CoT prompt learning, and then a small number of training samples are generated to train the BioBERT model. The trained model imitates the reasoning steps of the training sample to output the temporal relationship between the two clinical events. Based on the BioBERT model, the present invention uses the graph attention mechanism and the multi-head attention mechanism to automatically learn the features of text and events, reduces the steps of feature extraction that rely on manually defined rules, not only improves efficiency, but also enhances the accuracy when processing complex data, and combines the medical knowledge graph and entity embedding technology to capture and analyze the global relationship between entities within the entire document range, which can be applied to the recognition of long texts, and the medical terms and relationships provided by the knowledge graph further enhance the ability of the model to process common sense knowledge in the field, and the use of the CoT prompt learning method can effectively guide the model to perform logical reasoning and temporal relationship judgment, and fully stimulate the reasoning ability of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.

[0069] Figure 1 Schematic diagram of the process of the method for identifying the temporal relationship of clinical events in an embodiment of the present invention;

[0070] Figure 2 A schematic diagram of a technical route of a method for identifying a temporal relationship of clinical events in an embodiment of the present invention;

[0071] Figure 3 It is a standardized entity subgraph in the embodiment of the present invention.

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

[0073] The embodiments of the present invention are described in detail below with reference to the accompanying drawings. However, the present invention can be implemented in many different ways that are defined and covered.

[0074] The present invention proposes a method, medium and device for identifying the temporal relationship of clinical events, aiming to solve the problem that the existing identification methods are relatively complex and cannot be applied to long texts. Example 1

[0075] like Figure 1 and Figure 2 As shown, the method for identifying the temporal relationship of clinical events includes:

[0076] S1: Obtain two clinical events and their corresponding original clinical texts; input the two clinical events into the context encoding model to identify the medical entities in the two clinical events;

[0077] In S1, clinical events are medical events related to patients that occur during the medical process. Medical entities include disease names, drug names, symptom names, examination item names, food names, and department names. The context encoding model uses the BioBERT model.

[0078] S2: Generate a standardized entity subgraph related to medical entities based on medical knowledge graph search, where: the standardized entity subgraph includes nodes and relationships between nodes, and the nodes include two standardized entity nodes corresponding to two medical entities, intermediate nodes on the path between the two standardized entity nodes, and neighbor nodes of the standardized entity nodes and the intermediate nodes;

[0079] Specifically, through fuzzy matching and semantic similarity query, the corresponding standardized entity node is found in the medical knowledge graph such as UMLS. In this embodiment, for the entity "diabetes", its corresponding concept "diabetesmellitus" is found in UMLS. The standardized entity subgraph generated in S2 is as follows: Figure 3 As shown, to The nodes in the standardized entity subgraph are used. Fuzzy matching and similarity detection techniques are combined with the powerful text processing capabilities of the BioBERT model to effectively understand and distinguish ambiguity and co-reference in the text. This method improves the model's ability to parse text semantics, allowing the subtle differences and deep meanings in the text to be accurately identified. In addition, the UMLS knowledge graph and entity embedding technology are combined to capture and analyze the global relationship between entities across the entire document. The medical terms and relationships provided by the knowledge graph further enhance the model's ability to process common sense knowledge in the field.

[0080] S3: Based on the graph attention mechanism, feature encoding is performed on two standardized entity nodes to generate the final feature vectors of two clinical events respectively, and the final feature vectors of the two clinical events are concatenated to obtain the comprehensive feature vector of the clinical event pair;

[0081] S3 includes:

[0082] S3.1. Use the BioBERT model to generate the initial feature vectors of each node in the standardized entity subgraph ;

[0083] S3.2, based on the graph attention mechanism, calculate the attention coefficients between two standardized entity nodes and their neighbor nodes respectively;

[0084] In S3.2, the calculation formula of the attention coefficient is as follows:

[0085] ;

[0086] in: is the number of the current layer, usually starting from 0 and increasing during each layer iteration; is the first Standardized entity nodes of layers Its neighbor nodes The attention coefficient between is the number of the standardized entity node, which takes the value 1 or 2; Standardized entity node Neighbor node number of is an activation function used to prevent the gradient disappearance problem; is the first The weight vector of the layer, used to calculate the attention coefficient between nodes; Transpose it; is the first The weight matrix of the layer is used for linear transformation of node features; and They represent the first Standardized entity nodes of layers The initial eigenvector and its neighbor nodes The initial eigenvector of Represents vector concatenation;

[0087] S3.3, normalizing the attention coefficients obtained in S3.2 to obtain normalized attention coefficients;

[0088] In S3.3, the calculation formula of the normalized attention coefficient is as follows:

[0089] ;

[0090] in: is the normalized attention coefficient; Standardized entity node The set of neighbor node numbers of express A neighbor node number in ; Is a standardized entity node and neighbor nodes The unnormalized attention coefficient between Standardized entity node and a neighbor node The unnormalized attention coefficient between ; Standardized entity node The set of neighbor nodes; The natural constant An exponential function with base ; in this embodiment, Figure 3 As shown, The neighbor nodes of ,Right now ; The neighbor nodes of ,Right now ;

[0091] S3.4. According to the normalized attention coefficient, weighted aggregation is performed on the information of the neighbor nodes of the two standardized entity nodes to obtain the neighbor aggregation vectors of the two standardized entity nodes respectively;

[0092] In S3.4, the calculation formula of the neighbor aggregation vector is as follows:

[0093] ;

[0094] in: Standardized entity node In the graph attention mechanism The neighbor aggregation vector of the layer, is a nonlinear activation function; Neighbor node In the graph attention mechanism The feature vector of the layer;

[0095] S3.5. Aggregate the information of all intermediate nodes between two standardized entity nodes to obtain a path feature vector connecting the two standardized entity nodes.

[0096] In S3.5, the calculation formula of the path characteristic vector is as follows:

[0097] ;

[0098] in: is the path feature vector between two standardized entity nodes; is the number of the intermediate node, The first The feature vector of the intermediate nodes, are the total number of two normalized entity nodes and intermediate nodes;

[0099] S3.6. Based on the path feature vector and the neighbor aggregation vector of the two standardized entity nodes, the final feature vectors of the two standardized entity nodes are generated respectively, and the final feature vectors of the two clinical events are concatenated to obtain the comprehensive feature vector of the clinical event pair.

[0100] In S3.6, the calculation formula of the final eigenvector is as follows:

[0101] ;

[0102] in: Standardized entity node The final eigenvector of ;

[0103] The calculation formula of the comprehensive feature vector of clinical event pairs is as follows:

[0104] ;

[0105] in: is the comprehensive feature vector of clinical event pairs; Standardized entity node The final eigenvector of Standardized entity node The final feature vector of .

[0106] S4: Calculate the attention weights of the two clinical events on each sentence in the original clinical text, specifically:

[0107] S4.1. Encode the original clinical text using the context encoding model to obtain the embedding vector of each sentence in the original clinical text;

[0108] S4.2, based on the multi-head attention mechanism, the attention weights of the clinical event pairs on each sentence in the original clinical text are calculated according to the comprehensive feature vector of the clinical event pairs and the embedding vectors of each sentence;

[0109] By using a multi-head attention mechanism and focusing on different levels of text representation space in the text, we can capture contextual semantics at the document level, sentence level, and token level. This mechanism effectively captures long-distance contextual semantics and improves the performance of the model in understanding and analyzing complex document structures. GAT is used to process the complex relationships between nodes in the knowledge graph, and the multi-head attention mechanism is combined to process semantic expressions at different levels, achieving more fine-grained temporal relationship extraction. This in-depth node analysis and hierarchical processing strategy ensures the accuracy and meticulousness of the model in extracting temporal relationships.

[0110] S4.2 includes:

[0111] S4.2.1. Linearly transform the comprehensive feature vector of the clinical event pair and the embedding vector of each sentence to obtain a linearly transformed comprehensive feature vector and a linearly transformed embedding vector;

[0112] In S4.2.1, the calculation formula for the linear transformation is as follows:

[0113] ;

[0114] ;

[0115] in: Number the sentences. For the The embedding vector of each sentence; Represents the head number in the multi-head attention mechanism; For the The feature representation of clinical event pairs after linear transformation in each head, For the After linear transformation in the The embedding vector of each sentence; and They are used for and The weight matrix of the graph attention mechanism;

[0116] S4.2.2, based on the multi-head attention mechanism, the attention scores of different attention heads of the clinical event pairs on each sentence are calculated according to the linearly transformed comprehensive feature vector and the linearly transformed embedding vector;

[0117] In S4.2.2, the calculation formula of attention score is as follows:

[0118] ;

[0119] in: For clinical events in The first sentence The attention score of each attention head; for Dimensions; is transposed;

[0120] S4.2.3. In each attention head, the attention score of each sentence is normalized to obtain the normalized weight, and the final attention weight of the clinical event pair on each sentence is calculated based on the normalized weight.

[0121] In S4.2.3, the calculation formula for normalized weight is as follows:

[0122] ;

[0123] in: is the normalized weight, The function is used to normalize the attention score into a probability distribution to ensure that the weight sums to 1;

[0124] The calculation formula for the final attention weight is as follows:

[0125] ;

[0126] in: For clinical events in The final attention weight on the sentence; is the total number of attention heads.

[0127] S5: Select the M sentences with the highest attention weights, and reorganize the selected M sentences according to the order of appearance in the original clinical text to obtain text fragments; the text fragments include: sentences ,sentence ,...,sentence .

[0128] In S1 to S5, medical knowledge graphs (such as UMLS) integrate multiple medical vocabularies and taxonomies, providing rich medical concepts and relationship information. Introducing medical knowledge graphs as external knowledge helps to standardize medical terms in clinical texts, thereby better resolving semantic ambiguity and co-reference problems. In terms of attention mechanisms, graph attention mechanisms (GAT) and multi-head attention mechanisms are used. The graph attention mechanism introduces the attention mechanism into graph neural networks, assigns different weights to different neighbor nodes, and generates more accurate node embedding representations. The multi-head attention mechanism can capture semantic information at different levels in the text, thereby improving the model's contextual understanding ability, providing more sophisticated and comprehensive information processing capabilities for the task of extracting temporal relationships between clinical events, and significantly improving the accuracy of predictions and the robustness of the model.

[0129] S6: Based on the CoT prompt learning, the BioBERT model is trained to obtain the trained BioBERT model, and the text fragment is input into the trained BioBERT model to output the temporal relationship between the two clinical events.

[0130] S6 includes:

[0131] S6.1. Use the OpenPrompt tool to create a prompt template, which includes: a text-encoded context fragment, a question asking about the temporal relationship between two clinical events, and a candidate set of temporal relationship types;

[0132] In S6.1, medical causal relationships include causal relationships, conditional relationships, and hierarchical relationships; the two clinical events are clinical event A and clinical event B; the candidate set of temporal relationship types includes SIMULTANEOUS, OVERLAP, BEFORE, AFTER, and UNKNOWN, where: SIMULTANEOUS means simultaneous, OVERLAP means partial overlap, BEFORE means clinical event A is before clinical event B, AFTER means clinical event A is after clinical event B, and UNKNOWN means unknown.

[0133] Among them, causal relationship refers to a certain cause leading to a certain result. For example, in "the gastrointestinal dysfunction of the human body leads to the patient's poor absorption capacity", "gastrointestinal dysfunction" is a direct cause of "poor absorption capacity", and "poor absorption capacity" is the direct result of "gastrointestinal dysfunction". Conditional relationship generally supplements and modifies causal relationship. For example, "patients who are allergic to amoxicillin cannot use it, otherwise it may cause allergic reactions such as rash, drug fever and asthma. Therefore, penicillin skin test must be done before use." In "amoxicillin allergy" is the condition for "taking amoxicillin" to cause "allergic reaction". Hyponym relationship refers to the relationship between medical concepts. For example, in "Alzheimer's disease is a mental illness and is more common in life", "Alzheimer's disease" and "mental illness" constitute a hyponym relationship. The medical causal relationship part focuses on showing the causal, conditional, and purpose relationships between events to help the model understand the direct temporal dynamics between events. The semantic relationship part supplements the understanding of events in specific contexts by explaining the context or related attributes of the event. CoT-prompted learning simulates the reasoning process of domain experts, enabling the model to learn and adapt quickly even with a small number of samples. It also improves the model's self-explanatory ability and transparency, and enhances trust and verifiability in the model's prediction results.

[0134] S6.2. Generate training samples and test samples based on the prompt template. In the training samples, the medical causal relationship between two clinical events is first answered, and then the temporal relationship between the two clinical events is judged based on the causal relationship and the context information of the text fragment; the test samples include the text-encoded context fragment, the question asking about the temporal relationship between the two clinical events, and the candidate set of the temporal relationship type; Figure 2 As shown, Q represents the question asked and A represents the answer.

[0135] In S6.2, the reliance on large amounts of labeled data is reduced by leveraging the pre-trained BioBERT and CoT hint learning mechanisms. This strategy significantly improves the model’s adaptability and performance under data-scarce conditions by guiding the model to learn effectively with a small amount of hints.

[0136] S6.3. Use the training samples to train the BioBERT model to obtain a temporal relationship model that can output the temporal relationship between two clinical events in the original clinical text; and use the test samples to test and evaluate the temporal relationship model.

[0137] S6.4. The text fragments obtained in S5 are used to form a prompt template and input into the temporal relationship model. The temporal relationship model will first determine the medical causal relationship between the two clinical events, and then combine the context information of the text fragments in the prompt template to identify the temporal relationship between the two clinical events.

[0138] As a pre-trained model, the BioBERT model has proven to have excellent performance in processing medical texts in various formats. Combined with the CoT prompt learning mechanism, the trained BioBERT model not only relies on contextual information, but also exerts its inherent reasoning ability to adapt to different downstream tasks. This combination of flexibility and generalization is more powerful and practical in diverse practical application scenarios. In addition, the trained BioBERT adopts CoT prompt learning to move in the correct reasoning direction by generating internal explanations or "thinking paths". This approach not only improves the transparency and self-explanatory ability of the model, but also enhances the trust and acceptance of model decisions by medical professionals.

[0139] In S6, CoT prompt learning decomposes complex tasks into multiple steps and gradually reasoning to reach the final conclusion. This prompt learning method can effectively guide the model to perform logical reasoning and temporal relationship judgment, and fully stimulate the reasoning ability of the pre-trained model. OpenPrompt is an open source tool for template generation and prompt design. Its flexibility and ease of use can help quickly generate appropriate prompt templates and guide the model to judge temporal relationships.

[0140] The present invention automatically learns the features of texts and events through the BioBERT model as well as the graph attention mechanism and the multi-head attention mechanism, reducing the steps of feature extraction that rely on manually defined rules. It not only improves efficiency but also enhances the accuracy when processing complex data. It also combines medical knowledge graphs and entity embedding technology to capture and analyze the global relationships between entities throughout the entire document, and can be applied to the recognition of long texts. The medical terms and relationships provided by the knowledge graph further enhance the model's ability to process common sense knowledge in the field. Example 2

[0141] This embodiment provides a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the method for identifying the temporal relationship of clinical events as described above is implemented. Example 3

[0142] This embodiment provides an electronic device including: at least one processor, at least one memory, and computer program instructions stored in the memory. When the computer program instructions are executed by the processor, the method for identifying the temporal relationship of clinical events as described above is provided.

[0143] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the inventive concept of the present invention, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present invention.

Claims

1. A method for identifying the temporal relationship of clinical events, It is characterized in that The method for identifying the temporal relationship of clinical events comprises: S1: Obtain two clinical events and their corresponding original clinical texts; input the two clinical events into the context encoding model to identify the medical entities in the two clinical events; S2: Generate a standardized entity subgraph related to medical entities based on medical knowledge graph search, where: the standardized entity subgraph includes nodes and relationships between nodes, and the nodes include two standardized entity nodes corresponding to two medical entities, intermediate nodes on the path between the two standardized entity nodes, and neighbor nodes of the standardized entity nodes and the intermediate nodes; S3: Based on the graph attention mechanism, feature encoding is performed on two standardized entity nodes to generate the final feature vectors of two clinical events respectively, and the final feature vectors of the two clinical events are concatenated to obtain the comprehensive feature vector of the clinical event pair; S4: Calculate the attention weights of the two clinical events on each sentence in the original clinical text, specifically: S4.

1. Encode the original clinical text using the context encoding model to obtain the embedding vector of each sentence in the original clinical text; S4.2, based on the multi-head attention mechanism, the attention weights of the clinical event pairs on each sentence in the original clinical text are calculated according to the comprehensive feature vector of the clinical event pairs and the embedding vectors of each sentence; S5: Select the M sentences with the highest attention weights, and reorganize the selected M sentences according to the order of appearance in the original clinical text to obtain text fragments; S6: Based on CoT-prompted learning, few-shot learning is performed on the BioBERT model to obtain a temporal relationship model that can output the temporal relationship between two clinical events in the original clinical text.

2. The method for identifying the temporal relationship of clinical events according to claim 1, It is characterized in that The S3 includes: S3.

1. Use the BioBERT model to generate the initial feature vectors of each node in the standardized entity subgraph ; S3.2, based on the graph attention mechanism, calculate the attention coefficients between two standardized entity nodes and their neighbor nodes respectively; S3.3, normalizing the attention coefficients obtained in S3.2 to obtain normalized attention coefficients; S3.

4. According to the normalized attention coefficient, weighted aggregation is performed on the information of the neighbor nodes of the two standardized entity nodes to obtain the neighbor aggregation vectors of the two standardized entity nodes respectively; S3.5, aggregate the information of all intermediate nodes between two standardized entity nodes to obtain a path feature vector connecting the two standardized entity nodes; S3.

6. Based on the path feature vector and the neighbor aggregation vector of the two standardized entity nodes, the final feature vectors of the two standardized entity nodes are generated respectively, and the final feature vectors of the two clinical events are concatenated to obtain the comprehensive feature vector of the clinical event pair.

3. The method for identifying the temporal relationship of clinical events according to claim 2, It is characterized in that In S3.2, the calculation formula of the attention coefficient is as follows: ; in: is the number of the current layer; is the first Standardized entity nodes of layers Its neighbor nodes The attention coefficient between is the number of the standardized entity node, which takes the value 1 or 2; Standardized entity node The neighbor node number of is the activation function; is the first The weight vector of the layer, Transpose it; is the first The weight matrix of the layer; and They represent the first Standardized entity nodes of layers The initial eigenvector and its neighbor nodes The initial eigenvector of Represents vector concatenation; In S3.3, the calculation formula of the normalized attention coefficient is as follows: ; in: is the normalized attention coefficient; Standardized entity node The set of neighbor node numbers of express A neighbor node number in ; Is a standardized entity node and neighbor nodes The unnormalized attention coefficient between Standardized entity node and a neighbor node The unnormalized attention coefficient between ; In S3.4, the calculation formula of the neighbor aggregation vector is as follows: ; in: Standardized entity node In the graph attention mechanism The neighbor aggregation vector of the layer, is a nonlinear activation function; Neighbor node In the graph attention mechanism The feature vector of the layer; In S3.5, the calculation formula of the path characteristic vector is as follows: ; in: is the path feature vector between two standardized entity nodes; is the number of the intermediate node, The first The feature vector of the intermediate nodes, are the total number of two normalized entity nodes and intermediate nodes; In S3.6, the calculation formula of the final eigenvector is as follows: ; in: Standardized entity node The final eigenvector of ; The calculation formula of the comprehensive feature vector of clinical event pairs is as follows: ; in: is the comprehensive feature vector of clinical event pairs; Standardized entity node The final eigenvector of Standardized entity node The final feature vector of .

4. The method for identifying the temporal relationship of clinical events according to claim 3, It is characterized in that The S4.2 includes: S4.2.

1. Linearly transform the comprehensive feature vector of the clinical event pair and the embedding vector of each sentence to obtain a linearly transformed comprehensive feature vector and a linearly transformed embedding vector; S4.2.2, based on the multi-head attention mechanism, the attention scores of different attention heads of the clinical event pairs on each sentence are calculated according to the linearly transformed comprehensive feature vector and the linearly transformed embedding vector; S4.2.

3. In each attention head, the attention score of each sentence is normalized to obtain the normalized weight, and the final attention weight of the clinical event pair on each sentence is calculated based on the normalized weight.

5. The method for identifying the temporal relationship of clinical events according to claim 4, It is characterized in that In S4.2.1, the calculation formula of the linear transformation is as follows: ; ; in: Number the sentences. For the The embedding vector of each sentence; Represents the head number in the multi-head attention mechanism; For the The feature representation of clinical event pairs after linear transformation in each head, For the After linear transformation in the The embedding vector of each sentence; and They are used for and The weight matrix of the graph attention mechanism; In S4.2.2, the calculation formula of the attention score is as follows: ; in: For clinical events in The first sentence The attention score of each attention head; for Dimensions; is transposed; In S4.2.3, the calculation formula of the normalized weight is as follows: ; in: is the normalized weight, The function is used to normalize the attention scores into a probability distribution; The calculation formula for the final attention weight is as follows: ; in: For clinical events in The final attention weight of the sentence; is the total number of attention heads.

6. The method for identifying the temporal relationship of clinical events according to claim 5, It is characterized in that The S6 includes: S6.

1. Use the OpenPrompt tool to create a prompt template, which includes: a text-encoded context fragment, a question asking about the temporal relationship between two clinical events, and a candidate set of temporal relationship types; S6.

2. Generate training samples and test samples based on the prompt template. In the training samples, the medical causal relationship between two clinical events is first answered, and then the temporal relationship between the two clinical events is judged based on the causal relationship and the context information of the text fragment; the test samples include the text-encoded context fragment, the question asking about the temporal relationship between the two clinical events, and the candidate set of the temporal relationship type; S6.

3. Use the training samples to train the BioBERT model to obtain a temporal relationship model that can output the temporal relationship between two clinical events in the original clinical text; and use the test samples to test and evaluate the temporal relationship model; S6.

4. The text fragments obtained in S5 are used to form a prompt template and input into the temporal relationship model. The temporal relationship model will first determine the medical causal relationship between the two clinical events, and then combine the context information of the text fragments in the prompt template to identify the temporal relationship between the two clinical events.

7. The method for identifying the temporal relationship of clinical events according to claim 6, It is characterized in that In S6.1, medical causal relationships include causal relationships, conditional relationships, and hierarchical relationships; the two clinical events are clinical event A and clinical event B; the candidate set of temporal relationship types includes SIMULTANEOUS, OVERLAP, BEFORE, AFTER, and UNKNOWN, where: SIMULTANEOUS means simultaneous, OVERLAP means partial overlap, BEFORE means clinical event A is before clinical event B, AFTER means clinical event A is after clinical event B, and UNKNOWN means unknown.

8. The method for identifying the temporal relationship of clinical events according to any one of claims 1 to 7, It is characterized in that In S1, clinical events are medical events related to patients that occur during the medical process, and medical entities include disease names, drug names, symptom names, examination item names, food names, and department names.

9. A computer-readable storage medium, It is characterized in that Computer program instructions are stored thereon, and when the computer program instructions are executed by a processor, the method for identifying the temporal relationship of clinical events as described in any one of claims 1 to 8 is implemented.

10. An electronic device, It is characterized in that include: At least one processor, at least one memory, and computer program instructions stored in the memory, when the computer program instructions are executed by the processor, the method for identifying the temporal relationship of clinical events according to any one of claims 1 to 8.