A medical text entity relationship joint extraction method fusing relationship semantic information
Patent Information
- Application Number
- CN202311163642.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-11
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2043-09-11
AI Technical Summary
本发明的目的有三点:1)将关系的语义信息融入候选的关系三元组中,解决三元组信息不完整的问题
[0073]1)本发明提出的融合关系语义信息的神经网络结构模型RelationLinker,将关系的语义信息融入到候选的关系三元组中,使得候选的关系三元组有了较为完整的信息。在保证关系三元组提取效果的同时提升了模型的召回率。
Smart Images

Figure CN117421387B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of medical natural language processing technology, specifically referring to a method for jointly extracting entity relations from medical text by integrating relational semantic information. Background Technology
[0002] Currently, most hospitals in China use natural language processing (NLP) to record medical records. This type of unstructured text cannot be directly used by computers and needs to be converted into a structured format that is easy for computers to process. Extracting structured information from unstructured text is one of the research directions in natural language processing. The rapid and accurate extraction of structured information from medical records mainly relies on information extraction techniques in natural language processing, including entity extraction, relation extraction, and event extraction. Among these, entity and relation extraction are key steps in structuring medical records.
[0003] Entity and relation extraction is a key task in information extraction. There are two main types of methods for entity and relation extraction. One type uses a pipeline approach, treating entity and relation extraction as two cascaded subtasks, with relation extraction depending on entity extraction. The drawback of this method is the problem of error propagation and the lack of consideration for the interaction between the two subtasks. The other type uses joint decoding, where relation and entity extraction share a single encoder. This type of method has become the mainstream approach; for example, CasRel uses a single BERT encoder for entity and relation extraction.
[0004] In recent years, most methods for achieving SOTA (Social Outcome Scale) performance in entity-relation extraction have been based on token-pairing, such as TPLinker, which enumerates any two tokens in a sentence as possible entities or entity pairs. This approach has significant advantages, solving the error accumulation problem and enabling simultaneous entity and relation extraction.
[0005] The recent surge in popularity of ChatGPT has once again propelled artificial intelligence to new heights. We can not only chat with ChatGPT, but also use it to assist in scientific research. In the field of entity relation extraction, on the one hand, we can use ChatGPT for data augmentation, having it help us generate new samples through conversation. On the other hand, we can also use ChatGPT to perform logical judgments on extracted relation triples.
[0006] Finally, current entity relation extraction models merely treat relations as numerical identifiers without any concrete semantic information. This approach is flawed. For example, given a sentence and relation name, we can quickly identify which words in the sentence are associated with the relation name. This example clearly illustrates the importance of semantic information in capturing relation triples. Furthermore, many models suffer from class imbalance in their training datasets. Therefore, we need to propose a model that incorporates the semantic information of relations while addressing the class imbalance problem in the datasets themselves. Summary of the Invention
[0007] To address the problems in the background art, this invention discloses a joint extraction method for medical text entity relations that integrates relational semantic information. The invention has three objectives: 1) To integrate the semantic information of relations into candidate relation triples, solving the problem of incomplete triple information. 2) To use ChatGPT to help generate new samples and address the class imbalance problem in the dataset itself. 3) To use ChatGPT to filter the extracted relation triples, improving the model's accuracy.
[0008] The technical solution adopted in this invention includes the following steps:
[0009] (1) Preprocess each sample in the publicly available medical text dataset to generate the original model training dataset;
[0010] (2) Use ChatGPT to augment the model training dataset constructed in step 1) to solve the problem of class imbalance and construct a new model training dataset.
[0011] (3) Construct the RelationLinker neural network model structure based on the pre-trained language model Bert;
[0012] (4) Train the RelationLinker neural network model constructed in step 3) based on the model dataset in step 2).
[0013] (5) Use the RelationLinker neural network model trained in step 4) to perform joint entity relation extraction on the medical text;
[0014] (6) Use ChatGPT to filter the relation triples extracted in step 5) to obtain the final result set.
[0015] Step 1) specifically refers to:
[0016] 1.1) Based on each text T and the list of triples corresponding to the text in the publicly available medical text dataset, three types of tag matrices are defined: entity head and tail tags EH-ET, subject and object combination head and tail tags SH-OH and ST-OT.
[0017] The list of triples includes subject, predicate, and object;
[0018] Among them, the entity's first and last tag matrix is used to extract the subject and object; the first and last tag matrices of the subject and object are used for subject-object alignment.
[0019] 1.2) Use a tokenizer to segment the text T (including the cls and sep symbols) to generate a token sequence: T1, T2, ..., T n ;
[0020] 1.3) Process each triple corresponding to text T:
[0021] a) Obtain the beginning and end tags of the entity:
[0022] Extract the subject and object from the triple as entities, and use the tuples (entity-head, entity-tail) formed by the start and end positions of the entities in the token sequence as the coordinates of the entity head and tail marker matrix, and set the value on them to 1.
[0023] b) Obtain the first and last tags of the entity pair:
[0024] Entity pairs are combinations of the subject and object of a known relation in a triple;
[0025] The tuple (subject-head, object-head) formed by the starting positions of the subject and object in the token sequence is used as the coordinates of the entity pair head-head tag matrix, and its value is set to 1; the tuple (subject-tail, object-tail) formed by the ending positions of the subject and object in the token sequence is used as the coordinates of the entity pair tail-tail tag matrix, and its value is set to 1.
[0026] In this case, the values of other coordinates on the marker matrix are 0.
[0027] Step 2) specifically refers to:
[0028] 2.1) Perform relationship category statistics on samples in publicly available medical text datasets;
[0029] 2.2) For samples where the number of occurrences of a category is less than the threshold, ChatGPT is used for data augmentation. The sentences are rewritten to generate new samples without changing the meaning and keywords.
[0030] 2.3) After preprocessing the new samples, add them to the dataset from step (1) to construct a new model training dataset;
[0031] The preprocessing of the new samples is as follows: after removing sentences with semantic incoherence and distorted meaning, the preprocessing method in step 1 is used to process the new samples.
[0032] The RelationLinker neural network model structure in step 3) includes a Bert encoding layer, a relation embedding representation module, a subject-object extraction module, and a subject-object alignment module.
[0033] 3.1) Coding layer
[0034] RoBERTa encoding is used, where the input to the encoding layer is: [cls]text[sep], and the output is: (h1,h2,…,h n );
[0035] Among them, h i h is the hidden vector representation of the i-th token after RoBERTa encoding. i ∈(h1,h2,…,h n );
[0036] 3.2) Relationship Embedding Module
[0037] In the subject-object alignment process, any relation R in the relational paradigm followed by the dataset is used. i It is represented using an embedding vector, which is randomly generated using the function torch.nn.embedding;
[0038] Among them, R i ∈R,R={R1,R2,…,R m}, 1≤i≤m, where m is the number of relations in the relation normal form;
[0039] In the process of generating the subject and object, the extracted subject and the extracted object are regarded as two special relations r1 and r2. For any one of the special relations r1 and r2, the extraction subject and object are considered as two special relations r1 and r2. k Representation is performed using an embedding vector, which is randomly generated using the function torch.nn.embedding;
[0040] Where, r k ∈r, r={r1,r2},1≤k≤2;
[0041] Here, "extraction subject" refers to the subject of the sentence being extracted, and "extraction object" refers to the object of the sentence being extracted; the special relations r and r2 are used to represent the actions of extracting the subject or object.
[0042] 3.3) Subject-Object Generation Module
[0043] The relation r is obtained through the relation embedding module, and each relation r is further enumerated. k ;
[0044] Based on the latent vector sequence (h1,h2,…,h) output by the coding layer n Enumerate all pairs (h) that could be entities. i ,h j Then, through fully connected layers, the first and last representations of the entity (q) are learned respectively. i ,t j Using LearnedPositional Embedding, we obtain the relative position vector p, which is the fragment length of the candidate entity.
[0045] The first character vector q of the candidate entity i relation vector r k The tail character vector t j The relative position vectors p are concatenated in order to obtain a long vector (q). i ,r k ,t j ,p), learn the corresponding quadruple representation s of the long vector through a linear layer (generating a vector after dimensionality reduction through the linear layer);
[0046] Let the quadruple represent s and the relation r k The score obtained by performing a dot product operation on the embedding vector is used as the final score of the current candidate entity quadruple;
[0047] 3.4) Subject-Object Alignment Module
[0048] The first and last tags of the entity pair are processed separately. The entity pair tuples include (subject-head, object-head) and (subject-tail, object-tail).
[0049] Obtain the set of relational normal forms R = {R1, R2, ..., R} using the relation embedding module. m}, m is the number of relations in the relation normal form; further enumerate each relation R in the relation normal form. k ,1≤k≤m;
[0050] Based on the latent vector sequence (h1,h2,…,h) output by the coding layer n Enumerate all possible pairs of tuples (h) that could be entity pairs.i ,h j The language learns its subject and object representations through two linear layers, thereby generating a subject vector s. i Object vector o j Based on subject vectors s i Relational embedding vector R k Object vector o j Enumerate a potential relation triple candidate and assign the subject vector s i Relational embedding vector R k Object vector o j Concatenate them sequentially to form a long vector (s) i ,R k ,o j Then, the long vector is passed through a linear layer to learn its corresponding triplet representation t;
[0051] Let the triplet t and relation R be represented. k The score obtained by performing a dot product operation on the embedding vector is used as the final score of the current candidate relation triplet.
[0052] Step 4) specifically involves:
[0053] The RelationLinker neural network model constructed in step 3) is trained using the model training dataset from step 2). The sparse multi-label cross-entropy function is selected as the final loss function, and the weights and biases of the RelationLinker neural network model are adjusted using backpropagation of error. The neural network model parameters are selected based on the F1 score of the multi-label classification during the training process, and the set of parameters corresponding to the maximum F1 score of multi-label classification is used as the RelationLinker neural network model parameters.
[0054] Step 5) specifically involves:
[0055] 5.1) For a given text T, first add the special characters [cls] and [seq] to the beginning and end of the text respectively, then input it into the BERT encoding layer. The BERT encoding layer outputs (h1, h2, ..., h... n );
[0056] 5.2) The output latent vector sequence (h1, h2, ..., h...) n Input the subject-object generation module, which outputs two matrices: the subject and object beginning and ending matrices: SH-ST, OH-OT.
[0057] The value at each coordinate of the matrix represents the final score of the corresponding candidate entity pair. When the score exceeds a set threshold, it means that the corresponding candidate entity pair is valid and is retained; otherwise, it is considered invalid and is filtered out; finally, the subject and object set is obtained.
[0058] The default value for the threshold is 0.
[0059] 5.3) The output latent vector sequence (h1, h2, ..., h...) n The input is the subject-object alignment module, which outputs two types of subject-object alignment matrices, including the first-head matrix SH-OH and the last-head matrix ST-OT, with |R| matrices in each type.
[0060] The value at each coordinate in the matrix represents the final score of the corresponding candidate relation triplet;
[0061] Among them, the subject-object alignment matrix has two thresholds α and β, where α < β; α is used to determine whether the candidate relation triple is valid, and β is used to determine whether the credibility of the relation triple is high.
[0062] 5.4) Use a double loop enumeration method to enumerate all possible subject and object combinations from the subject and object sets output in step 5.2), and decode each possible subject and object combination to obtain the set of relation triples corresponding to the text.
[0063] The decoding process in step 5.4) is as follows:
[0064] 5.4.1) For each possible subject and object combination, the subject coordinates are represented as (subject-head, subject-tail), the object coordinates are represented as (object-head, object-tail), and the coordinates of the subject and object combination are represented as (subject-head, object-head) and (subject-tail, object-tail).
[0065] 5.4.2) Step 5.3) Output the two types of subject-object alignment matrices for each relation, including the first-to-first alignment matrix and the last-to-last alignment matrix for each relation:
[0066] a) If the coordinates (subject-head, object-head) in the subject-object head alignment matrix exceed the specified threshold α and the coordinates (subject-tail, object-tail) in the subject-object tail alignment matrix also exceed the specified threshold α, extract the subject name, relation name and object name from the text and relation paradigm based on the coordinates of the subject and object combination, and add the extracted relation triples to the relation triples set S1;
[0067] b) Similarly, when the threshold β is exceeded, another set of relation triples with higher credibility, S2, is obtained by referring to step a).
[0068] Step 6) specifically involves:
[0069] Let S3 = S1 - S2, we get a set of relation triples with lower credibility, S3, where S2 is a subset of S1;
[0070] For each extracted relation triplet in set S3, the relation triplet is arranged into a statement in subject-verb-object order and input into ChatGPT. ChatGPT is used to determine whether the statement is true, and relation triplets that are true are added to set S4.
[0071] Output the union of S2 and S4 as the final result set.
[0072] The beneficial effects of this invention are:
[0073] 1) The RelationLinker neural network structure model proposed in this invention integrates the semantic information of relations into candidate relation triples, giving them more complete information. This improves the model's recall rate while ensuring the effectiveness of relation triple extraction.
[0074] 2) This invention defines three types of tags based on the token-pair method: the first and last tags of an entity, the first and last tags of an entity pair, and the last and last tags, which solves the problems of entity nesting, SPO, and EPO in the joint extraction of entity relationships.
[0075] 3) To address the class imbalance issue in the original dataset, ChatGPT is used for data augmentation.
[0076] 4) ChatGPT was used to filter relation triples with low credibility, which further improved the accuracy of the model. Attached Figure Description
[0077] Figure 1 This is a flowchart of the present invention;
[0078] Figure 2 This is a schematic diagram of the basic structure of the RelationLinker neural network model of the present invention;
[0079] Figure 3 This is a structural diagram of the subject-object generation module of the present invention. Detailed Implementation
[0080] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0081] like Figure 1 As shown, the present invention provides a method for jointly extracting entity relationships from medical text by fusing relational semantic information, comprising the following steps:
[0082] Step 1) specifically includes the following steps:
[0083] 1.1) For each text T and any triple (subject, predicate, object) appearing in the publicly available medical dataset, three tag matrices are defined: entity head and tail tags EH-ET, subject and object head and tail tags SH-OH, and subject and object tail and tail tags ST-OT. The entity head and tail tag matrix is used to extract the subject and object. The subject and object head and tail tag matrices are used for subject-object alignment.
[0084] 1.2) Use Tokenizer to segment the text T (including cls and sep symbols) to generate a token sequence (T1, T2, ..., Tn).
[0085] 1.3) For any triple (subject, predicate, object) appearing in text T and a given relation predicate, first process the entity's head and tail tags. Treat the subject and object as separate entities. The tuple (entity-head, entity-tail) formed by the start and end positions of the entity in the token sequence is used as the coordinates of the entity's head and tail tag matrix, and its value is set to 1. Next, process the entity pair's head and tail tags. The tuple (subject-head, object-head) formed by the start positions of the subject and object in the token sequence is used as the coordinates of the entity pair's head tag matrix under the known relation, and its value is set to 1. The tuple (subject-tail, object-tail) formed by the end positions of the subject and object in the token sequence is used as the coordinates of the entity pair's tail tag matrix under the known relation, and its value is set to 1. The values at other coordinates in the tag matrix are 0.
[0086] like Figure 2 As shown, the text: “Mycoplasma pneumonia symptoms include fever and dry cough.” contains the following relational triples: (Mycoplasma pneumonia, clinical manifestations, fever), (Mycoplasma pneumonia, clinical manifestations, dry cough). In the entity head and tail tag matrix for the extracted subject, the value at coordinate (1,5) is 1. In the entity head and tail tag matrix for the extracted object, the values at coordinates (10,11) and (13,14) are 1, and the values at the remaining coordinates are 0. Under the condition that the relation is clinical manifestations, in the head and tail entity head and tail entity head and tail tag matrices, the values at coordinates (1,10) and (1,13) are 1, and the values at the remaining coordinates are 0. In the head and tail entity tail and tail entity tail and tail tag matrices, the values at coordinates (5,11) and (5,14) are 1, and the values at the remaining coordinates are 0.
[0087] Step 2) specifically includes the following steps:
[0088] 2.1) Perform category statistics on samples in the publicly available medical text dataset.
[0089] 2.2) For samples where the category appears less frequently, ChatGPT is used for data augmentation. Sentences are rewritten to generate new samples without changing the meaning and keywords.
[0090] 2.3) Preprocess the newly generated samples and add them to the original dataset to build a new model training dataset.
[0091] The original sentence was: "Symptoms of mycoplasma pneumonia include fever and dry cough." The new text is: "Clinical manifestations of mycoplasma pneumonia include fever and dry cough." The relational triples appearing in the sentence are: (mycoplasma pneumonia, clinical manifestations, fever), (mycoplasma pneumonia, clinical manifestations, dry cough). In the entity head and tail tag matrix for the extracted subject, the value at coordinate (1,5) is 1. In the entity head and tail tag matrix for the extracted object, the values at coordinates (12,13) and (15,16) are 1, and the values at the remaining coordinates are 0. Under the condition that the relation is "clinical manifestations," in the head and tail entity head and tail entity head and tail tag matrices, the values at coordinates (1,12) and (1,15) are 1, and the values at the remaining coordinates are 0. In the head and tail entity tail and tail entity tail tag matrices, the values at coordinates (5,13) and (5,16) are 1, and the values at the remaining coordinates are 0.
[0092] Step 3) specifically includes the following steps:
[0093] 3.1) Encoding Layer. RoBERTa encoding is used, where the input to the encoding layer is: [cls]text[sep], and the output is (h1, h2, ..., hn).
[0094] 3.2) Relation Embedding Module. This module embeds any relation R within the relational paradigm followed by the dataset. i The embedding vector is used for representation. The embedding vector is generated using torch.nn.embedding(relation_num, relation_dim).
[0095] 3.3) Subject-Object Generation Module. The extracted subject and object are treated as special relations and processed separately. A relation vector representation *r* is obtained through the relation embedding module. For the latent vector sequence (h1, h2, ..., hn) output by the encoding layer, all possible pairs (hi, hj) that could become entities are first enumerated. Then, the first and last representations (qi, tj) of the entity are learned through a fully connected layer. Next, the relative position vector *p* is obtained using Learned Positional Embedding. The first character vector *qi*, the relation vector *r*, the last character vector *tj*, and the relative position vector *p* of the candidate entity are concatenated in sequence to obtain a long vector. This long vector is passed through a linear layer to learn the corresponding quadruple representation. The dot product of this quadruple representation and the relation embedding vector is performed to obtain a score, which is the final score for this candidate entity quadruple.
[0096] 3.4) Subject-Object Alignment Module. The first and last tags of entity pairs are processed separately. For any latent vector *hi* output from the encoding layer, its subject and object representations are learned through two linear layers. Then, for any potential relation triplet candidate (subject, predicate, object), the subject vector, relation embedding vector, and object vector are concatenated sequentially into a long vector. This long vector is then passed through a linear layer to learn its corresponding triplet representation. The dot product of this triplet representation and the relation embedding vector yields a score, which is used as the final score for this candidate relation triplet.
[0097] Step 4) specifically includes the following steps:
[0098] The RelationLinker neural network model constructed in step 3) is trained using the model training dataset from step 2). The sparse multi-label cross-entropy function is selected as the final loss function, and the weights and biases of the RelationLinker neural network model are adjusted using backpropagation of error. The neural network model parameters are selected based on the F1 score of the multi-label classification during the training process, and the set of parameters corresponding to the maximum F1 score of multi-label classification is used as the RelationLinker neural network model parameters.
[0099] Step 5) specifically includes the following steps:
[0100] 5.1) For a given text T, first add the special characters [cls] and [seq] to the beginning and end of the text respectively, then input it into the Bert encoding layer. The output of the Bert encoding layer is (h1, h2, ..., hn).
[0101] 5.2) The output latent vector sequence (h1, h2, ..., hn) is input into the subject-object generation module. The output of the subject-object generation module is two matrices (SH-ST, OH-OT). The value at each coordinate of the matrix represents the final score of the candidate entity pair. When this score exceeds a certain threshold, the candidate entity pair is considered valid; otherwise, it is considered invalid. This threshold is 0 by default. Finally, the subject and object sets are obtained.
[0102] 5.3) The output latent vector sequence (h1, h2, ..., hn) is input into the subject-object alignment module. The output of the subject-object alignment module is two types of matrices (SH-OH, ST-OT), with |R| matrices in each type. The value at each coordinate of the matrix represents the final score of the candidate relation triple. When this score exceeds a certain threshold, the candidate relation triple is considered valid; otherwise, it is considered invalid. This threshold is 0 by default. Several subject-object alignment matrices are obtained in the end.
[0103] 5.4) Decoding. Step 5.2) Outputs the subject and object set of a sentence. At this point, a double loop is used to enumerate any possible subject and object combination. The subject is represented as (subject-head, subject-tail), and the object as (object-head, object-tail). Step 5.3) outputs two types of subject-object alignment matrices for each relation. For any relation P, if the coordinates (subject-head, object-tail) in its corresponding subject-object head alignment matrix exceed a specified threshold α, and the coordinates (subject-tail, object-tail) in its corresponding subject-object tail alignment matrix also exceed the specified threshold α, then we extract the subject name, relation name, and object name from the text and relation paradigm, and add them as the extracted relation triplet (subject name, relation name, object name) to the relation triplet set S1. Similarly, when the threshold β is exceeded, we obtain another set of relation triples with higher confidence, S2. For example, here α = 0, β = 1.
[0104] like Figure 2As shown, the input text is "Mycoplasma pneumonia symptoms include fever and dry cough." The subject set {(1, 5, 2.7)} and the object set {(10, 11, 3.2), (13, 14, 2.1)} are obtained from the subject-object extraction module. The first-to-first alignment matrix of entity pairs {(7, 1, 10, 1.7), (7, 1, 13, 0.8)} is obtained from the subject-object alignment module. The last-to-last alignment matrix of entity pairs {(7, 5, 11, 2.3), (7, 5, 14, 0.3)} is obtained. A double loop is used to enumerate any combination of subject and object in the subject and object sets. In this example, the subject coordinates can be (1, 5), and the object coordinates can be (10, 11) and (13, 14). The matrix obtained from the subject-object alignment module is then used for alignment. For threshold α, the quintuples that meet the above conditions are (1, 5, 7, 10, 11) and (1, 5, 7, 13, 14). Then, the final triples (Mycoplasma pneumonia, clinical manifestations, fever) and (Mycoplasma pneumonia, clinical manifestations, dry cough) are obtained from the text and relational paradigm and added to the relational triple set S1. Similarly, for threshold β, we obtain a relational triple set S2 with higher confidence. In this example, S1 = {(Mycoplasma pneumonia, clinical manifestations, fever), (Mycoplasma pneumonia, clinical manifestations, dry cough)}. S2 = {(Mycoplasma pneumonia, clinical manifestations, fever)}.
[0105] Step 6) specifically involves:
[0106] Step 5) Output two sets of relation triples, S1 and S2, where S2 is a subset of S1. Let S3 = S1 - S2, resulting in a set of relation triples with lower confidence, S3. For each relation triple in set S3, use ChatGPT to check if it is true; if true, add it to set S4. The final result set is the union of S2 and S4. Return the final result set.
[0107] In the example of step 5) above, S1 = {(Mycoplasma pneumonia, clinical manifestations, fever), (Mycoplasma pneumonia, clinical manifestations, dry cough)}. S2 = {(Mycoplasma pneumonia, clinical manifestations, fever)}. Dividing S1 and S2 yields a set of relation triples with lower confidence, S3 = {(Mycoplasma pneumonia, clinical manifestations, dry cough)}. For each relation triple in set S3, ChatGPT is queried to determine its validity, following the subject-verb-object order: "The clinical manifestations of mycoplasma pneumonia include dry cough. Please answer yes or no?". After ChatGPT provides an answer, it compares it with the result extracted by RelationLinker. If the answer is yes, the relation triple is added to relation set S4. Here, the answer is yes, so S4 = {(Mycoplasma pneumonia, clinical manifestations, dry cough)}. The final result set is the union of S2 and S4. In this example, the final result set is {(Mycoplasma pneumonia, clinical manifestations, fever), (Mycoplasma pneumonia, clinical manifestations, dry cough)}.
[0108] The performance of the model of this invention and the classic model on the CMeIE dataset is as follows:
[0109]
[0110] Note:
[0111] (1) CasRel and GPLinker are classic entity relation extraction algorithm models, while RelationLinker is the model of this invention;
[0112] (2) Precision: The proportion of samples that are predicted as positive that are correctly predicted. The larger the value, the better the extraction effect.
[0113] (3) Recall: The proportion of positive samples that are actually positive samples that are correctly predicted out of the total number of actual positive samples. The larger the value, the better the extraction effect.
[0114] (4) F1: the harmonic mean of recall and precipitson. The larger the value, the better the extraction effect.
[0115] (5) Compared to Casrel, the F1 value of this invention is increased by 11.770%;
[0116] (6) Compared to GPLinker, the recall rate of this invention is improved by 3.439%, which improves the recall rate of the model;
[0117] (7) Compared to GPLinker, the F1 score is improved by 1.811% after data augmentation using ChatGPT in this invention.
Claims
1. A method for jointly extracting entity relations from medical text by fusing relational semantic information, comprising the following steps: (1) Preprocess each sample in the publicly available medical text dataset to generate the original model training dataset; (2) Use ChatGPT to augment the model training dataset constructed in step 1) to construct a new model training dataset; (3) Construct the RelationLinker neural network model structure based on the pre-trained language model BERT; (4) Train the RelationLinker neural network model constructed in step 3) based on the model dataset in step 2); (5) Use the RelationLinker neural network model trained in step 4) to perform joint entity relation extraction on the medical text; (6) Use ChatGPT to filter the relation triples extracted in step 5) to obtain the final result set; Step 2) specifically refers to: 2.1) Perform relationship category statistics on samples in publicly available medical text datasets; 2.2) For samples where the number of occurrences of a category is less than the threshold, ChatGPT is used for data augmentation to rewrite the sentences and generate new samples without changing the meaning and keywords. 2.3) After preprocessing the new samples, add them to the dataset from step (1) to construct a new model training dataset; The preprocessing of the new samples is as follows: after removing sentences with semantic incoherence and distorted meaning, the preprocessing method in step 1 is used to process the new samples. The RelationLinker neural network model structure in step 3) includes a Bert encoding layer, a relation embedding representation module, a subject-object extraction module, and a subject-object alignment module. 3.1) Coding layer RoBERTa encoding is used, where the input to the encoding layer is: [cls]text[sep], and the output is: ; in, For the first The implicit vector representation of each token after RoBERTa encoding. ; 3.2) Relationship Embedding Module In the process of subject-object alignment, any relation in the relational paradigm followed by the dataset is considered. It is represented using an embedding vector, which is randomly generated using the function torch.nn.embedding; in, , The number of relations in the relational normal form; In the process of subject-object generation, the extracted subject and the extracted object are regarded as two special relationships. and For any one of these special relations Representation is performed using an embedding vector, which is randomly generated using the function torch.nn.embedding; in, ; Here, "extracting subject" refers to extracting the subject of the sentence, and "extracting object" refers to extracting the object of the sentence; special relationships and Used to describe the act of extracting a subject or object; 3.3) Subject-Object Generation Module Obtained through the relationship embedding module Further enumerate each type of relationship ; Based on the hidden vector sequence output by the coding layer Enumerate all pairs that could be entities. Then, through fully connected layers, the first and last representations of the entity are learned. The relative position vector p is obtained using Learned PositionalEmbedding, which is the fragment length of the candidate entity. The first character vector of the candidate entity relation vector , tail character vector The relative position vectors p are concatenated in order to obtain a long vector. The long vector is passed through a linear layer to learn the corresponding quadruple representation. ; Represent the quadruple and relationships The score obtained by performing a dot product operation on the embedding vector is used as the final score of the current candidate entity quadruple; 3.4) Subject-Object Alignment Module The first and last tags of the entity pair are processed separately. The entity pair tuples include (subject-head, object-head) and (subject-tail, object-tail). Obtain the set of relation paradigms through the relation embedding module. m is the number of relations in the relational normal form; further enumeration of each type of relation in the relational normal form. ; Based on the hidden vector sequence output by the coding layer Enumerate all pairs of tuples that can be entity pairs. It learns its subject and object representations through two linear layers, thereby generating subject vectors. Object vector Based on subject vectors Relational embedding vectors Object vector Enumerate a potential relation triple candidate and assign the subject vector Relational embedding vectors Object vector Concatenate them sequentially into a long vector Then, the long vector is passed through a linear layer to learn its corresponding triplet representation t; Let the triplet represent t and the relation The score obtained by performing a dot product operation on the embedding vector is used as the final score of the current candidate relation triplet.
2. The method for jointly extracting entity relations from medical text by fusing semantic information according to claim 1, characterized in that, Step 1) specifically refers to: 1.1) Based on each text T and the list of triples corresponding to the text in the publicly available medical text dataset, three types of label matrices are defined: entity head and tail label EH-ET, subject and object combination head and tail label SH-OH, and subject and object combination tail and tail label ST-OT. The list of triples includes subject, predicate, and object; 1.2) Use a tokenizer to segment the text T and generate a token sequence: ; 1.3) Process each triple corresponding to text T: a) Obtain the beginning and end tags of the entity: Extract the subject and object from the triple as entities, and use the tuples (entity-head, entity-tail) formed by the start and end positions of the entities in the token sequence as the coordinates of the entity head and tail tag matrix, and set the value on them to 1; b) Obtain the first and last tags of the entity pair: Entity pairs are combinations of the subject and object of a known relation in a triple; The tuple (subject-head, object-head) formed by the starting positions of the subject and object in the token sequence is used as the coordinates of the entity pair head-head tag matrix, and its value is set to 1; the tuple (subject-tail, object-tail) formed by the ending positions of the subject and object in the token sequence is used as the coordinates of the entity pair tail-tail tag matrix, and its value is set to 1. In this case, the values of other coordinates on the marker matrix are 0.
3. The method for jointly extracting entity relations from medical text by fusing semantic information according to claim 1, characterized in that, Step 4) specifically refers to: The RelationLinker neural network model constructed in step 3) is trained using the model training dataset from step 2). The sparse multi-label cross-entropy function is selected as the final loss function, and the weights and biases of the RelationLinker neural network model are adjusted using backpropagation of error. The parameters of the neural network model are selected based on the F1 score of the multi-label classification model during training. The set of parameters corresponding to the maximum F1 score of multi-label classification is used as the parameters of the RelationLinker neural network model.
4. The method for jointly extracting entity relations from medical text by fusing semantic information according to claim 1, characterized in that, Step 5) specifically involves: 5.1) For a given text T, first add the special characters [cls] and [seq] to the beginning and end of the text respectively, then input it into the BERT encoding layer, and the BERT encoding layer outputs... ; 5.2) Output the implicit vector sequence Input the subject-object generation module, and the subject-object generation module outputs two matrices: the subject and object beginning and ending matrices: SH-ST, OH-OT; The value at each coordinate in the matrix represents the final score of the corresponding candidate entity pair. When the score exceeds a set threshold, it indicates that the corresponding candidate entity pair is valid and is retained. Otherwise, it is considered invalid and eliminated; finally, the set of subjects and objects is obtained. The default value for the threshold is 0. 5.3) Output the implicit vector sequence Input the subject-object alignment module, which outputs two types of subject-object alignment matrices, including the first-word matrix SH-OH and the last-word matrix ST-OT, with |R| matrices in each type. The value at each coordinate in the matrix represents the final score of the corresponding candidate relation triplet; Among them, the subject-object alignment matrix has two thresholds α and β, where α < β; α is used to determine whether the candidate relation triple is valid, and β is used to determine whether the credibility of the relation triple is high. 5.4) Use a double loop enumeration method to enumerate all possible subject and object combinations from the subject and object sets output in step 5.2), and decode each possible subject and object combination to obtain the set of relation triples corresponding to the text.
5. The method for jointly extracting entity relations from medical text by fusing semantic information according to claim 4, characterized in that, The decoding process in step 5.4) is as follows: 5.4.1) For each possible subject and object combination, the subject coordinates are represented as (subject-head, subject-tail), the object coordinates are represented as (object-head, object-tail), and the coordinates of the subject and object combination are represented as (subject-head, object-head) and (subject-tail, object-tail). 5.4.2) Step 5.3) Output the two types of subject-object alignment matrices for each relation, including the subject-object first-first alignment matrix and the subject-object last-last alignment matrix for each relation: a) If the coordinates (subject-head, object-head) in the subject-object head alignment matrix exceed the specified threshold α and the coordinates (subject-tail, object-tail) in the subject-object tail alignment matrix also exceed the specified threshold α, extract the subject name, relation name and object name from the text and relation paradigm based on the coordinates of the subject and object combination, and add the extracted relation triples to the relation triples set S1; b) Similarly, when the threshold β is exceeded, another set of relation triples with higher credibility, S2, is obtained by referring to step a).
6. The method for jointly extracting entity relations from medical text by fusing semantic information according to claim 1, characterized in that, Step 6) specifically refers to: Let S3 = S1 - S2, we get a set of relation triples with lower credibility, S3, where S2 is a subset of S1; For each extracted relation triplet in set S3, the relation triplet is arranged into a statement in subject-verb-object order and input into ChatGPT. ChatGPT is used to determine whether the statement is true, and relation triplets that are true are added to set S4. Output the union of S2 and S4 as the final result set.
Citation Information
Patent Citations
Entity relationship data generating method, apparatus, equipment and storage medium
CN109325201A
Entity relationship extraction method and system integrated with dynamic word vector technology
CN109871451A