Medical text entity pair extraction method and device
By using a pre-trained entity pair extraction model in medical text, combined with the screening of positive and negative sample label information, the problem of low accuracy in entity pair extraction from medical text is solved and the accuracy and efficiency of extraction are improved.
Patent Information
- Application Number
- CN202410875852.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-10-01
AI Technical Summary
In the process of extracting entity pairs from medical texts, the cost of data annotation for relation extraction in the existing technology is high, resulting in low accuracy in extracting entity pairs from medical texts.
Using pre-trained entity pair extraction models, including entity recognition module, entity pair matching module and relationship classification module, the accuracy of entity pair extraction is improved by using positive and negative sample label information for model training and data screening.
By filtering based on negative sample marking information, the transmission of erroneous information is reduced, the accuracy of extraction of medical text entities is improved, and the cost of data annotation is reduced.
Smart Images

Figure CN118734840A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text processing, and in particular to a method and device for extracting medical text entity pairs. Background Art
[0002] Entity relationship extraction tasks generally aim to extract entities in text and semantic relationships between entities. Taking medical text as an example, we can extract symptom and part entities in medical text and direct relationships between entities. For example, in the medical text "Current diagnosis: T11 vertebral compression fracture; thoracic scoliosis.", we can extract the symptom manifestation part relationship between the part "thoracic vertebra" and the symptom "scoliosis".
[0003] In the process of implementing the present invention, it was found that there are at least the following technical problems in the prior art: when extracting medical text, the data annotation cost of relationship extraction is high, and a large number of high-quality annotations are difficult to obtain, resulting in low extraction accuracy of medical text entity pairs. Summary of the invention
[0004] The present invention provides a method and device for extracting entity pairs from medical texts, so as to solve the technical problem of low accuracy in extracting entity pairs from medical texts.
[0005] According to one aspect of the present invention, a method for extracting entity pairs from medical texts is provided, comprising:
[0006] Obtain the medical text to be extracted;
[0007] Inputting the medical text to be extracted into a pre-trained entity pair extraction model, and obtaining an output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module, and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample labeling information corresponding to the sample medical text, and the sample labeling information includes positive sample labeling information and negative sample labeling information, and the negative sample labeling information is used to filter the transmission data between modules;
[0008] The entity pair extraction result of the medical text to be extracted is determined based on the output result of the entity pair extraction model.
[0009] According to another aspect of the present invention, a device for extracting medical text entity pairs is provided, comprising:
[0010] A medical text acquisition module is used to acquire the medical text to be extracted;
[0011] An entity pair model extraction module, used for inputting the medical text to be extracted into a pre-trained entity pair extraction model to obtain an output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample labeling information corresponding to the sample medical text, the sample labeling information includes positive sample labeling information and negative sample labeling information, and the negative sample labeling information is used for filtering the transmission data between modules;
[0012] The entity pair extraction result determination module is used to determine the entity pair extraction result of the medical text to be extracted based on the output result of the entity pair extraction model.
[0013] According to another aspect of the present invention, there is provided an electronic device, the electronic device comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for extracting medical text entity pairs described in any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for extracting medical text entity pairs described in any embodiment of the present invention when executed.
[0018] The technical solution of the embodiment of the present invention is to obtain a medical text to be extracted; input the medical text to be extracted into a pre-trained entity pair extraction model to obtain the output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample marking information corresponding to the sample medical text, the sample marking information includes positive sample marking information and negative sample marking information, and the negative sample marking information is used to filter the transmission data between modules; based on the output result of the entity pair extraction model, the entity pair extraction result of the medical text to be extracted is determined, and the data transmission between modules in the entity pair extraction model is filtered based on the negative sample marking information, thereby solving the technical problem of transmitting erroneous information during entity pair extraction, thereby improving the accuracy of entity pair extraction.
[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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 these drawings without creative work.
[0021] Figure 1 is a flow chart of a method for extracting medical text entity pairs provided in Embodiment 1 of the present invention;
[0022] Figure 2 It is a structural schematic diagram of a medical text entity pair extraction model provided in the second embodiment of the present invention;
[0023] Figure 3 It is a structural schematic diagram of a device for extracting medical text entity pairs provided in Embodiment 3 of the present invention;
[0024] Figure 4 It is a structural schematic diagram of an electronic device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] Embodiment 1
[0028] Figure 1 This is a flow chart of a method for extracting entity pairs from medical texts provided in the first embodiment of the present invention. This embodiment is applicable to the case of extracting entity pairs from medical texts. The method can be executed by a device for extracting entity pairs from medical texts. The device for extracting entity pairs from medical texts can be implemented in the form of hardware and / or software. The device for extracting entity pairs from medical texts can be configured in an electronic device. Figure 1 As shown, the method includes:
[0029] S110, obtaining the medical text to be extracted.
[0030] In this embodiment, the medical text to be extracted may be a medical text that needs entity extraction. When entity extraction is required, the user may input text, and the text input by the user may be obtained as the medical text to be extracted. Optionally, the user may input text by inputting, selecting, etc., which is not limited here.
[0031] S120. Input the medical text to be extracted into a pre-trained entity pair extraction model to obtain an output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample labeling information corresponding to the sample medical text, the sample labeling information includes positive sample labeling information and negative sample labeling information, and the negative sample labeling information is used to filter the transmission data between modules.
[0032] In this embodiment, in order to achieve accurate extraction of medical text, an entity pair extraction model is constructed through an entity recognition module, an entity pair matching module and a relationship classification module. The entity recognition module is used to identify and extract entities, the entity pair matching module is used to match entities to determine entity pairs, and the relationship classification module is used to determine the direct relationship between entities in the entity pairs.
[0033] In order to achieve accurate entity extraction when the number of sample labels is limited, this embodiment artificially constructs a certain number of negative samples to represent the erroneous results predicted by the model when building the model training samples. When extracting entities from the model, the erroneous results predicted by the module are filtered out based on the negative samples during data transmission between modules, so that the correct prediction results are transmitted between modules, and then the output of the model is the correct prediction result, thereby improving the accuracy of entity extraction when samples are limited.
[0034] In one embodiment of the present invention, before using the entity pair extraction model to extract entities, the entity pair extraction model is trained. Optionally, the training of the entity pair extraction model includes:
[0035] Acquire a sample medical text, and determine sample labeling information in the sample medical text, wherein the sample labeling information includes positive sample labeling information and negative sample labeling information, the positive sample labeling information includes entity positive samples and relationship classification positive samples, and the negative sample labeling information includes entity negative samples and relationship classification negative samples;
[0036] Constructing a model training sample based on the sample medical text and the sample labeling information corresponding to the sample medical text;
[0037] The model training samples are used to train the pre-built entity pair extraction model to obtain a trained entity pair extraction model.
[0038] It can be understood that the entity pair extraction model provided in this embodiment includes two extraction parts, namely entity extraction and entity relationship extraction. In order to enable both entity extraction and entity relationship extraction to retain the corresponding correct information, this embodiment marks the corresponding entity positive samples, entity negative samples, and relationship classification positive samples and relationship classification negative samples, and filters out the erroneous information in the entity extraction prediction results through the entity negative samples, and filters out the erroneous information in the relationship classification prediction results through the relationship classification negative samples, and finally obtains accurate entity extraction results. The above-mentioned negative sample construction method allows the model to clearly learn which samples are correct and which samples are wrong among all candidate entity pairs under low resource conditions, so that the entity extraction model can achieve better results.
[0039] Specifically, in the entity extraction stage, setting up targeted entity negative sample construction can help the model learn better to a certain extent and improve the training accuracy of the model. In the relationship classification stage, due to the existence of the relationship dictionary, the possible combinations of entity pairs are reduced. Compared with all possible pairwise combinations of entity pairs, the model can be learned in a smaller and more representative set. The rule module generates all possible entity pair combinations, and all positive samples must be included in them, so all possible entity combinations generated by the rule module that are not positive samples are used as negative samples. And because these negative samples extracted by rules can largely represent the model's incorrect predictions, this more targeted negative sample construction method allows the model to clearly learn which samples are correct and which samples are wrong among all candidate entity pairs under low resource conditions. Therefore, the relationship classification model can achieve better results.
[0040] Among them, the process of using model training samples to train the entity pair extraction model can refer to the model training process in the prior art, which will not be repeated here.
[0041] On the basis of the above scheme, the step of inputting the medical text to be extracted into the pre-trained entity pair extraction model to obtain the output result of the entity pair extraction model includes:
[0042] Inputting the to-be-extracted medical text into the entity recognition module to obtain entity recognition information output by the entity recognition module, wherein the entity recognition information includes entity segments and categories of the entity segments;
[0043] Inputting the entity recognition information into the entity pair matching module to obtain an entity pair output by the entity pair matching module;
[0044] The entity pair is input into the relationship classification module, the relationship classification result output by the relationship classification module is obtained, and the relationship classification result is used as the output result of the entity pair extraction model.
[0045] According to the above embodiments, the entity pair extraction model includes an entity recognition module, an entity pair matching module and a relationship classification module. In order to extract the entity relationship in the medical text to be extracted, the entity recognition module is first used to identify the entity of the medical text to be extracted, and the category of the entity is determined. The identified entity is used as an entity fragment, and the category of the entity is used as the category of the entity fragment; then the entity fragment and the category of the entity fragment are input into the entity pair matching module, and the entity fragments are paired through the entity pair matching module to obtain matched entity pairs. Finally, the entity pair is input into the relationship classification module, and the relationship between the entities in the entity pair is identified through the relationship classification module, and the relationship between the entities in the identified entity pair is output as a relationship classification result.
[0046] In one embodiment of the present invention, the entity recognition module includes a boundary detection layer and an entity type classification layer, and the step of inputting the medical text to be extracted into the entity recognition module to obtain entity recognition information output by the entity recognition module includes:
[0047] Inputting the medical text to be extracted into the boundary detection layer to obtain entity segments output by the boundary detection layer;
[0048] The entity fragment is input into the entity type classification layer to obtain the category of the entity fragment output by the entity type classification layer.
[0049] Furthermore, the entity recognition module may include a boundary detection layer and an entity type classification layer, wherein the boundary detection layer is used to detect the boundaries of entities in the medical text to be extracted, thereby determining entity segments; and the entity type classification layer is used to determine the categories of entity segments. In other words, the entity segments are determined by the boundary detection layer, and the categories of entity segments are determined by the entity type classification layer.
[0050] Optionally, the boundary detection layer can be implemented by a binary classification linear layer. Specifically, the boundary detection layer can include a starting position binary classification linear layer and an ending position binary classification linear layer, the starting position binary classification linear layer identifies the probability of the starting position, the ending position binary classification linear layer identifies the probability of the ending position, and then combines a preset probability threshold to determine the entity segment.
[0051] Optionally, the entity type classification layer can be implemented by a linear classification layer. Exemplarily, the entity segment is input into a softmax linear classification layer to obtain the category of the entity segment.
[0052] In some embodiments, the step of inputting the to-be-extracted medical text into the boundary detection layer to obtain entity segments output by the boundary detection layer, and inputting the entity segments into the entity type classification layer to obtain the categories of the entity segments output by the entity type classification layer includes:
[0053] Based on the boundary detection layer Determine the starting position probability of each candidate segment in the medical text to be extracted, by Determine the end position probability of each candidate segment in the medical text to be extracted, where: represents the starting position probability of each candidate segment in the input information, represents the end position probability of each candidate segment in the input information, W start , W end is the weight parameter, b start , b end is the bias parameter, X i is the text representation calculated by the encoder, and Sigmoid is the activation function;
[0054] Obtaining an entity segment in the candidate segment determined based on the probability of the starting position and the probability of the ending position output by the boundary detection layer;
[0055] Based on the entity type classification layer, the entity type prediction probability distribution is determined by the following formula:
[0056] e(s)=F(e i ,e i+1 ,...,e i+k ),
[0057] Among them, e i It represents the dense vector representation of the entity fragment after passing through the Bert encoder, and F is the maximum pooling function. Represents the predicted probability distribution of entity type, and Softmax is a nonlinear transformation function;
[0058] The entity type classification outputs a category of an entity fragment determined based on a predicted probability distribution of the entity type.
[0059] Optionally, in order to obtain entity fragments, two binary classification linear layers can be used to predict the actual position and end position respectively. For each i-th token in the medical text to be extracted, the probability of the i-th token being predicted as the starting position and the probability of the end position being predicted as the end position are calculated. The position with the highest probability of the starting position is taken as the starting point, and the position with the highest probability of the end position is taken as the end point to obtain the entity fragment.
[0060] After obtaining the entity fragment, the category of the entity fragment is predicted. The prediction of the category of the entity fragment can be achieved through a linear classification layer. Specifically, the dense vector representation of the medical text to be extracted after passing through the encoder is calculated, and the predicted probability distribution of the entity type is determined based on the above dense vector representation. The entity category of the entity fragment is determined based on the predicted probability distribution.
[0061] In one embodiment of the present invention, inputting the entity identification information into the entity pair matching module includes:
[0062] Filtering the entity fragments in the entity identification information according to the types of the entity fragments in the entity identification information;
[0063] The entity recognition information corresponding to the filtered entity fragments is input into the entity pair matching module.
[0064] In order to avoid prediction errors caused by the transmission of erroneous information, the entity recognition information needs to be screened before it is input into the entity pair matching module. It is understandable that the entity negative sample can characterize the entity recognition information of the prediction error. Therefore, before the entity recognition information is input into the entity pair matching module, the entity recognition information is screened based on the entity negative sample, and the screened entity recognition information is input into the entity pair matching module. Optionally, the entity recognition information includes entity categories. Based on this, the entity recognition information can be screened based on the entity category, and the entity category representation in the entity negative sample can be set to none (such as none). Accordingly, the entity recognition information without the entity category representation in the entity recognition information is deleted to obtain the filtered entity recognition information.
[0065] Take the text sentence "Current diagnosis: T11 vertebral compression fracture; thoracic scoliosis" as an example. The manually labeled entities are: location thoracic vertebra, T11 vertebra. Symptoms scoliosis, compression fracture. The above labeled samples can also be called positive samples. If only positive samples are input to the model training, then when predicting, all model output results are assumed to be correct by default. In the actual process, the wrong entity will inevitably be input to the next stage. In order to avoid the wrong entity being input to the next stage, negative sample enhancement is used here, which is equivalent to artificially constructing a certain number of negative samples when constructing the training set, that is, the entity type is "None". Because negative samples are also possible wrong results predicted by the model, there are two possibilities for the randomly sampled negative samples constructed here. One is that there is an overlap with the positive sample, such as "vertebral compression" and "thoracic scoliosis", and the other is that there is no overlap with the positive sample, such as "diagnosis". This more targeted negative sample construction can help the model learn better to a certain extent and improve the training accuracy of the model.
[0066] In one embodiment of the present invention, inputting the entity recognition information into the entity pair matching module to obtain the entity pair output by the entity pair matching module includes:
[0067] The entity pair matching module generates the entity pairs according to set rules based on a predefined medical relationship dictionary.
[0068] After obtaining the entity fragments (identified by the boundary detection layer) and the categories of the entity fragments (identified by the entity type classification layer) identified by the entity recognition module, it is necessary to group the entity fragments into entity pairs as candidate entity pairs for the relationship classification module, and the relationship classification module then performs relationship classification on all entity pairs. In the medical field, when annotating data relationship triples, a medical relationship dictionary is pre-defined, that is, for a certain set of subject entity types and object entity types, their corresponding relationships are fixed. Therefore, the medical relationship dictionary in the text can be designed in advance by relevant annotators with professional backgrounds according to the application scenarios. Based on the pre-defined medical relationship dictionary, the entity fragments in the entity recognition information are formed into entity pairs, and the formed entity pairs are used as the input of the relationship classification module. Constructing entity pairs based on the medical relationship dictionary allows the generation of entity pairs without manual annotation, saving resources.
[0069] In one example, the predefined medical relationship dictionary may be:
[0070] {('Test item', 'value'): 'result',
[0071] ('lesion', 'value'):'result',
[0072] ('symptoms', 'location'): 'symptom location',
[0073] ('symptoms', 'lesions'): 'symptom manifestation location',
[0074] ('lesion', 'location'): 'lesion location',
[0075] ('lesion','test item'):'test item',
[0076] ('symptoms', 'disease'): 'modification',
[0077] …
[0078] In the above medical relationship dictionary, the entity types are in the parentheses on the left, and the content after the colon is the relationship between the entity types. For example, there is a relationship type "result" between the "test item" and "value" types.
[0079] That is, in the predefined medical relation dictionary, each triple data includes a set of entity pairs and the relationship between entities in the entity pairs. Therefore, in the predefined medical relation dictionary, for a certain set of subject entity types and object entity types, their corresponding relationship is fixed.
[0080] In one embodiment of the present invention, the entity recognition module first identifies the entity boundaries and types contained in the text A, and obtains entity fragments and categories of entity fragments. For example, the recognition result may be: [(e1, lesion), (e2, value), (e3, symptom), (e4, part)]. It is necessary to classify the relationship between the identified entity fragments, that is, to classify the entity pairs, and identify the relationship types between the entity fragments in the entity pairs. Before identifying the relationship types corresponding to the entity pairs, it is necessary to construct candidate entity pairs, and all possible entity pair combinations between the identified entity fragments can be constructed. As mentioned above, 4 entities are identified, so the number of permutations is 12, that is, 12 groups of candidate entity pairs are generated. However, the pre-defined medical relationship dictionary defines which types of entities have relationships. Therefore, it is not necessary to construct all possible entity pair combinations between the identified entity fragments as candidate entity pairs. It is only necessary to construct candidate entity pairs from entity fragments of different types that have relationships in the medical relationship dictionary. Still taking the above example, according to the medical relationship dictionary of the above example, the candidate entity pairs constructed are as follows: [(e1, e2), (e3, e1), (e1, e4), (e3, e4)]. The candidate entity pairs constructed above are input into the relationship classification module, and then entity pair classification or relationship classification is performed.
[0081] In one embodiment of the present invention, determining the output result of the entity pair extraction model based on the relationship classification result includes:
[0082] Determining the relationship category of each entity pair in the relationship classification result;
[0083] The entity pairs in the relationship classification results are screened based on the relationship categories, and the relationship classification results corresponding to the screened entity pairs are used as output results of the entity pair extraction model.
[0084] After the relationship classification module classifies the entity pairs, in order to avoid the incorrectly predicted entity pairs affecting the accuracy of the output results, the relationship classification results are screened before being output, the incorrect entity pairs are deleted, and the correct entity pairs are retained for output, thereby improving the accuracy of the output results of the entity pair extraction model.
[0085] The relationship classification result includes the relationship category between the entities in the entity pair. Based on this, the relationship classification result can be screened based on the relationship category corresponding to the entity pair. In one embodiment, the entity pair can be judged as a correct entity pair or an incorrect entity pair based on the relationship category of the entity pair. The relationship classification positive sample and the relationship classification negative sample can be pre-constructed, and the relationship category in the relationship classification positive sample is set as a standard relationship category, and the relationship category in the relationship classification negative sample is set as an incorrect relationship category. It can be understood that the relationship classification negative sample can represent the predicted incorrect entity pair. Therefore, after predicting the relationship category of each entity pair, before outputting the relationship classification result, the relationship classification result is screened based on the relationship classification negative sample, and the screened relationship classification result is used as output. Specifically, the entity pair with the relationship category of the incorrect relationship category is used as an incorrect entity pair, and the incorrect entity pair is removed and then output. Optionally, the relationship category representation in the relationship classification negative sample can be set as the incorrect relationship category, and accordingly, the entity pair with no corresponding real relationship category representation in the relationship classification result is deleted to obtain the filtered relationship classification result.
[0086] For example, the standard relationship categories between entities can be determined based on the specific meaning and application scenarios of the entities. In one example, the standard relationship categories between entities in a medical diagnosis document can be symptom manifestation site, lesion tendency, lesion site, result, etc. In one example, the standard relationship categories between entities in an imaging examination document can be modification, test item, lesion site, lesion tendency, symptom manifestation site, result, etc.
[0087] In one embodiment of the present invention, the relation classification module is constructed based on a pre-trained masked language model front end. Optionally, the classification is converted into an autoencoder language model problem for prediction based on a method based on a pre-trained masked language model front end (MLM head).
[0088] Optionally, inputting the entity pair into the relationship classification module to obtain the relationship classification result output by the relationship classification module includes:
[0089] Based on the relationship classification module, the relationship category of each entity pair in the relationship classification result is determined by the following formula:
[0090] P(y x |x)=P([MASK]=γ(y x )|x prompt )=Softmax(W lm ·h [mask] )
[0091] Among them, y x is the relationship type, x prompt To splice the input information with prompt information, W lm is the parameter matrix, h [mask] Represents x prompt The text of [MASK] represents a vector, h represents the mapping from relationship type to predicted word, and Softmax is the activation function.
[0092] Exemplarily, an input template can be pre-built. When the relationship prediction between entity pairs is required, each pair of entity pairs is filled into the template, and the prompt information prompt is spliced and then the relationship classification prediction is traversed. When predicting the relationship, the prompt will predict the [MASK] special character in the input template, that is, a certain character in the text is covered, and the model predicts the original character. Therefore, after obtaining the result of the relationship prediction (determined based on the pre-annotated relationship type), the result of the relationship prediction is filled into the character covered by [MASK] in the input module, and the output triple result includes the entity pair and the relationship type between the entity pair. Assuming that 8 types of relationship types are pre-annotated, eight characters can be pre-defined to correspond to 8 types of relationship respectively. For example, 8 special characters [class1], [class2], [class3], [class4], [class5], [class6], [class7], and [class8] are defined to correspond to 8 types of relationship respectively.
[0093] Specifically, the entity pairs that need to be predicted will be converted into prompt input. For example, the text sentence is "Current diagnosis: T11 vertebral compression fracture; thoracic scoliosis." Pre-build a template. Assume that the entity pairs to be classified are [(scoliosis, (18, 19)), (thoracic vertebrae, (16, 17)]. First, generate a prompt based on the template, "There is a relationship [MASK] [SEP] between [SEP][SUB] scoliosis [SUB / ] and [OBJ] thoracic vertebrae [OBJ / ]", where MASK is the relationship type to be tested. First, construct the original text as "[CLS] T11 vertebral compression fracture; [E1] thoracic vertebrae [E1 / ][E2] scoliosis [E2 / ]" . ", after being concatenated with prompt, is used as a new input for relation classification, "[CLS] T11 vertebral compression fracture; [E1] Thoracic vertebra [E1 / ][E2] Scoliosis [E2 / ]. There is a relationship [MASK][SEP] between [SEP][SUB] Scoliosis [SUB / ] and [OBJ] Thoracic vertebra [OBJ / ]", where [E1], [E1 / ], [E2], [E2 / ], [SUB], [SUB / ], [OBJ], [OBJ / ] are all entities and subjects and objects corresponding to special tokens. The new input contains a [MASK], and the MLM head will fill in the predicted characters for [MASK], and then map the predicted characters to the relation category label to obtain the result, that is, the relation category corresponding to the entity pair. Among them, prompt is the prompt information, which is usually concatenated with the input entity pair and input into the model as additional context.
[0094] The technical solution of the embodiment of the present invention is to obtain a medical text to be extracted; input the medical text to be extracted into a pre-trained entity pair extraction model to obtain the output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample marking information corresponding to the sample medical text, the sample marking information includes positive sample marking information and negative sample marking information, and the negative sample marking information is used to filter the transmission data between modules; based on the output result of the entity pair extraction model, the entity pair extraction result of the medical text to be extracted is determined, and the data transmission between modules in the entity pair extraction model is filtered based on the negative sample marking information, thereby solving the technical problem of transmitting erroneous information during entity pair extraction, thereby improving the accuracy of entity pair extraction.
[0095] Embodiment 2
[0096] Figure 2 It is a structural diagram of a medical text entity pair extraction model provided in the second embodiment of the present invention. This embodiment provides a preferred embodiment based on the above embodiment.
[0097] In this embodiment, the method for extracting medical text entity pairs can be based on a medical text pair extraction system model. Figure 2 As shown, the extraction model of medical text pairs includes an entity recognition module, an entity pair matching module and a relationship classification module.
[0098] (1) Entity Recognition Module
[0099] Specifically, the entity recognition module consists of two parts: boundary detection and type classification:
[0100] Entity Boundary Detection Layer:
[0101] In order to obtain the entity fragment and position, two binary linear layers can be used to predict the start position index and end position index of the entity. The operation for each token in the text sentence is as follows:
[0102]
[0103]
[0104] In the above formula, and Respectively represent the probability of each i-th token in the input sentence being predicted as the start position and end position of the entity segment. start , W end is the weight of the linear transformation layer, b start , b end is the bias. i It is the text representation calculated by the Bert encoder. Sigmoid is the activation function, which maps the value to between 0 and 1.
[0105] Entity type classification layer:
[0106] After obtaining the entity fragment and its position, first generate the representation of the entity fragment, and then input the representation of the entity fragment into the softmax (function) linear classification layer to obtain the category of the entity fragment. The operation is as follows:
[0107] e(s)=F(e i ,e i+1 ,...,e i+k );
[0108]
[0109] In the above formula, e i Represents the dense vector representation of each token obtained after the text sentence passes through the Bert encoder, and F represents the maximum pooling function. Represents the predicted probability distribution of entity types. Softmax is a nonlinear transformation function that outputs the probability value of each category in multi-classification problems.
[0110] In the entity recognition module, the starting position probability and the ending position probability of each i-th token in the medical text to be extracted are determined through the entity boundary detection layer. For each token, the position with the highest starting position probability is taken as the starting point, and the position with the highest ending position probability is taken as the ending point to obtain the entity fragment.
[0111] (2) Entity Pair Matching Module
[0112] Generally, after obtaining the results of the entity recognition module, it is necessary to group the entities into entity pairs as candidate entity pairs for the relationship classification module, which then performs relationship classification on all entity pairs. In the medical field, when labeling data relationship triples, a relationship dictionary is predefined, that is, for a certain set of subject entity types and object entity types, their corresponding relationships are fixed, as shown below:
[0113] Relation Dictionary = {
[0114] ('symptoms', 'location'): 'symptom location',
[0115] ('symptoms', 'lesions'): 'symptom manifestation location',
[0116] ('lesion','disease'):'lesion tendency',
[0117] ('lesion','lesion'):'lesion site',
[0118] ('lesion', 'location'): 'lesion location',
[0119] ('Test Item', 'Lesion'): 'Result', ...
[0121] }
[0122] Therefore, based on the pre-defined relation dictionary, all possible entity pairs can be generated according to the rules as the input of the relation classification module.
[0123] (3) Relationship Classification Module
[0124] Different from the general linear classification layer, in this embodiment, the classification is converted into an autoencoder language model problem to predict the answer word based on the MLM head method. The specific operation is as follows:
[0125] P(y x |x)=P([MASK]=h(y x )|xprompt )=Softmax(W lm ·h [mask] )
[0126] In the above formula, y x Represents the relationship type, x prompt Indicates the input of prompt is concatenated, W lm represents the weight of the linear transformation layer, h [mask] Represents x prompt The text of [MASK] represents a vector, h represents the mapping from relationship type to answer word, and SoftmaxSigmoid is an activation function that maps values to between 0 and 1.
[0127] (When using prompt for prediction, the [MASK] special character in the template will be predicted, because [MASK] means to mask a character in the text, and the model predicts the original character. Assuming there are 8 types of relationships, the answer words will be pre-defined, and the 8 special characters [class1], [class2], ..., [class8] correspond to 8 types of relationships respectively.)
[0128] Based on the above scheme, the model prediction process includes:
[0129] (1) Obtain the text sentence from which the relationship is to be extracted.
[0130] For example Figure 2 "T11 vertebral compression fracture; thoracic scoliosis."
[0131] (2) Input the text sentence into the entity recognition module, perform entity boundary detection, output the entity location index, and return the result.
[0132] [(scoliosis, (18,19)), (thoracic vertebra, (16,17)), (compression fracture, (10,14)), (T11 vertebra, (5,9)), (vertebral compression, (8,11))].
[0133] (3) Classify all entity types and filter the types of entity negative samples. Output the results.
[0134] Exemplarily, the output result may be: [(scoliosis, (18, 19), symptoms), (thoracic vertebrae, (16, 17), location), (compression fracture, (10, 14), symptoms), (T11 vertebra, (5, 9), location), (vertebral compression, (3, 6), None), (diagnosis, (2, 3), None)].
[0135] The type of entity negative samples can be: "None", so in the above results, "vertebral compression" and "diagnosis" are identified as "None" type entities, so the incorrect identification is filtered out and the process continues.
[0136] (4) Input the entities filtered in the previous step into the rule module and return all possible entity pairs based on the relationship dictionary.
[0137] Illustratively, the entity pairs may be: [[(scoliosis, (18, 19)), (thoracic vertebrae, (16, 17)], [(compression fracture, (10, 14)), (T11 vertebrae, (5, 9))], [(compression fracture, (10, 14)), (thoracic vertebrae, (16, 17)], [(scoliosis, (18, 19)), (T11 vertebrae, (5, 9))]].
[0138] (5) Fill the entity pairs into the template and input them into the relationship classification module to obtain the relationship category corresponding to the entity pairs and return the result.
[0139] Exemplarily, the output result may be: [(scoliosis, symptom site, thoracic vertebra), (compression fracture, symptom site, T11 vertebra), (compression fracture, None, thoracic vertebra), (scoliosis, None, T11 vertebra)].
[0140] In order to ensure the accuracy of the output results, the output results are filtered by the corresponding types of entity pairs. For example, the relationship type corresponding to the negative sample of relationship classification can be "None". Based on this, (compression fracture, thoracic vertebra), (scoliosis, T11 vertebra) in the output results are "None" type relationships, so the incorrect triples are filtered and the filtered output results are used as system recognition results.
[0141] The embodiment of the present invention constructs negative samples through the entity recognition module, so that the entity recognition module has the function of filtering out erroneous entities by itself, which greatly avoids the propagation of erroneous entity recognition results when performing entity recognition first and then predicting the relationship type of entity pairs. In addition, a medical relationship dictionary is pre-constructed to construct more targeted negative sample entity pairs, so that its relationship classification has better performance. In addition, the MLM head is used to replace the general linear classification layer. The MASK Language Model task during the pre-training model training is to randomly cover the token in the text sentence with a special mark [MASK], so that the model learns to predict the covered token. Therefore, the method based on the MLM head can accurately extract the entity pair extraction model under low resource conditions. Moreover, it has been verified by experiments that the method adopted in the embodiment of the present invention is about 11% better than the performance of the TDEER joint model when about 300 data are manually annotated.
[0142] Embodiment 3
[0143] Figure 3 Schematic diagram of a medical text entity pair extraction device provided in Embodiment 3 of the present invention. Figure 3 As shown, the device comprises:
[0144] A medical text acquisition module 310 is used to acquire the medical text to be extracted;
[0145] An entity pair model extraction module 320 is used to input the medical text to be extracted into a pre-trained entity pair extraction model to obtain an output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample labeling information corresponding to the sample medical text, the sample labeling information includes positive sample labeling information and negative sample labeling information, and the negative sample labeling information is used to filter the transmission data between modules;
[0146] The entity pair extraction result determination module 330 is used to determine the entity pair extraction result of the medical text to be extracted based on the output result of the entity pair extraction model.
[0147] The technical solution of this embodiment is to obtain the medical text to be extracted through the medical text acquisition module; the entity pair model extraction module inputs the medical text to be extracted into the pre-trained entity pair extraction model to obtain the output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample labeling information corresponding to the sample medical text, the sample labeling information includes positive sample labeling information and negative sample labeling information, and the negative sample labeling information is used to filter the transmission data between modules; the entity pair extraction result determination module determines the entity pair extraction result of the medical text to be extracted based on the output result of the entity pair extraction model, and by filtering the data transmission between modules in the entity pair extraction model based on the negative sample labeling information, the technical problem of transmitting erroneous information during entity pair extraction is solved, thereby improving the accuracy of entity pair extraction.
[0148] Based on the above embodiment, optionally, the entity pair model extraction module 320 is specifically used for:
[0149] Inputting the to-be-extracted medical text into the entity recognition module to obtain entity recognition information output by the entity recognition module, wherein the entity recognition information includes entity segments and categories of the entity segments;
[0150] Inputting the entity recognition information into the entity pair matching module to obtain an entity pair output by the entity pair matching module;
[0151] Inputting the to-be-extracted medical text into the entity recognition module to obtain entity recognition information output by the entity recognition module, wherein the entity recognition information includes entity segments and categories of the entity segments;
[0152] Inputting the entity recognition information into the entity pair matching module to obtain an entity pair output by the entity pair matching module;
[0153] The entity pair is input into the relationship classification module, the relationship classification result output by the relationship classification module is obtained, and the relationship classification result is used as the output result of the entity pair extraction model.
[0154] Based on the above embodiment, optionally, the entity pair model extraction module 320 is specifically used for:
[0155] Based on the relationship classification module, the relationship category of each entity pair in the relationship classification result is determined by the following formula:
[0156] P(y x |x)=P([MASK]=γ(y x )|x prompt )=Softmax(W lm ·h [mask] )
[0157] Among them, y x is the relationship type, x prompt To splice the input information with prompt information, W lm is the parameter matrix, h [mask] Represents x prompt The text of [MASK] represents a vector, h represents the mapping from relationship type to predicted word, and Softmax is the activation function.
[0158] Based on the above embodiment, optionally, the entity pair model extraction module 320 is specifically used for:
[0159] Inputting the medical text to be extracted into the boundary detection layer to obtain entity segments output by the boundary detection layer;
[0160] The entity fragment is input into the entity type classification layer to obtain the category of the entity fragment output by the entity type classification layer.
[0161] Based on the above embodiment, optionally, the entity pair model extraction module 320 is specifically used for:
[0162] Based on the boundary detection layer Determine the starting position probability of each candidate segment in the medical text to be extracted, by Determine the end position probability of each candidate segment in the medical text to be extracted, where: represents the starting position probability of each candidate segment in the input information, represents the end position probability of each candidate segment in the input information, W start , W end is the weight parameter, b start , b end is the bias parameter, X i is the text representation calculated by the encoder, and Sigmoid is the activation function;
[0163] Obtaining an entity segment in the candidate segment determined based on the probability of the starting position and the probability of the ending position output by the boundary detection layer;
[0164] Based on the entity type classification layer, the predicted probability distribution of entity type is determined by the following formula: e(s)=F(e i ,e i+1 ,...,e i+k ), Among them, e i It represents the dense vector representation of the entity fragment after passing through the Bert encoder, and F is the maximum pooling function. Represents the predicted probability distribution of entity type, and Softmax is a nonlinear transformation function;
[0165] The entity type classification outputs a category of an entity fragment determined based on a predicted probability distribution of the entity type.
[0166] Based on the above embodiment, optionally, the entity pair model extraction module 320 is specifically used for:
[0167] Filtering the entity fragments in the entity identification information according to the types of the entity fragments in the entity identification information;
[0168] The entity recognition information corresponding to the filtered entity fragments is input into the entity pair matching module.
[0169] Based on the above embodiment, optionally, the entity pair model extraction module 320 is specifically used for:
[0170] The entity pair matching module generates the entity pairs according to set rules based on a predefined medical relationship dictionary.
[0171] Based on the above embodiment, optionally, the entity pair model extraction module 320 is specifically used for:
[0172] Determining the relationship category of each entity pair in the relationship classification result;
[0173] The entity pairs in the relationship classification results are screened based on the relationship categories, and the relationship classification results corresponding to the screened entity pairs are used as output results of the entity pair extraction model.
[0174] Based on the above embodiment, optionally, the relationship classification module is constructed based on a pre-trained mask language model front end.
[0175] The device for extracting medical text entity pairs provided in the embodiment of the present invention can execute the method for extracting medical text entity pairs provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0176] Embodiment 4
[0177] Figure 4 1 is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0178] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0179] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0180] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a method for extracting medical text entity pairs.
[0181] In some embodiments, the method for extracting medical text entity pairs can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for extracting medical text entity pairs described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the method for extracting medical text entity pairs in any other appropriate manner (for example, by means of firmware).
[0182] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0183] The computer program for implementing the method for extracting medical text entity pairs of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine as an independent software package and partially on a remote machine, or entirely on a remote machine or server.
[0184] Embodiment 5
[0185] Embodiment 5 of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to execute a method for extracting medical text entity pairs, the method comprising:
[0186] Obtain the medical text to be extracted;
[0187] Inputting the medical text to be extracted into a pre-trained entity pair extraction model, and obtaining an output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module, and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample labeling information corresponding to the sample medical text, and the sample labeling information includes positive sample labeling information and negative sample labeling information, and the negative sample labeling information is used to filter the transmission data between modules;
[0188] The entity pair extraction result of the medical text to be extracted is determined based on the output result of the entity pair extraction model.
[0189] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0190] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0191] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0192] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0193] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0194] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for extracting entity pairs from medical texts, characterized in that: include: Obtain the medical text to be extracted; Inputting the medical text to be extracted into a pre-trained entity pair extraction model, and obtaining an output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module, and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample labeling information corresponding to the sample medical text, and the sample labeling information includes positive sample labeling information and negative sample labeling information, and the negative sample labeling information is used to filter the transmission data between modules; The entity pair extraction result of the medical text to be extracted is determined based on the output result of the entity pair extraction model.
2. The method according to claim 1, characterized in that The step of inputting the to-be-extracted medical text into a pre-trained entity pair extraction model to obtain an output result of the entity pair extraction model comprises: Inputting the to-be-extracted medical text into the entity recognition module to obtain entity recognition information output by the entity recognition module, wherein the entity recognition information includes entity segments and categories of the entity segments; Inputting the entity recognition information into the entity pair matching module to obtain an entity pair output by the entity pair matching module; The entity pair is input into the relationship classification module, the relationship classification result output by the relationship classification module is obtained, and the output result of the entity pair extraction model is determined based on the relationship classification result.
3. The method according to claim 2, characterized in that The step of inputting the entity pair into the relationship classification module to obtain the relationship classification result output by the relationship classification module includes: Based on the relationship classification module, the relationship category of each entity pair in the relationship classification result is determined by the following formula: P(y x |x)=P([MASK]=γ(y x )|x prompt )=Softmax(W lm ·h [mask] ): Among them, y x is the relationship type, x prompt To splice the input information with prompt information, W lm is the parameter matrix, h [mask] Represents x prompt The text of [MASK] represents a vector, h represents the mapping from relationship type to predicted word, and Softmax is the activation function.
4. The method according to claim 2, characterized in that: The entity recognition module includes a boundary detection layer and an entity type classification layer. The step of inputting the to-be-extracted medical text into the entity recognition module and obtaining entity recognition information output by the entity recognition module includes: Inputting the medical text to be extracted into the boundary detection layer to obtain entity segments output by the boundary detection layer; The entity fragment is input into the entity type classification layer to obtain the category of the entity fragment output by the entity type classification layer.
5. The method according to claim 4, characterized in that The step of inputting the to-be-extracted medical text into the boundary detection layer to obtain entity segments output by the boundary detection layer, and inputting the entity segments into the entity type classification layer to obtain the categories of the entity segments output by the entity type classification layer comprises: Based on the boundary detection layer Determine the starting position probability of each candidate segment in the medical text to be extracted, by Determine the end position probability of each candidate segment in the medical text to be extracted, where: represents the starting position probability of each candidate segment in the input information, represents the end position probability of each candidate segment in the input information, W start , W end is the weight parameter, b start 、b end is the bias parameter, X i is the text representation calculated by the encoder, and Sigmoid is the activation function; Obtaining an entity segment in the candidate segment determined based on the probability of the starting position and the probability of the ending position output by the boundary detection layer; Based on the entity type classification layer, the entity type prediction probability distribution is determined by the following formula: Among them, e i represents the dense vector representation of the entity fragment after passing through the Bert encoder, F is the maximum pooling function, Represents the predicted probability distribution of entity type, and Softmax is a nonlinear transformation function; The entity type classification outputs a category of an entity fragment determined based on a predicted probability distribution of the entity type.
6. The method according to claim 3, characterized in that The inputting the entity recognition information into the entity pair matching module comprises: Filtering the entity fragments in the entity identification information according to the types of the entity fragments in the entity identification information; The entity recognition information corresponding to the filtered entity fragments is input into the entity pair matching module.
7. The method according to claim 2, characterized in that The step of inputting the entity recognition information into the entity pair matching module to obtain the entity pair output by the entity pair matching module includes: The entity pair matching module generates the entity pairs according to set rules based on a predefined medical relationship dictionary.
8. The method according to claim 2, characterized in that: The determining the output result of the entity pair extraction model based on the relationship classification result includes: Determining the relationship category of each entity pair in the relationship classification result; The entity pairs in the relationship classification results are screened based on the relationship categories, and the relationship classification results corresponding to the screened entity pairs are used as output results of the entity pair extraction model.
9. The method according to claim 1, characterized in that: The relation classification module is built based on a pre-trained masked language model front end.
10. A device for extracting entity pairs from medical texts, characterized in that: include: A medical text acquisition module is used to acquire the medical text to be extracted; An entity pair model extraction module, used for inputting the medical text to be extracted into a pre-trained entity pair extraction model to obtain an output result of the entity pair extraction model, wherein the entity pair extraction model includes an entity recognition module, an entity pair matching module and a relationship classification module, and the model training sample of the entity pair extraction model includes a sample medical text and sample labeling information corresponding to the sample medical text, the sample labeling information includes positive sample labeling information and negative sample labeling information, and the negative sample labeling information is used for filtering the transmission data between modules; The entity pair extraction result determination module is used to determine the entity pair extraction result of the medical text to be extracted based on the output result of the entity pair extraction model.
