Entity recognition method and apparatus, electronic device, and storage medium
By embedding entity recognition rules into the entity recognition model and combining finite automatic state machines and neural network training, the problem of low recognition accuracy when the sample size is insufficient is solved, and efficient named entity recognition in medical texts is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-26
- Publication Date
- 2026-04-07
AI Technical Summary
Existing technologies for named entity recognition in medical texts, especially when the sample size is small, have low model accuracy, which affects the accuracy of named entity recognition.
By embedding pre-built entity recognition rules into the entity recognition model, and using the transition rules of finite automatic state machines and tensor rank decomposition, combined with neural networks for training, the recognition accuracy of the model can be improved.
With a small sample size, the accuracy of the entity recognition model was improved, enhancing the performance of named entity recognition in medical texts.
Smart Images

Figure CN116205230B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of entity recognition, and particularly relates to an entity recognition method and device, an electronic device and a storage medium. BACKGROUND
[0002] In recent years, with the development of network and medical information technology, Internet medical treatment gradually emerges, and medical big data gradually emerges. Medical big data plays an important role in the medical industry. For the application of medical big data, the recognition of medical named entities in medical text is a basic work.
[0003] For the named entity recognition of medical text, a supervised method is usually used to train a recognition model, the medical text is taken as a sequence, and the recognition model is used to predict the label of each word or character in the sequence, so as to extract the entity in the text. However, this method often needs a large amount of labeled data to obtain good results, such as a statistical learning scheme based on conditional random field (CRF). When the sample size is small, the accuracy of the trained model is low, thereby affecting the accuracy of the named entity recognition in the medical text. SUMMARY
[0004] Based on the defects and deficiencies of the prior art, the present application provides an entity recognition method, device, electronic device and storage medium, which can improve the accuracy of named entity recognition in medical text.
[0005] According to a first aspect of an embodiment of the present application, an entity recognition method is provided, comprising:
[0006] inputting a to-be-recognized text into a pre-trained entity recognition model to obtain an entity label corresponding to the to-be-recognized text;
[0007] The entity recognition model is obtained by at least embedding a pre-constructed entity recognition rule into a first training sample matched with the entity recognition rule, and performing entity recognition training by using the first training sample embedded with the entity recognition rule. The first training sample matched with the entity recognition rule includes a text sample capable of recognizing an entity in the sample by using the entity recognition rule.
[0008] Optionally, the entity recognition model is obtained by embedding the pre-constructed entity recognition rule into the first training sample matched with the entity recognition rule, and performing entity recognition training by using the first training sample embedded with the entity recognition rule, comprising:
[0009] embedding the pre-constructed entity recognition rule into a sample feature corresponding to the first training sample matched with the pre-constructed entity recognition rule to obtain an input feature corresponding to the first training sample;
[0010] The input features are fed into a neural network for entity recognition to obtain the output label corresponding to the first training sample.
[0011] Based on the sample label and output label corresponding to the first training sample determined using the entity recognition rules, the network parameters of the neural network are adjusted to obtain the entity recognition model.
[0012] Optionally, the step of the neural network performing entity recognition on the input features corresponding to the first training sample includes:
[0013] The input features corresponding to the first training sample are encoded to obtain the encoded features corresponding to the first training sample.
[0014] Based on the attention mechanism, the encoding features corresponding to each character in the first training sample are combined with the encoding features corresponding to other characters in the first training sample to determine the attention encoding features corresponding to each character in the first training sample.
[0015] Based on the attention encoding features corresponding to the first training sample, predict the output label corresponding to the first training sample.
[0016] Optionally, a pre-built entity recognition rule is embedded into the sample features corresponding to a first training sample that matches the pre-built entity recognition rule to obtain the input features corresponding to the first training sample, including:
[0017] Based on the transition rules of finite automatic state machines, the pre-constructed entity recognition rules are characterized to obtain rule features containing the entity recognition rules;
[0018] Extract the sample features corresponding to the first training sample that matches the entity recognition rule;
[0019] The rule features are fused with the sample features corresponding to the first training sample to obtain the input features corresponding to the first training sample.
[0020] Optionally, based on the transition rules of a finite automatic state machine, the pre-built entity recognition rules are characterized to obtain rule features containing the entity recognition rules, including:
[0021] Based on the transition rules of finite automatic state machines, the pre-built entity recognition rules are converted into corresponding rule tensors;
[0022] Perform tensor rank decomposition on the rule tensor, and use the decomposed rule matrix as the rule feature containing the entity recognition rule.
[0023] Optionally, based on the transition rules of a finite automatic state machine, the pre-built entity recognition rules are converted into corresponding rule tensors, including:
[0024] Based on the transition rules of finite automatic state machines, the pre-built entity recognition rules are converted into corresponding finite automatic state machines;
[0025] By using tensor dimensionality reduction, the finite automaton is transformed into an independent finite automaton, and the tensor corresponding to the independent finite automaton is used as the rule tensor corresponding to the pre-constructed entity recognition rule.
[0026] Optionally, the training process of the entity recognition model further includes:
[0027] Obtain medical text and corresponding annotation tags for the medical text, wherein the annotation tags include entity annotation tags;
[0028] The medical text is input into the entity recognition model to obtain the output label corresponding to the medical text. The output label includes at least the labels of the entities identified from the medical text.
[0029] The entity recognition model parameters are adjusted based on the annotation labels and output labels corresponding to the medical text.
[0030] According to a second aspect of the embodiments of this application, an entity recognition device is provided, comprising:
[0031] The label recognition module is used to input the text to be recognized into a pre-trained entity recognition model to obtain the entity label corresponding to the text to be recognized.
[0032] The entity recognition model is obtained by embedding a pre-built entity recognition rule into a first training sample that matches the entity recognition rule, and then using the first training sample after embedding the entity recognition rule to perform entity recognition training. The first training sample that matches the entity recognition rule includes text samples that can recognize entities in the sample by the entity recognition rule.
[0033] According to a third aspect of the embodiments of this application, an electronic device is provided, including: a memory and a processor;
[0034] The memory is connected to the processor and is used to store programs;
[0035] The processor is used to implement the above-described entity recognition method by running the program in the storage device.
[0036] According to a fourth aspect of the embodiments of this application, a storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, it implements the above-described entity recognition method.
[0037] The entity recognition method proposed in this application includes: inputting the text to be recognized into a pre-trained entity recognition model to obtain entity labels corresponding to the text to be recognized; wherein, the entity recognition model is obtained at least by embedding pre-constructed entity recognition rules into a first training sample that matches the entity recognition rules, and by using the first training sample after embedding the entity recognition rules for entity recognition training, wherein the first training sample that matches the entity recognition rules includes text samples that can recognize entities in the sample through the entity recognition rules. By adopting the technical solution of this application, pre-constructed entity recognition rules can be integrated into the entity recognition model, and the entity recognition rules can achieve high recognition results even with a small number of samples. Therefore, the entity recognition model incorporating entity recognition rules can improve the accuracy of the entity recognition model, thereby improving the accuracy of named entity recognition for medical texts. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0039] Figure 1 This is a flowchart illustrating an entity recognition method provided in an embodiment of this application;
[0040] Figure 2 This is a schematic diagram of a processing flow for training an entity recognition model provided in an embodiment of this application;
[0041] Figure 3 This is a flowchart illustrating the processing of the training entity recognition model provided in an embodiment of this application;
[0042] Figure 4 This is an example diagram of the form of the finite automatic state machine corresponding to the entity recognition rules provided in the embodiments of this application;
[0043] Figure 5 This is an example diagram of a finite automatic state machine corresponding to an entity recognition rule, which is provided in the embodiments of this application for text that matches the entity recognition rule.
[0044] Figure 6 This is a schematic diagram of the neural network structure provided in the embodiments of this application;
[0045] Figure 7 This is a schematic diagram of another processing flow for training an entity recognition model provided in an embodiment of this application;
[0046] Figure 8 This is a schematic diagram of the structure of an entity recognition device provided in an embodiment of this application;
[0047] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0048] The technical solutions of this application are applicable to entity recognition scenarios, especially to applications involving named entity recognition in medical texts. By employing the technical solutions of this application, the accuracy of entity recognition models can be improved, thereby enhancing the accuracy of named entity recognition in medical texts.
[0049] With the rapid development of the information society, big data has become a strategic resource as important as natural resources. The medical field generates massive amounts of data daily, leading to the emergence of medical big data. In the healthcare industry, the research and application of medical big data can effectively improve diagnostic accuracy, reduce doctor-patient conflicts, conserve medical resources, and improve the quality of medical care. One of the prerequisites and foundations for the research and application of medical big data is the identification of named entities in medical texts. Identifying relevant entities in medical texts is the fundamental work for the application of medical big data. Medical named entity recognition refers to identifying entities with specific meanings within medical texts.
[0050] For named entity recognition in medical texts, supervised training methods are typically used to train the recognition model. The medical text is treated as a sequence, and the model predicts the label for each character or word in the sequence to extract the entities. However, this method often requires a large amount of labeled data to achieve good results, such as statistical learning schemes based on Conditional Random Fields (CRFs). When the sample size is small, the accuracy of the trained model is low, thus affecting the accuracy of named entity recognition in medical texts.
[0051] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0052] This application proposes an entity recognition method, see [link to relevant documentation] Figure 1 As shown, the method includes:
[0053] S101. Input the text to be recognized into the pre-trained entity recognition model to obtain the entity label corresponding to the text to be recognized.
[0054] Specifically, for medical text requiring named entity recognition, this text is input into a pre-trained entity recognition model. The model identifies the entity labels corresponding to the text. Based on these labels, the corresponding entities are extracted from the text, representing the medical named entities within the text. Furthermore, when performing entity recognition on the text, the model can identify not only the entity labels but also non-entity labels, which correspond to non-entities within the text.
[0055] In this embodiment, the entity recognition model is obtained at least by embedding a pre-built entity recognition rule into a first training sample that matches the entity recognition rule, and then using the first training sample with the embedded entity recognition rule for entity recognition training. The first training sample that matches the entity recognition rule includes text samples that can identify entities in the sample using the entity recognition rule. For example, if the entity recognition rule is a regularization rule for "the doctor prescribed <medication>", then the first training sample that matches the entity recognition rule could include "the doctor prescribed aspirin". This first training sample can identify the entity in the sample using the entity recognition rule, that is, identify "aspirin" as the <medication> entity.
[0056] In this embodiment, the pre-constructed entity recognition rules can include multiple rules. The first training sample for training the entity recognition model can include training samples corresponding to each entity recognition rule. Each training sample is a text sample that matches its corresponding entity recognition rule and embeds that rule. By training the entity recognition model using these training samples, the entity recognition rules corresponding to these training samples can be integrated into the entity recognition model. This allows the entity recognition model to incorporate all the constructed entity recognition rules, enhancing its performance. Since entity recognition based on entity recognition rules can achieve relatively accurate entity recognition with a smaller sample size, integrating entity recognition rules into the entity recognition model allows it to achieve high accuracy even with limited training samples, thereby improving the accuracy of the entity recognition model and enhancing the accuracy of named entity recognition for medical text.
[0057] In this embodiment, the pre-built entity recognition rules can be manually formulated rules, rules determined based on historical recognition experience, or simply preset rules. The entity recognition rules are constructed based on online data and a medical text database. These rules can include dictionaries for pure text matching (e.g., fever, cough), rules containing reasoning logic (e.g., regular expressions), and grammatical rules based on keywords and their synonyms (e.g., rules for writing diarrhea and its synonyms, then unifying these words under the semantic meaning of diarrhea).
[0058] As described above, the entity recognition method proposed in this application involves inputting the text to be recognized into a pre-trained entity recognition model to obtain entity labels corresponding to the text. The entity recognition model is obtained at least by embedding pre-constructed entity recognition rules into first training samples that match the entity recognition rules, and then using these first training samples to train entity recognition. The first training samples that match the entity recognition rules include text samples that can recognize entities in the samples using the entity recognition rules. By adopting the technical solution of this application, pre-constructed entity recognition rules can be integrated into the entity recognition model. Since entity recognition rules can achieve high recognition performance even with a small number of samples, the entity recognition model incorporating entity recognition rules can improve the accuracy of the entity recognition model, thereby improving the accuracy of named entity recognition in medical texts.
[0059] As an optional implementation method, see [link to implementation details]. Figure 2 As shown, another embodiment of this application discloses a training process for an entity recognition model, which involves embedding pre-built entity recognition rules into a first training sample that matches the entity recognition rules, and then using the first training sample with the embedded entity recognition rules to train entity recognition and obtain an entity recognition model, including:
[0060] S201. Embed the pre-built entity recognition rules into the sample features corresponding to the first training sample that matches the pre-built entity recognition rules to obtain the input features corresponding to the first training sample.
[0061] Specifically, this embodiment can extract medical text from a medical database that can be identified by pre-built entity recognition rules as a first training sample. Then, it extracts the sample features corresponding to the first training sample, embeds the pre-built entity recognition rules into these features, and uses the resulting new features as the input features for the first training sample. Embedding the entity recognition rules into the sample features of the first training sample can be achieved by fusing the rule information of the entity recognition rules into the sample features of the first training sample. The specific steps are as follows:
[0062] First, based on the transition rules of finite automatic state machines, the pre-constructed entity recognition rules are represented to obtain rule features containing entity recognition rules.
[0063] To embed entity recognition rules into the first training sample, it is first necessary to extract the rule features of these rules. Existing technologies involve converting regularization rules into finite automata (FSTs), and FSTs can represent the corresponding regularization rules using tensors. This allows the extraction of the regularization rule information from the tensors of the FSTs. Therefore, this embodiment utilizes the transformation rules of a finite automata (FST) to characterize the pre-constructed entity recognition rules, thereby obtaining rule features containing the rule information corresponding to the entity recognition rules.
[0064] For example, when the entity recognition rule (RE) is "the doctor prescribed <medication>", the corresponding finite automatic state machine (FST) takes the form of: Figure 4 As shown, when qO, q1, and q2 all represent the states of a finite automaton (FST), and are also entities and non-entities in the entity recognition rule, when the first training sample corresponding to this entity recognition rule (RE) is "the doctor prescribed aspirin", the matching process of the entity recognition rule (RE) is as follows: match <aspirin> from the first training sample and determine its label as <drug>, as shown. Figure 5 As shown, the labels corresponding to q0 to q2 are all non-entity labels, i.e., 0; the label corresponding to q3 is an entity label, B-drug, which is the first character in the entity; and the labels corresponding to q4 to q6 are entity labels, I-drug. The matching process of the entity recognition rule (RE) can be seen from the state transitions of the finite automatic state machine (FST) transformed by the entity recognition rule (RE). Therefore, the rule information of the entity recognition rule (RE) can be extracted from the finite automatic state machine (FST) transformed by the entity recognition rule (RE).
[0065] The existing technology has already disclosed the method of converting regularization rules into finite automatic state machines (FSTs), so this embodiment will not elaborate on the conversion rules of finite automatic state machines.
[0066] Specifically, firstly, this embodiment converts the pre-built entity recognition rule (RE) into a corresponding rule tensor according to the transition rules of the finite automaton (FST). This rule tensor contains the rule information of the entity recognition rule (RE). Since directly representing a finite automaton (FST) requires at least a fourth-order tensor, where the input vocabulary size is V, the output tag set size is L (e.g., <drug> tag, <disease> tag, etc.), and the number of states of the FST is K, then the tensor representing the FST is a V*L*K*K tensor. This tensor can represent the transitions between states and the inputs and outputs during the transitions. However, the space complexity and number of parameters of a fourth-order tensor are relatively large. To reduce the inference space complexity and number of parameters of the state machine, based on the transition rules of the finite automaton, the specific steps for converting the pre-built entity recognition rule into the corresponding rule tensor can be as follows: Figure 3 As shown, the pre-built entity recognition rule (RE) is first converted into a finite automatic state machine (FST) based on the transformation rules of the finite automatic state machine. Then, the finite automatic state machine (FST) is converted into an independent finite automatic state machine (i-FST) using tensor dimensionality reduction. The tensor corresponding to the independent finite automatic state machine (i-FST) is then used as the rule tensor corresponding to the pre-built entity recognition rule.
[0067] Based on the conditional independence of the Independent Finite Automaton (i-FST), the i-FST has a lower dimensionality than the Finite Automaton (FST). It only requires a V*K*K third-order tensor to represent the state transition with the input, and a K*L matrix O to represent the correspondence between the reached state and the output label.
[0068] In this embodiment, after converting the entity recognition rules into corresponding rule tensors, to reduce the time complexity of the finite automatic state machine (FST) inference, it is necessary to perform tensor rank decomposition on the rule tensors and use the decomposed matrices to replace the previous tensors to represent the entity recognition rules. Since the rule tensor is a third-order tensor, tensor rank decomposition of the rule tensor can be decomposed into three matrices E. R D S D E ,in, v t =E R [x t ]、 Where xt Let v represent the input at time t, which is the t-th character in the first training sample. In this embodiment, the decomposed matrix v t As a rule matrix, this rule matrix serves as the rule feature containing rule information for entity recognition rules. The formula for the tensor rank decomposition described above is an existing tensor rank decomposition method, and will not be elaborated upon in this embodiment.
[0069] Second, extract the sample features corresponding to the first training sample that matches the entity recognition rules.
[0070] This embodiment needs to extract the sample features corresponding to the first training sample that matches the entity recognition rule. These sample features can be represented by word vectors such as word2vec and BERT.
[0071] Third, the rule features are fused with the sample features corresponding to the first training sample to obtain the input features corresponding to the first training sample.
[0072] To embed entity recognition rules into the first training sample, the rule features corresponding to the entity recognition rules need to be fused with the sample features corresponding to the first training sample to obtain the input features corresponding to the first training sample. During the fusion process, a rule embedding ratio needs to be set, and the rule features and sample features are fused according to this ratio. For example:
[0073] v t0 =ηE R [x t ]+(1-η)u t ·G
[0074] Among them, v t E represents the fused input features. R [x t ] represents a rule feature, u t ·G represents the sample features of the first training sample, and η represents the rule embedding ratio.
[0075] S202. Input the input features into the neural network for entity recognition to obtain the output label corresponding to the first training sample.
[0076] Specifically, the input features obtained by embedding entity recognition rules into the first training sample are input into the neural network so that the neural network can perform entity recognition on the input features and output the output label corresponding to the first training sample. The output label includes entity labels and may also include non-entity labels. The label can adopt a BIO structure, where O represents a non-entity label, and B and I both represent entity labels, with B representing the label of the first character in the entity.
[0077] Furthermore, the steps for the neural network to perform entity recognition on the input features corresponding to the first training sample include:
[0078] First, the input features corresponding to the first training sample are encoded to obtain the encoded features corresponding to the first training sample.
[0079] After the input features corresponding to the first training sample are input into the neural network, the encoding network in the neural network can encode these input features to obtain the encoded features corresponding to the first training sample. For example... Figure 6 As shown, f1 to f5 are the input features that fuse the sample features of the first training sample with the rule features of the entity recognition rule (RE), and h1 to h5 are the encoded features after encoding the input features. In this embodiment, the encoding network can be a BiLSTM network, or it can be a GRU network, a CNN network, a Transformer, etc.
[0080] Second, based on the attention mechanism, the encoding features corresponding to each character in the first training sample are combined with the encoding features corresponding to other characters in the first training sample to determine the attention encoding features corresponding to each character in the first training sample.
[0081] To account for the influence of other characters globally on the current character, this embodiment utilizes an attention mechanism. It combines the encoding features of each character in the first training sample with the encoding features of other characters in the same first training sample to determine the attention encoding features for each character in the first training sample, thereby achieving contextual integration. The specific formula is as follows:
[0082]
[0083]
[0084] Among them, S pi h represents the attention encoding feature of the i-th character. j α represents the encoding feature of the j-th character. pik h represents the attention score of the j-th character to the i-th character. i W represents the encoding feature of the i-th character. sp This represents the preset weight matrix.
[0085] like Figure 6 As shown, s1 to s5 are the attention encoding features corresponding to each character in the first training sample.
[0086] Third, based on the attention encoding features corresponding to the first training sample, predict the output label corresponding to the first training sample.
[0087] After the neural network determines the attention-encoded features corresponding to the first training sample, these features need to be input into a softmax classifier. This allows the softmax classifier to predict the probability of character labels based on the attention-encoded features, thereby determining the output label for each character in the first training sample. The formula for the softmax classifier to predict the output label based on the attention-encoded features is as follows:
[0088] p i =softmax(W p [S pi ;hi ] +b p )
[0089] Among them, W p b represents the weight matrix of the activation layer (i.e., the softmax classifier). p This represents the bias term of the activation layer (i.e., the softmax classifier).
[0090] S203. Based on the sample label and output label corresponding to the first training sample determined using entity recognition rules, adjust the network parameters of the neural network to obtain the entity recognition model.
[0091] Specifically, since the first training sample matches the entity recognition rule—meaning the entity in the first training sample can be identified by the entity recognition rule—this embodiment needs to perform entity recognition on the first training sample based on the entity recognition rule to determine the sample label corresponding to the first training sample. The sample label corresponding to the first training sample includes entity labels and may also include non-entity labels. This embodiment can calculate the cross-entropy loss function between the sample label corresponding to the first training sample and the output label corresponding to the first training sample output by the neural network. Based on this cross-entropy loss function, the network parameters of the neural network are adjusted to train the neural network. Training of the neural network ends when the cross-entropy loss function meets the loss range, and the final neural network is used as the entity recognition model.
[0092] As an optional implementation method, see [link to implementation details]. Figure 7 As shown in another embodiment of this application, the training process of the entity recognition model further includes the following steps:
[0093] S701. Obtain the medical text and the corresponding annotation tags for the medical text.
[0094] Specifically, this embodiment can obtain medical texts from scientific and educational literature guidelines, electronic medical records, medical textbooks, medical guidelines, medical reports, etc., and manually annotate the obtained medical texts to obtain corresponding annotation tags. The medical texts and their corresponding annotation tags are then combined to form a medical resource dataset. The annotation tags corresponding to the medical texts include entity annotation tags, and may also include non-entity annotation tags.
[0095] For example, a medical resource dataset includes: medical text (x1, ..., x...). n Label (y1, ..., y) n ), where x1, ..., x n This represents each word in the medical text, y1, ..., y n These represent the annotation labels corresponding to each word in a medical text.
[0096] For medical text annotation, the BIO annotation method can be used. For example, for the medical text "The doctor prescribed aspirin", if we want to identify the drug entity in the text, we can annotate it as "OOOOOB-drugI-drugI-drug". That is, the first character of the entity is annotated as B plus the entity type, the middle and end of the entity are all annotated as I plus the entity type, and the rest are annotated as O.
[0097] S702. Input the medical text into the entity recognition model to obtain the output label corresponding to the medical text.
[0098] Specifically, the acquired medical text is input into an entity recognition model that incorporates entity recognition rules, and the output labels corresponding to the medical text are obtained from the entity recognition model. The output labels corresponding to the medical text include at least labels of entities identified from the medical text, and may also include labels of non-entity entities.
[0099] S703. Adjust the model parameters of the entity recognition model based on the annotation labels and output labels corresponding to the medical text.
[0100] Specifically, this embodiment can calculate the cross-entropy loss function between the annotation label corresponding to the medical text and the output label corresponding to the medical text, and adjust the model parameters of the entity recognition model according to the cross-entropy loss function, thereby improving the accuracy of the entity recognition model.
[0101] Because the entity recognition model in this embodiment learns pre-built entity recognition rules, it achieves good training results even with a small number of labeled samples when performing entity recognition on medical text based on these rules. This embodiment can also train the entity recognition model incorporating entity recognition rules using a large number of labeled samples. This further improves the accuracy of the entity recognition model when the number of labeled samples is large, ensuring that the final model achieves good entity recognition performance on both data-scarce and data-rich samples, effectively enhancing the model's adaptability to different scenarios and data types.
[0102] Corresponding to the entity recognition method described above, this application also proposes an entity recognition device, see [link to relevant documentation]. Figure 8 As shown, the device includes:
[0103] The label recognition module 100 is used to input the text to be recognized into a pre-trained entity recognition model to obtain the entity label corresponding to the text to be recognized.
[0104] The entity recognition model is obtained by embedding pre-built entity recognition rules into a first training sample that matches the entity recognition rules, and then using the first training sample after embedding the entity recognition rules for entity recognition training. The first training sample that matches the entity recognition rules includes text samples that can identify entities in the sample by the entity recognition rules.
[0105] The entity recognition device proposed in this application includes a label recognition module 100 that inputs the text to be recognized into a pre-trained entity recognition model to obtain entity labels corresponding to the text. The entity recognition model is obtained at least by embedding pre-constructed entity recognition rules into first training samples that match the entity recognition rules, and then using these first training samples to train entity recognition. The first training samples that match the entity recognition rules include text samples that can recognize entities within the samples using the entity recognition rules. By adopting the technical solution of this application, pre-constructed entity recognition rules can be integrated into the entity recognition model. Since entity recognition rules can achieve high recognition performance even with a small number of samples, the entity recognition model incorporating entity recognition rules can improve the accuracy of the entity recognition model, thereby improving the accuracy of named entity recognition for medical texts.
[0106] As an optional implementation, another embodiment of this application also discloses that the entity recognition device further includes: a rule embedding module, a network recognition module, and a first parameter adjustment module.
[0107] The rule embedding module is used to embed pre-built entity recognition rules into the sample features corresponding to the first training sample that matches the pre-built entity recognition rules, so as to obtain the input features corresponding to the first training sample.
[0108] The network recognition module is used to input the input features into the neural network to perform entity recognition and obtain the output label corresponding to the first training sample.
[0109] The first parameter adjustment module is used to adjust the network parameters of the neural network according to the sample label and output label corresponding to the first training sample determined by the entity recognition rules, so as to obtain the entity recognition model.
[0110] As an optional implementation, another embodiment of this application also discloses that the step of the neural network performing entity recognition on the input features corresponding to the first training sample includes:
[0111] The input features corresponding to the first training sample are encoded to obtain the encoded features corresponding to the first training sample.
[0112] Based on the attention mechanism, the encoding features corresponding to each character in the first training sample are combined with the encoding features corresponding to other characters in the first training sample to determine the attention encoding features corresponding to each character in the first training sample.
[0113] Based on the attention encoding features corresponding to the first training sample, predict the output label corresponding to the first training sample.
[0114] As an optional implementation, another embodiment of this application also discloses that the rule embedding module includes: a rule representation unit, a sample feature extraction unit, and a feature fusion unit.
[0115] The rule representation unit is used to represent pre-built entity recognition rules based on the transition rules of finite automatic state machines, and obtain rule features containing entity recognition rules.
[0116] The sample feature extraction unit is used to extract the sample features corresponding to the first training sample that matches the entity recognition rule.
[0117] The feature fusion unit is used to fuse the rule features with the sample features corresponding to the first training sample to obtain the input features corresponding to the first training sample.
[0118] As an optional implementation, another embodiment of this application also discloses a rule characterization unit, specifically used for:
[0119] Based on the transition rules of finite automatic state machines, the pre-built entity recognition rules are converted into corresponding rule tensors;
[0120] Perform tensor rank decomposition on the rule tensor, and use the decomposed rule matrix as the rule features containing entity recognition rules.
[0121] As an optional implementation, another embodiment of this application also discloses that the rule representation unit, based on the transition rules of a finite automatic state machine, converts pre-built entity recognition rules into corresponding rule tensors, including:
[0122] Based on the transition rules of finite automatic state machines, the pre-built entity recognition rules are converted into corresponding finite automatic state machines;
[0123] By using tensor dimensionality reduction, a finite automaton is transformed into an independent finite automaton, and the tensor corresponding to the independent finite automaton is used as the rule tensor corresponding to the pre-built entity recognition rule.
[0124] As an optional implementation, another embodiment of this application also discloses that the entity recognition device further includes: an acquisition module, an input module, and a second parameter adjustment module.
[0125] The acquisition module is used to acquire medical text and the corresponding annotation tags for the medical text, including entity annotation tags;
[0126] The input module is used to input medical text into the entity recognition model and obtain the output label corresponding to the medical text. The output label includes at least the label of the entity recognized from the medical text.
[0127] The second parameter adjustment module is used to adjust the model parameters of the entity recognition model based on the annotation labels and output labels corresponding to the medical text.
[0128] The entity recognition device provided in this embodiment belongs to the same concept as the entity recognition method provided in the above embodiments of this application. It can execute the entity recognition method provided in any of the above embodiments of this application and has the corresponding functional modules and beneficial effects for executing the entity recognition method. Technical details not described in detail in this embodiment can be found in the specific processing content of the entity recognition method provided in the above embodiments of this application, and will not be repeated here.
[0129] Another embodiment of this application also provides an electronic device, see [link to relevant documentation] Figure 7 As shown, the device includes:
[0130] Memory 200 and processor 210;
[0131] The memory 200 is connected to the processor 210 and is used to store programs;
[0132] The processor 210 is configured to implement the entity recognition method disclosed in any of the above embodiments by running the program stored in the memory 200.
[0133] Specifically, the aforementioned electronic device may also include: a bus, a communication interface 220, an input device 230, and an output device 240.
[0134] The processor 210, memory 200, communication interface 220, input device 230, and output device 240 are interconnected via a bus. Among them:
[0135] A bus can include a pathway for transmitting information between various components of a computer system.
[0136] The processor 210 can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program of the present invention. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0137] Processor 210 may include a main processor, as well as a baseband chip, modem, etc.
[0138] The memory 200 stores a program that executes the technical solution of this invention, and may also store an operating system and other key business functions. Specifically, the program may include program code, which includes computer operation instructions. More specifically, the memory 200 may include read-only memory (ROM), other types of static storage devices capable of storing static information and instructions, random access memory (RAM), other types of dynamic storage devices capable of storing information and instructions, disk storage, flash memory, etc.
[0139] Input device 230 may include a device for receiving user input data and information, such as a keyboard, mouse, camera, scanner, light pen, voice input device, touch screen, pedometer, or gravity sensor.
[0140] Output device 240 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.
[0141] The communication interface 220 may include a device that uses any transceiver to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.
[0142] The processor 210 executes the program stored in the memory 200 and calls other devices, which can be used to implement the various steps of any entity recognition method provided in the above embodiments of this application.
[0143] Another embodiment of this application provides a storage medium storing a computer program, which, when executed by a processor, implements the various steps of the entity recognition method provided in any of the above embodiments.
[0144] For the foregoing method embodiments, in order to simplify the description, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0145] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For apparatus embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0146] The steps in the methods of the various embodiments of this application can be adjusted, merged, or deleted in order according to actual needs, and the technical features described in each embodiment can be replaced or combined.
[0147] The modules and sub-modules in the various embodiments of the present application's devices and terminals can be merged, divided, and deleted according to actual needs.
[0148] It should be understood that the disclosed terminals, devices, and methods can be implemented in other ways, given the several embodiments provided in this application. For example, the terminal embodiments described above are merely illustrative. For instance, the division of modules or sub-modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple sub-modules or modules may be combined or integrated into another module, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.
[0149] The modules or submodules described as separate components may or may not be physically separate. The components that constitute a module or submodule may or may not be physical modules or submodules; that is, they may be located in one place or distributed across multiple network modules or submodules. Some or all of the modules or submodules can be selected to achieve the purpose of this embodiment's solution, depending on actual needs.
[0150] Furthermore, the functional modules or sub-modules in the various embodiments of this application can be integrated into one processing module, or each module or sub-module can exist physically separately, or two or more modules or sub-modules can be integrated into one module. The integrated modules or sub-modules described above can be implemented in hardware or in the form of software functional modules or sub-modules.
[0151] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0152] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software unit executed by a processor, or a combination of both. The software unit can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0153] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0154] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An entity recognition method, characterized in that, include: The text to be identified is input into a pre-trained entity recognition model to obtain the entity label corresponding to the text to be identified; The entity recognition model is obtained by embedding a pre-built entity recognition rule into a first training sample that matches the entity recognition rule, and then using the first training sample after embedding the entity recognition rule to perform entity recognition training. The first training sample that matches the entity recognition rule includes text samples that can recognize entities in the sample by the entity recognition rule. An entity recognition model is obtained by embedding a pre-constructed entity recognition rule into a first training sample that matches the entity recognition rule, and then using the first training sample with the embedded entity recognition rule to train entity recognition, including: Based on the transition rules of the finite automatic state machine, the pre-constructed entity recognition rules are represented to obtain rule features containing the entity recognition rules. The rule features are then embedded into the sample features corresponding to the first training sample that matches the pre-constructed entity recognition rules to obtain the input features corresponding to the first training sample. The input features are fed into a neural network for entity recognition to obtain the output label corresponding to the first training sample. Based on the sample label and output label corresponding to the first training sample determined using the entity recognition rules, the network parameters of the neural network are adjusted to obtain the entity recognition model.
2. The method according to claim 1, characterized in that, The steps of the neural network performing entity recognition on the input features corresponding to the first training sample include: The input features corresponding to the first training sample are encoded to obtain the encoded features corresponding to the first training sample. Based on the attention mechanism, the encoding features corresponding to each character in the first training sample are combined with the encoding features corresponding to other characters in the first training sample to determine the attention encoding features corresponding to each character in the first training sample. Based on the attention encoding features corresponding to the first training sample, predict the output label corresponding to the first training sample.
3. The method according to claim 1, characterized in that, The rule features are embedded into the sample features corresponding to a first training sample that matches a pre-constructed entity recognition rule to obtain the input features corresponding to the first training sample, including: Extract the sample features corresponding to the first training sample that matches the entity recognition rule; The rule features are fused with the sample features corresponding to the first training sample to obtain the input features corresponding to the first training sample.
4. The method according to claim 1, characterized in that, Based on the transition rules of a finite automatic state machine, pre-constructed entity recognition rules are characterized to obtain rule features containing the entity recognition rules, including: Based on the transition rules of finite automatic state machines, the pre-built entity recognition rules are converted into corresponding rule tensors; Perform tensor rank decomposition on the rule tensor, and use the decomposed rule matrix as the rule feature containing the entity recognition rule.
5. The method according to claim 4, characterized in that, Based on the transition rules of finite automatic state machines, pre-built entity recognition rules are converted into corresponding rule tensors, including: Based on the transition rules of finite automatic state machines, the pre-built entity recognition rules are converted into corresponding finite automatic state machines; By using tensor dimensionality reduction, the finite automaton is transformed into an independent finite automaton, and the tensor corresponding to the independent finite automaton is used as the rule tensor corresponding to the pre-constructed entity recognition rule.
6. The method according to claim 1, characterized in that, The training process of the entity recognition model also includes: Obtain medical text and corresponding annotation tags for the medical text, wherein the annotation tags include entity annotation tags; The medical text is input into the entity recognition model to obtain the output label corresponding to the medical text. The output label includes at least the labels of the entities identified from the medical text. The entity recognition model parameters are adjusted based on the annotation labels and output labels corresponding to the medical text.
7. An entity recognition device, characterized in that, include: The label recognition module is used to input the text to be recognized into a pre-trained entity recognition model to obtain the entity label corresponding to the text to be recognized. The entity recognition model is obtained by embedding a pre-built entity recognition rule into a first training sample that matches the entity recognition rule, and then using the first training sample after embedding the entity recognition rule to perform entity recognition training. The first training sample that matches the entity recognition rule includes text samples that can recognize entities in the sample by the entity recognition rule. An entity recognition model is obtained by embedding a pre-constructed entity recognition rule into a first training sample that matches the entity recognition rule, and then using the first training sample with the embedded entity recognition rule to train entity recognition, including: Based on the transition rules of the finite automatic state machine, the pre-constructed entity recognition rules are represented to obtain rule features containing the entity recognition rules. The rule features are then embedded into the sample features corresponding to the first training sample that matches the pre-constructed entity recognition rules to obtain the input features corresponding to the first training sample. The input features are fed into a neural network for entity recognition to obtain the output label corresponding to the first training sample. Based on the sample label and output label corresponding to the first training sample determined using the entity recognition rules, the network parameters of the neural network are adjusted to obtain the entity recognition model.
8. An electronic device, characterized in that, include: Memory and processor; The memory is connected to the processor and is used to store programs; The processor is configured to implement the entity recognition method as described in any one of claims 1 to 6 by running a program in the memory.
9. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the entity recognition method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Sensitive corpus detection method based on lexicon and word vector model
CN110727880A
Entity identification method and system, storage medium and equipment
CN112084746A