A method and device for training entity recognition model
By obtaining and using the model to train domain words and category tags in text, and combining the multi-head attention mechanism, the entity recognition model is trained, and the problem of difficulty in effectively utilizing domain knowledge in multiple business scenarios in the existing technology is solved, and the entity recognition effect is improved.
Patent Information
- Application Number
- CN202111594553.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-23
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2041-12-23
AI Technical Summary
The prior art is difficult to effectively utilize domain knowledge in multiple business scenarios, resulting in poor entity recognition effects of named entity recognition models in different scenarios.
By obtaining the domain word and category labels corresponding to each word in the model training text, and combining the multi-head attention mechanism, the initial entity recognition model is trained to generate the target entity recognition model.
The entity recognition effect of named entity recognition model in different scenarios has been improved, and the model's ability to utilize domain knowledge has been enhanced.
Smart Images

Figure CN114548095B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of model training technology, and in particular to a method and device for entity recognition model training. Background Art
[0002] Named Entity Recognition (NER) aims to identify entities with specific meanings in text (mainly including names of people, places, institutions, proper nouns, etc.); it is an important basic tool in application fields such as information extraction, question-answering systems, syntactic analysis, and machine translation, and occupies an important position in natural language processing (NLP) technology. In the Meituan search scenario, NER is the basic signal of the Deep Query Understanding (DQU) service, which is mainly used in search recall, user intent recognition, entity linking, etc. The quality of the NER signal directly affects the user's search experience.
[0003] The NER task in the search scenario has the following two characteristics: 1. It is necessary to identify a large number of domain-related entities, and the identification depends on domain-related knowledge. It is difficult to achieve good recognition results by relying solely on general semantic features. For example, "fish swimming" can be identified as a dish ingredient based on knowledge, but it is difficult to correctly identify its classification based on semantic features alone; 2. It is necessary to support many different business scenarios, and the knowledge and recognition modes of each business scenario are quite different. For example, "Jinbaiwan Roast Duck Wangjing Store" should be identified as a merchant name component in the store search scenario, and as a landmark component in the hotel search scenario.
[0004] Frontier methods mainly rely on pre-trained language models such as BERT (Bidirectional Encoder Representations from Transformers) to capture the semantic features of text, combined with deep neural networks to help improve recognition results. Faced with NER tasks that rely on a large amount of domain-related knowledge in multiple business scenarios, frontier methods find it difficult to make good use of domain knowledge, resulting in poor entity recognition results of neural networks in different scenarios. For example, when a user searches for "wash your hair" on Meituan, they need to query the chain store named "Mr.JUDY wash your hair"; the NER model based only on semantics will easily misidentify it as a component of the merchant category, resulting in other brands of shampoo merchants being ranked higher; and by integrating the domain knowledge of the merchant name, the NER model can identify "wash your hair" as the core component of the merchant name, so that the merchants of the chain brand can be accurately recalled and ranked higher, which can better meet user needs. Summary of the invention
[0005] Embodiments of the present disclosure provide an entity recognition model training method and device to improve the entity recognition effect of the entity recognition model in different scenarios.
[0006] According to a first aspect of an embodiment of the present disclosure, there is provided an entity recognition model training method, comprising:
[0007] Get model training text;
[0008] Based on a multi-domain knowledge base, obtaining a domain word corresponding to each character in the model training text;
[0009] Obtaining the word category label of each word in the model training text and the word category label of the domain word corresponding to each word;
[0010] Based on each character in the model training text, the domain word corresponding to each character, the character category label of each character and the word category label of the domain word corresponding to each character, the initial entity recognition model is trained to obtain a target entity recognition model.
[0011] Optionally, obtaining the domain word corresponding to each character in the model training text based on the multi-domain knowledge base includes:
[0012] Based on the multi-domain knowledge base, obtaining a first domain word with each character in the model training text as the head position, a second domain word with each character in the model training text as the middle position, and a third domain word with each character in the model training text as the tail position;
[0013] The first domain word, the second domain word and the third domain word are used as domain words corresponding to each character in the model training text.
[0014] Optionally, the initial entity recognition model is trained based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character to obtain the target entity recognition model, including:
[0015] Obtaining a word vector for each word in the model training text, a word vector for the domain word corresponding to each word, a word label vector for the word category label of each word, and a word label vector for the word category label of the domain word corresponding to each word;
[0016] The initial entity recognition model is trained based on the word vector of each character in the model training text, the word vector of the domain word corresponding to each character, the word label vector of the word category label of each character, and the word label vector of the word category label of the domain word corresponding to each character to obtain the target entity recognition model.
[0017] Optionally, the obtaining of the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word includes:
[0018] Calling the pre-trained model to process each character and the domain word corresponding to each character in the model training text to generate a character vector for each character and a word vector for the domain word corresponding to each character;
[0019] A multi-layer neural network is called to process the character category label of each character and the word category label of the domain word corresponding to each character, and a character label vector of each character category label and a word label vector of each word category label are generated.
[0020] Optionally, the initial entity recognition model includes: a multi-head attention mechanism layer, a feature fusion layer, a bidirectional long short-term memory network layer and a decoding layer, and the model training sample corresponds to the initial category label sequence, wherein,
[0021] The initial entity recognition model is trained based on the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word to obtain the target entity recognition model, including:
[0022] Inputting the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word into the initial entity recognition model;
[0023] Calling the multi-head attention mechanism layer to perform attention distribution processing on the word vector, the word vector, the word label vector and the word label vector to obtain the attention-enhanced target word vector, target word vector, target word label vector and target word label vector corresponding to the word vector, the word vector, the word label vector and the word label vector respectively;
[0024] Calling the feature fusion layer to perform splicing processing on the target character vector, the target word vector, the target character label vector and the target word label vector to obtain a splicing vector;
[0025] Calling the bidirectional long short-term memory network layer to process the concatenated vector to obtain a character encoding vector corresponding to each character in the model training text;
[0026] Calling the decoding layer to decode the word encoding vector to obtain a predicted category label sequence corresponding to the model training text;
[0027] Based on the initial category label sequence and the predicted category label sequence, a loss value corresponding to the initial entity recognition model is calculated;
[0028] When the loss value is within a preset range, the trained initial entity recognition model is used as the target entity recognition model.
[0029] Optionally, after the initial entity recognition model is trained based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character to obtain the target entity recognition model, the method further includes:
[0030] Get the text to be recognized;
[0031] Obtaining the target domain word corresponding to each character in the text to be recognized;
[0032] Obtaining a target word category label for each word in the to-be-recognized text and a target word category label for a target domain word corresponding to each word;
[0033] Input each character in the text to be recognized, the target domain word corresponding to each character, the target character category label of each character, and the target word category label of the target domain word corresponding to each character into the target entity recognition model;
[0034] Obtaining multiple category label sequences corresponding to the text to be recognized output by the target entity recognition model, and the prediction probability corresponding to each of the category label sequences;
[0035] Based on the predicted probability, a target label sequence from the multiple category label sequences is obtained, and the target label sequence is used as a category label recognition result of the text to be recognized.
[0036] Optionally, acquiring a target label sequence from the multiple category label sequences based on the predicted probability includes:
[0037] A category label sequence with the largest prediction probability among the multiple category label sequences is obtained, and the category label sequence with the largest prediction probability is used as the target label sequence.
[0038] According to a second aspect of an embodiment of the present disclosure, there is provided an entity recognition model training device, comprising:
[0039] Model training text acquisition module, used to obtain model training text;
[0040] A domain word acquisition module, used to acquire the domain word corresponding to each character in the model training text based on a multi-domain knowledge base;
[0041] A category label acquisition module, used to acquire the word category label of each word in the model training text, and the word category label of the domain word corresponding to each word;
[0042] The target entity recognition model acquisition module is used to train the initial entity recognition model based on each character in the model training text, the domain word corresponding to each character, the character category label of each character and the word category label of the domain word corresponding to each character to obtain the target entity recognition model.
[0043] Optionally, the domain word acquisition module includes:
[0044] A domain word acquisition unit, used for acquiring, based on the multi-domain knowledge base, a first domain word with each character in the model training text as the head position, a second domain word with each character in the model training text as the middle position, and a third domain word with each character in the model training text as the tail position;
[0045] The domain word determination unit is used to use the first domain word, the second domain word and the third domain word as the domain word corresponding to each character in the model training text.
[0046] Optionally, the target entity recognition model acquisition module includes:
[0047] A label vector acquisition unit, used to acquire a character vector of each character in the model training text, a word vector of a domain word corresponding to each character, a character label vector of a character category label of each character, and a word label vector of a word category label of a domain word corresponding to each character;
[0048] The target entity recognition model acquisition unit is used to train the initial entity recognition model based on the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word to obtain the target entity recognition model.
[0049] Optionally, the label vector acquiring unit includes:
[0050] A word vector generating subunit, used for calling a pre-trained model to process each word and the domain word corresponding to each word in the model training text, and generating a word vector for each word and a word vector for the domain word corresponding to each word;
[0051] The label vector generating subunit is used to call the multi-layer neural network to process the character category label of each character and the word category label of the domain word corresponding to each character, and generate a character label vector for each character category label and a word label vector for each word category label.
[0052] Optionally, the initial entity recognition model includes: a multi-head attention mechanism layer, a feature fusion layer, a bidirectional long short-term memory network layer and a decoding layer, and the model training sample corresponds to the initial category label sequence, wherein,
[0053] The target entity recognition model acquisition unit includes:
[0054] A vector input subunit, used to input the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word into the initial entity recognition model;
[0055] a target vector acquisition subunit, configured to call the multi-head attention mechanism layer to perform attention distribution processing on the character vector, the word vector, the character label vector, and the word label vector, to obtain the attention-enhanced target character vector, target word vector, target character label vector, and target word label vector corresponding to the character vector, the word vector, the character label vector, and the word label vector, respectively;
[0056] A splicing vector acquisition subunit, used for calling the feature fusion layer to splice the target character vector, the target word vector, the target character label vector and the target word label vector to obtain a splicing vector;
[0057] A character encoding vector acquisition subunit is used to call the bidirectional long short-term memory network layer to process the concatenated vector to obtain a character encoding vector corresponding to each character in the model training text;
[0058] A prediction label sequence acquisition subunit is used to call the decoding layer to decode the word encoding vector to obtain a prediction category label sequence corresponding to the model training text;
[0059] A loss value calculation subunit, used to calculate the loss value corresponding to the initial entity recognition model based on the initial category label sequence and the predicted category label sequence;
[0060] The target entity recognition model acquisition subunit is used to use the trained initial entity recognition model as the target entity recognition model when the loss value is within a preset range.
[0061] Optionally, the device further comprises:
[0062] A module for obtaining text to be recognized, used for obtaining text to be recognized;
[0063] A target domain word acquisition module is used to acquire the target domain word corresponding to each character in the text to be recognized;
[0064] A target category label acquisition module is used to acquire a target word category label for each word in the text to be recognized, and a target word category label for a target domain word corresponding to each word;
[0065] A text input module to be recognized, used for inputting each character in the text to be recognized, the target domain word corresponding to each character, the target character category label of each character, and the target word category label of the target domain word corresponding to each character into the target entity recognition model;
[0066] A prediction probability acquisition module, used to acquire multiple category label sequences corresponding to the text to be recognized output by the target entity recognition model, and the prediction probability corresponding to each category label sequence;
[0067] The label recognition result acquisition module is used to acquire a target label sequence from the multiple category label sequences based on the predicted probability, and use the target label sequence as the category label recognition result of the text to be recognized.
[0068] Optionally, the tag recognition result acquisition module includes:
[0069] The target label sequence acquisition unit is used to acquire the category label sequence with the largest prediction probability among the multiple category label sequences, and use the category label sequence with the largest prediction probability as the target label sequence.
[0070] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0071] A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the entity recognition model training method described in any one of the above items is implemented.
[0072] According to a fourth aspect of an embodiment of the present disclosure, a readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any of the entity recognition model training methods described above.
[0073] The embodiments of the present disclosure provide an entity recognition model training method and device, which obtains the domain words corresponding to each character in the model training text based on a multi-domain knowledge base, obtains the character category label of each character in the model training text, and the word category label of the domain word corresponding to each character, and trains the initial entity recognition model based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character, to obtain a target entity recognition model. The embodiments of the present disclosure improve the entity segmentation and category prediction capabilities of named entity recognition by introducing domain-related knowledge vocabulary and classification labels, and improve the entity recognition effect of named entity recognition in different scenarios by introducing a multi-head attention mechanism to learn the weights of different domain knowledge. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the description of the embodiments of the present disclosure will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0075] Figure 1 A flowchart of a method for training an entity recognition model according to an embodiment of the present disclosure;
[0076] Figure 2 A flowchart of another entity recognition model training method provided in an embodiment of the present disclosure;
[0077] Figure 3 A schematic diagram of an entity recognition model processing flow provided for an embodiment of the present disclosure;
[0078] Figure 4 A schematic diagram of the structure of an entity recognition model training device provided in an embodiment of the present disclosure;
[0079] Figure 5 A schematic diagram of the structure of another entity recognition model training device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0080] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the embodiments of the present disclosure.
[0081] Embodiment 1
[0082] Reference Figure 1 , which shows a flow chart of the steps of an entity recognition model training method provided by an embodiment of the present disclosure, such as Figure 1 As shown, the entity recognition model training method may include the following steps:
[0083] Step 101: Obtain model training text.
[0084] The embodiments of the present disclosure can be applied to scenarios where domain-related knowledge vocabulary and classification labels are introduced to train entity recognition models.
[0085] Model training text refers to the text used to train the entity recognition model.
[0086] In practical applications, the model training text may be from Chinese Wikipedia, Baidu Encyclopedia, public news, and business-related data (such as user comment text in the order platform, etc.). Specifically, the source of the model training text may be determined according to business needs, and this embodiment does not impose any restrictions on this.
[0087] When the entity recognition model needs to be trained, the model training text can be obtained.
[0088] After the model training text is obtained, step 102 is executed.
[0089] Step 102: Based on the multi-domain knowledge base, obtain the domain word corresponding to each character in the model training text.
[0090] Domain words refer to the vocabulary associated with each word in the model training text in different fields.
[0091] After obtaining the model training text, the domain word corresponding to each character in the model training text can be obtained based on the multi-domain knowledge base. Specifically, this process can be described in detail in combination with the following specific implementation method.
[0092] In a specific implementation of the embodiment of the present disclosure, the above step 102 may include:
[0093] Sub-step A1: Based on the multi-domain knowledge base, obtain a first domain word with each character in the model training text as the head position, a second domain word with each character in the model training text as the middle position, and a third domain word with each character in the model training text as the tail position.
[0094] In this embodiment, the first domain word refers to a domain word with each character in the model training text as the head position.
[0095] The second domain word refers to the domain word with each word in the model training text as the middle position.
[0096] The third domain word refers to the domain word with each word in the model training text as the tail position.
[0097] After obtaining the model training text, based on the multi-domain knowledge base, the first domain word with each character in the model training text as the head position, the second domain word with each character in the model training text as the middle position, and the third domain word with each character in the model training text as the tail position can be obtained. Specifically, for a character in the input text, in the knowledge base of the domain, words in different domains with the character as the head (B, Begin), middle (M, Middle), and tail (E, End) can be found, and the corresponding first domain word, second domain word, and third domain word, as well as the character (S, Single) (such as water can be used as a domain word, etc.), for example, Figure 3 As shown, the input text is "Da Wang Road Orange Hotel" which contains a single word "Orange". The words starting with this word in the text include "Orange" and "Orange Hotel". Among them, the field words corresponding to "Orange Hotel" include "in-store field" and "hotel field", and the field words corresponding to "Orange" include "hotel field", "take-out field", "grocery shopping field", etc.
[0098] It can be understood that the above examples are merely examples listed for better understanding of the technical solutions of the embodiments of the present disclosure, and are not intended to be the sole limitations of the embodiments.
[0099] After obtaining the first domain word with each character in the model training text as the head position, the second domain word with each character in the model training text as the middle position, and the third domain word with each character in the model training text as the tail position based on the multi-domain knowledge base, sub-step A2 is executed.
[0100] Sub-step A2: taking the first domain word, the second domain word and the third domain word as the domain word corresponding to each character in the model training text.
[0101] After the first domain word, the second domain word and the third domain word are obtained, the first domain word, the second domain word and the third domain word may be used as the domain word corresponding to each character in the model training text.
[0102] The embodiments of the present disclosure combine domain words of different fields with each character to integrate vocabulary of different fields into the training of entity model recognition, thereby improving the entity recognition effect in different scenarios.
[0103] After obtaining the domain word corresponding to each character in the model training text based on the multi-domain knowledge base, step 103 is executed.
[0104] Step 103: Obtain the character category label of each character in the model training text, and the character category label of the domain word corresponding to each character.
[0105] Word category labels are labels that indicate the category to which each word in the model training text belongs.
[0106] The word category label refers to the label used to indicate the category of the domain word corresponding to each word in the model training text.
[0107] After obtaining the domain word corresponding to each character in the model training text, the character category label of each character in the model training text and the word category label of the domain word corresponding to each character can be obtained.
[0108] After obtaining the character category label of each character in the model training text and the character category label of the domain word corresponding to each character, step 104 is executed.
[0109] Step 104: Based on each character in the model training text, the domain word corresponding to each character, the character category label of each character and the word category label of the domain word corresponding to each character, the initial entity recognition model is trained to obtain a target entity recognition model.
[0110] After obtaining the character category label of each character in the model training text and the word category label of the domain word corresponding to each character, the initial entity recognition model can be trained based on each character in the model training text, the domain word corresponding to each character, the character category label of each character and the word category label of the domain word corresponding to each character to obtain the target entity recognition model.
[0111] Specifically, vectors corresponding to each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character can be obtained, and the vectors can be used as input to the initial entity recognition model to train the initial entity recognition model. The specific training process can be described in detail in combination with the following specific implementation method.
[0112] In another specific implementation of the present disclosure, the above step 104 may include:
[0113] Sub-step B1: Obtain the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word.
[0114] In this embodiment, the word vector refers to the representation vector corresponding to each word in the model training text.
[0115] The word vector refers to the representation vector of the domain word corresponding to each word in the model training text.
[0116] The word label vector refers to the representation vector of the word category label corresponding to each word in the model training text.
[0117] The word label vector refers to the representation vector of the word category label of the domain word corresponding to each word in the model training text.
[0118] After obtaining the domain words corresponding to each character in the model training text, the word category label of each character, and the word category label of the domain word corresponding to each character, the word vector of each character in the model training text, the word vector of the domain word corresponding to each character, the word label vector of the word category label of each character, and the word label vector of the word category label of the domain word corresponding to each character can be obtained. In a specific implementation, a pre-trained model can be called to process each character and the domain word corresponding to each character in the model training text to generate a word vector for each character and a word vector for the domain word corresponding to each character, and a multi-layer neural network can be called to process the word category label of each character and the word category label of the domain word corresponding to each character to generate a word label vector for each character category label and a word label vector for each word category label. Specifically, the pre-trained model BERT can be used to generate vector representations of Chinese characters and vocabulary, and MLP (Multi-Layer Perceptron) can be used to convert category labels in various domain knowledge bases into vector representations.
[0119] After obtaining the character vector, character tag vector, word vector and word tag vector, perform sub-step B2.
[0120] Sub-step B2: Train the initial entity recognition model based on the word vector of each character in the model training text, the word vector of the domain word corresponding to each character, the word label vector of the word category label of each character, and the word label vector of the word category label of the domain word corresponding to each character to obtain the target entity recognition model.
[0121] After obtaining the character vector, character label vector, word vector and word label vector, the character vector, character label vector, word vector and word label vector can be input into the initial entity recognition model to train the initial entity recognition model to obtain the target entity recognition model. The training process can be described in detail in combination with the following specific implementation method.
[0122] In another specific implementation of the embodiment of the present disclosure, the initial entity recognition model includes: a multi-head attention mechanism layer, a feature fusion layer, a bidirectional long short-term memory network layer and a decoding layer, and the model training sample corresponds to the initial category label sequence, wherein,
[0123] The above sub-step B2 may include:
[0124] Sub-step C1: Input the word vector of each character in the model training text, the word vector of the domain word corresponding to each character, the word label vector of the word category label of each character, and the word label vector of the word category label of the domain word corresponding to each character into the initial entity recognition model.
[0125] After obtaining the character vector, the character label vector, the word vector and the word label vector, the character vector, the character label vector, the word vector and the word label vector may be input into the initial entity recognition model.
[0126] After the character vector, the character tag vector, the word vector and the word tag vector are input into the initial entity recognition model, sub-step C2 is performed.
[0127] Sub-step C2: Call the multi-head attention mechanism layer to perform attention distribution processing on the character vector, the word vector, the character label vector and the word label vector to obtain the attention-enhanced target character vector, target word vector, target word label vector and target word label vector corresponding to the character vector, the word vector, the character label vector and the word label vector respectively.
[0128] After the word vector, word label vector, word vector and word label vector are input into the initial entity recognition model, the multi-head attention mechanism layer can be called to perform attention distribution processing on the word vector, word label vector, word vector and word label vector to obtain the attention-enhanced vectors corresponding to the word vector, word label vector, word vector and word label vector, namely, the attention-enhanced target word vector, target word vector, target word label vector and target word label vector.
[0129] Specifically, for a character i in the input text, in the knowledge base of domain Γ, we can find words with this character as the beginning (B, Begin), middle (M, Middle), and end (E, End), as well as the single character itself (S, Single), and the corresponding vector representations are recorded as Similarly, the category label of the corresponding vocabulary is represented by However, simple weighted average is difficult to effectively capture the weights of knowledge in different fields in entity recognition. This scheme adopts a multi-head attention mechanism to learn this weight distribution. The head attention mechanism takes the above vectors as input and obtains the vocabulary representation and category label representation that have learned the weights of knowledge in different fields, denoted as B ei 、M ei 、E ei , S ei , B vi 、M vi 、E vi , S vi . Below is Bei Take the calculation as an example:
[0130]
[0131] σ(·)
[0132] Among them, W qj , W kj , W vj , is the attention parameter of the jth head, d is the feature dimension, and m is the total number of heads, which is related to the number of fields. Thus, the attention-enhanced text character encoding can be obtained.
[0133] After obtaining the attention-enhanced target word vector, target word vector, target word label vector, and target word label vector, sub-step C3 is performed.
[0134] Sub-step C3: calling the feature fusion layer to perform splicing processing on the target character vector, the target word vector, the target character label vector and the target word label vector to obtain a spliced vector.
[0135] After obtaining the attention-enhanced target word vector, target word vector, target word label vector, and target word label vector, the feature fusion layer can be called to concatenate the attention-enhanced target word vector, target word vector, target word label vector, and target word label vector to obtain a concatenated vector, that is, To integrate the semantics, word segmentation and corresponding category label information of characters and words.
[0136] After the splicing vector is obtained, sub-step C4 is executed.
[0137] Sub-step C4: calling the bidirectional long short-term memory network layer to process the concatenated vector to obtain a character encoding vector corresponding to each character in the model training text.
[0138] After obtaining the concatenated vector, the bidirectional long short-term memory network layer (i.e., BiLSTM layer) can be called to process the concatenated vector to obtain the character encoding vector corresponding to each character in the model training text.
[0139] In the BiLSTM layer, the semantic information of characters and words is used As input, the feature transfer method of input text character j in character-level LSTM (Long Short-Term Memory) is as follows:
[0140]
[0141]
[0142]
[0143]
[0144]
[0145]
[0146] Where σ(·) is the Sigmoid function, W ·x ,W ·h ,b · For the learning parameters of each gate, is the Hadamard product, y j is the output of character j after single-layer LSTM encoding. BiLSTM consists of two LSTM models in different directions. The final output of character j is:
[0147] After obtaining the character encoding vector corresponding to each character in the model training text, sub-step C5 is executed.
[0148] Sub-step C5: calling the decoding layer to decode the character encoding vector to obtain a predicted category label sequence corresponding to the model training text.
[0149] After obtaining the character encoding vector corresponding to each character in the model training text, the decoding layer can be called to decode the character encoding vector to obtain the predicted category label sequence corresponding to the model training text.
[0150] Sub-step C6: Based on the initial category label sequence and the predicted category label sequence, calculate the loss value corresponding to the initial entity recognition model.
[0151] After obtaining the predicted category label sequence, the loss value of the initial entity recognition model can be calculated based on the predicted category label sequence and the initial category label sequence.
[0152] Sub-step C7: When the loss value is within a preset range, the trained initial entity recognition model is used as the target entity recognition model.
[0153] When the loss value is within a preset range, the trained initial entity recognition model can be used as the target entity recognition model.
[0154] The embodiments of the present disclosure improve the entity segmentation and category prediction capabilities of named entity recognition by introducing domain-related knowledge vocabulary and classification labels, and improve the entity recognition effect of named entity recognition in different scenarios by introducing a multi-head attention mechanism to learn the weights of knowledge in different fields.
[0155] The entity recognition model training method provided by the embodiment of the present disclosure obtains the domain word corresponding to each character in the model training text based on a multi-domain knowledge base, obtains the character category label of each character in the model training text, and the word category label of the domain word corresponding to each character, and trains the initial entity recognition model based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character to obtain the target entity recognition model. The embodiment of the present disclosure improves the entity segmentation and category prediction capabilities of named entity recognition by introducing domain-related knowledge vocabulary and classification labels, and improves the entity recognition effect of named entity recognition in different scenarios by introducing a multi-head attention mechanism to learn the weights of knowledge in different domains.
[0156] Embodiment 2
[0157] Reference Figure 2 , showing a flowchart of another entity recognition model training method provided by an embodiment of the present disclosure, such as Figure 2 As shown, the entity recognition model training method may include the following steps:
[0158] Step 201: Obtain model training text.
[0159] The embodiments of the present disclosure can be applied to scenarios where domain-related knowledge vocabulary and classification labels are introduced to train entity recognition models.
[0160] Model training text refers to the text used to train the entity recognition model.
[0161] In practical applications, the model training text may be from Chinese Wikipedia, Baidu Encyclopedia, public news, and business-related data (such as user comment text in the order platform, etc.). Specifically, the source of the model training text may be determined according to business needs, and this embodiment does not impose any restrictions on this.
[0162] When the entity recognition model needs to be trained, the model training text can be obtained.
[0163] After the model training text is obtained, step 202 is executed.
[0164] Step 202: Based on the multi-domain knowledge base, obtain the domain word corresponding to each character in the model training text.
[0165] Domain words refer to the vocabulary associated with each word in the model training text in different fields.
[0166] After obtaining the model training text, the domain word corresponding to each character in the model training text can be obtained based on the multi-domain knowledge base. Specifically, this process can be described in detail in combination with the following specific implementation method.
[0167] In a specific implementation of the embodiment of the present disclosure, the above step 202 may include:
[0168] Sub-step D1: Based on the multi-domain knowledge base, obtain a first domain word with each character in the model training text as the head position, a second domain word with each character in the model training text as the middle position, and a third domain word with each character in the model training text as the tail position.
[0169] In this embodiment, the first domain word refers to a domain word with each character in the model training text as the head position.
[0170] The second domain word refers to the domain word with each word in the model training text as the middle position.
[0171] The third domain word refers to the domain word with each word in the model training text as the tail position.
[0172] After obtaining the model training text, based on the multi-domain knowledge base, the first domain word with each character in the model training text as the head position, the second domain word with each character in the model training text as the middle position, and the third domain word with each character in the model training text as the tail position can be obtained. Specifically, for a character in the input text, in the knowledge base of the domain, words in different domains with the character as the head (B, Begin), middle (M, Middle), and tail (E, End) can be found, and the corresponding first domain word, second domain word, and third domain word, as well as the character (S, Single) (such as water can be used as a domain word, etc.), for example, Figure 3 As shown, the input text is "Da Wang Road Orange Hotel" which contains a single word "Orange". The words starting with this word in the text include "Orange" and "Orange Hotel". Among them, the field words corresponding to "Orange Hotel" include "in-store field" and "hotel field", and the field words corresponding to "Orange" include "hotel field", "take-out field", "grocery shopping field", etc.
[0173] It can be understood that the above examples are merely examples listed for better understanding of the technical solutions of the embodiments of the present disclosure, and are not intended to be the sole limitations of the embodiments.
[0174] After obtaining the first domain word with each character in the model training text as the head position, the second domain word with each character in the model training text as the middle position, and the third domain word with each character in the model training text as the tail position based on the multi-domain knowledge base, sub-step D2 is executed.
[0175] Sub-step D2: taking the first domain word, the second domain word and the third domain word as the domain word corresponding to each character in the model training text.
[0176] After the first domain word, the second domain word and the third domain word are obtained, the first domain word, the second domain word and the third domain word may be used as the domain word corresponding to each character in the model training text.
[0177] The embodiments of the present disclosure combine domain words of different fields with each character to integrate vocabulary of different fields into the training of entity model recognition, thereby improving the entity recognition effect in different scenarios.
[0178] After obtaining the domain word corresponding to each character in the model training text based on the multi-domain knowledge base, step 203 is executed.
[0179] Step 203: Obtain the character category label of each character in the model training text, and the character category label of the domain word corresponding to each character.
[0180] Word category labels are labels that indicate the category to which each word in the model training text belongs.
[0181] The word category label refers to the label used to indicate the category of the domain word corresponding to each word in the model training text.
[0182] After obtaining the domain word corresponding to each character in the model training text, the character category label of each character in the model training text and the word category label of the domain word corresponding to each character can be obtained.
[0183] After obtaining the character category label of each character in the model training text and the character category label of the domain word corresponding to each character, step 204 is executed.
[0184] Step 204: Based on each character in the model training text, the domain word corresponding to each character, the character category label of each character and the word category label of the domain word corresponding to each character, the initial entity recognition model is trained to obtain a target entity recognition model.
[0185] After obtaining the character category label of each character in the model training text and the word category label of the domain word corresponding to each character, the initial entity recognition model can be trained based on each character in the model training text, the domain word corresponding to each character, the character category label of each character and the word category label of the domain word corresponding to each character to obtain the target entity recognition model.
[0186] Specifically, vectors corresponding to each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character can be obtained, and the vectors can be used as inputs of the initial entity recognition model to train the initial entity recognition model to obtain the target entity recognition model. The model training process can refer to the description of the first embodiment, and this embodiment will not be repeated here.
[0187] Step 205: Obtain the text to be recognized.
[0188] The text to be recognized refers to the text that needs to be recognized by entity category.
[0189] After the target entity recognition model is trained, the text to be recognized can be obtained when the target entity recognition model is subsequently applied.
[0190] After the text to be recognized is obtained, step 206 is executed.
[0191] Step 206: Obtain the target domain word corresponding to each character in the text to be recognized.
[0192] The target domain word refers to the domain word corresponding to each character in the text to be recognized.
[0193] After obtaining the text to be recognized, the target domain word corresponding to each character in the text to be recognized can be obtained. The scheme for obtaining the target domain word corresponding to each character in the text to be recognized is similar to the scheme for obtaining the domain word of each character in the model training text in the above embodiment 1, and this embodiment will not be repeated here.
[0194] After the target domain word corresponding to each character in the text to be recognized is obtained, step 207 is executed.
[0195] Step 207: Obtain a target word category label for each word in the text to be recognized, and a target word category label for the target domain word corresponding to each word.
[0196] The target character category label refers to the category label corresponding to each character in the text to be recognized, and the target character category label can be used to indicate the category to which each character in the text to be recognized belongs.
[0197] The target word category label refers to the category label of the target domain word corresponding to each character in the text to be recognized. The target word category label can be used to indicate the category to which the target domain word corresponding to each character in the text to be recognized belongs.
[0198] After obtaining the target domain word corresponding to each character in the text to be recognized, the target character category label of each character in the text to be recognized and the target word category label of the target domain word corresponding to each character can be obtained.
[0199] After obtaining the target word category label of each word in the text to be recognized and the target word category label corresponding to the target domain word corresponding to each word, step 208 is executed.
[0200] Step 208: Input each character in the text to be recognized, the target domain word corresponding to each character, the target character category label of each character, and the target word category label of the target domain word corresponding to each character into the target entity recognition model.
[0201] After obtaining the target character category label of each character in the text to be recognized and the target word category label of the target domain word corresponding to each character, each character in the text to be recognized, the target domain word corresponding to each character, the target character category label of each character and the target word category label of the target domain word corresponding to each character can be input into the target entity recognition model. Specifically, each character in the text to be recognized, the target domain word corresponding to each character, the target character category label of each character and the target word category label of the target domain word corresponding to each character can be respectively converted into corresponding vectors, and the converted vectors can be input into the target entity recognition model.
[0202] Step 209: Obtain multiple category label sequences corresponding to the text to be recognized output by the target entity recognition model, and the prediction probability corresponding to each of the category label sequences.
[0203] After each character in the text to be recognized, the target domain word corresponding to each character, the target character category label of each character and the target word category label of the target domain word corresponding to each character are input into the target entity recognition model, the target entity recognition model can process each character in the text to be recognized, the target domain word corresponding to each character, the target character category label of each character and the target word category label of the target domain word corresponding to each character to obtain multiple category label sequences corresponding to the text to be recognized and the prediction probability corresponding to each category label sequence. The model processing process refers to the description of the model training process, which is similar to the model training process and will not be described in detail in this embodiment.
[0204] Step 210: Based on the predicted probability, a target label sequence from the multiple category label sequences is obtained, and the target label sequence is used as a category label recognition result of the text to be recognized.
[0205] After obtaining multiple category label sequences corresponding to the text to be recognized and the prediction probability corresponding to each category label sequence, the target label sequence in the multiple category label sequences can be obtained based on the prediction probability, and the target label sequence can be used as the category label recognition result of the text to be recognized. Specifically, according to the prediction probability, the category label sequence with the largest prediction probability in the multiple category label sequences can be obtained as the target label sequence.
[0206] The embodiments of the present disclosure improve the entity segmentation and category prediction capabilities of named entity recognition by introducing domain-related knowledge vocabulary and classification labels, and improve the entity recognition effect of named entity recognition in different scenarios by introducing a multi-head attention mechanism to learn the weights of knowledge in different fields.
[0207] The entity recognition model training method provided by the embodiment of the present disclosure obtains the domain word corresponding to each character in the model training text based on a multi-domain knowledge base, obtains the character category label of each character in the model training text, and the word category label of the domain word corresponding to each character, and trains the initial entity recognition model based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character to obtain the target entity recognition model. The embodiment of the present disclosure improves the entity segmentation and category prediction capabilities of named entity recognition by introducing domain-related knowledge vocabulary and classification labels, and improves the entity recognition effect of named entity recognition in different scenarios by introducing a multi-head attention mechanism to learn the weights of knowledge in different domains.
[0208] Embodiment 3
[0209] Reference Figure 4 , which shows a schematic diagram of the structure of an entity recognition model training device provided by an embodiment of the present disclosure, such as Figure 4 As shown, the entity recognition model training device 400 may include the following modules:
[0210] A model training text acquisition module 410 is used to acquire model training text;
[0211] A domain word acquisition module 420 is used to acquire the domain word corresponding to each character in the model training text based on a multi-domain knowledge base;
[0212] A category label acquisition module 430 is used to acquire a character category label of each character in the model training text and a word category label of a domain word corresponding to each character;
[0213] The target entity recognition model acquisition module 440 is used to train the initial entity recognition model based on each character in the model training text, the domain word corresponding to each character, the character category label of each character and the word category label of the domain word corresponding to each character to obtain the target entity recognition model.
[0214] Optionally, the domain word acquisition module includes:
[0215] A domain word acquisition unit, used for acquiring, based on the multi-domain knowledge base, a first domain word with each character in the model training text as the head position, a second domain word with each character in the model training text as the middle position, and a third domain word with each character in the model training text as the tail position;
[0216] The domain word determination unit is used to use the first domain word, the second domain word and the third domain word as the domain word corresponding to each character in the model training text.
[0217] Optionally, the target entity recognition model acquisition module includes:
[0218] A label vector acquisition unit, used to acquire a character vector of each character in the model training text, a word vector of a domain word corresponding to each character, a character label vector of a character category label of each character, and a word label vector of a word category label of a domain word corresponding to each character;
[0219] The target entity recognition model acquisition unit is used to train the initial entity recognition model based on the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word to obtain the target entity recognition model.
[0220] Optionally, the label vector acquiring unit includes:
[0221] A word vector generating subunit, used for calling a pre-trained model to process each word and the domain word corresponding to each word in the model training text, and generating a word vector for each word and a word vector for the domain word corresponding to each word;
[0222] The label vector generating subunit is used to call the multi-layer neural network to process the character category label of each character and the word category label of the domain word corresponding to each character, and generate a character label vector for each character category label and a word label vector for each word category label.
[0223] Optionally, the initial entity recognition model includes: a multi-head attention mechanism layer, a feature fusion layer, a bidirectional long short-term memory network layer and a decoding layer, and the model training sample corresponds to the initial category label sequence, wherein,
[0224] The target entity recognition model acquisition unit includes:
[0225] A vector input subunit, used to input the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word into the initial entity recognition model;
[0226] a target vector acquisition subunit, configured to call the multi-head attention mechanism layer to perform attention distribution processing on the character vector, the word vector, the character label vector, and the word label vector, to obtain the attention-enhanced target character vector, target word vector, target character label vector, and target word label vector corresponding to the character vector, the word vector, the character label vector, and the word label vector, respectively;
[0227] A splicing vector acquisition subunit, used for calling the feature fusion layer to splice the target character vector, the target word vector, the target character label vector and the target word label vector to obtain a splicing vector;
[0228] A character encoding vector acquisition subunit is used to call the bidirectional long short-term memory network layer to process the concatenated vector to obtain a character encoding vector corresponding to each character in the model training text;
[0229] A prediction label sequence acquisition subunit is used to call the decoding layer to decode the word encoding vector to obtain a prediction category label sequence corresponding to the model training text;
[0230] A loss value calculation subunit, used to calculate the loss value corresponding to the initial entity recognition model based on the initial category label sequence and the predicted category label sequence;
[0231] The target entity recognition model acquisition subunit is used to use the trained initial entity recognition model as the target entity recognition model when the loss value is within a preset range.
[0232] The entity recognition model training device provided by the embodiment of the present disclosure obtains the domain word corresponding to each character in the model training text based on a multi-domain knowledge base, obtains the character category label of each character in the model training text, and the word category label of the domain word corresponding to each character, and trains the initial entity recognition model based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character to obtain a target entity recognition model. The embodiment of the present disclosure improves the entity segmentation and category prediction capabilities of named entity recognition by introducing domain-related knowledge vocabulary and classification labels, and improves the entity recognition effect of named entity recognition in different scenarios by introducing a multi-head attention mechanism to learn the weights of different domain knowledge.
[0233] Embodiment 4
[0234] Reference Figure 5 , showing a schematic diagram of the structure of another entity recognition model training device provided by an embodiment of the present disclosure, such as Figure 5As shown, the entity recognition model training device 400 may include the following modules:
[0235] A model training text acquisition module 510 is used to acquire model training text;
[0236] A domain word acquisition module 520 is used to acquire the domain word corresponding to each character in the model training text based on a multi-domain knowledge base;
[0237] A category label acquisition module 530 is used to acquire a character category label of each character in the model training text, and a word category label of a domain word corresponding to each character;
[0238] A target entity recognition model acquisition module 540 is used to train the initial entity recognition model based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character to obtain a target entity recognition model;
[0239] The to-be-recognized text acquisition module 550 is used to acquire the to-be-recognized text;
[0240] A target domain word acquisition module 560 is used to acquire a target domain word corresponding to each character in the text to be recognized;
[0241] A target category label acquisition module 570 is used to acquire a target word category label for each word in the text to be recognized, and a target word category label for a target domain word corresponding to each word;
[0242] A text input module 580 for identifying is used to input each character in the text to be identified, the target domain word corresponding to each character, the target character category label of each character, and the target word category label of the target domain word corresponding to each character into the target entity recognition model;
[0243] A prediction probability acquisition module 590 is used to acquire multiple category label sequences corresponding to the to-be-recognized text output by the target entity recognition model, and the prediction probability corresponding to each of the category label sequences;
[0244] The label recognition result acquisition module 5100 is used to acquire a target label sequence from the multiple category label sequences based on the prediction probability, and use the target label sequence as the category label recognition result of the text to be recognized.
[0245] Optionally, the tag recognition result acquisition module includes:
[0246] The target label sequence acquisition unit is used to acquire the category label sequence with the largest prediction probability among the multiple category label sequences, and use the category label sequence with the largest prediction probability as the target label sequence.
[0247] The entity recognition model training device provided by the embodiment of the present disclosure obtains the domain word corresponding to each character in the model training text based on a multi-domain knowledge base, obtains the character category label of each character in the model training text, and the word category label of the domain word corresponding to each character, and trains the initial entity recognition model based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character to obtain a target entity recognition model. The embodiment of the present disclosure improves the entity segmentation and category prediction capabilities of named entity recognition by introducing domain-related knowledge vocabulary and classification labels, and improves the entity recognition effect of named entity recognition in different scenarios by introducing a multi-head attention mechanism to learn the weights of different domain knowledge.
[0248] An embodiment of the present disclosure further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the entity recognition model training method of the aforementioned embodiment when executing the program.
[0249] An embodiment of the present disclosure further provides a readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the entity recognition model training method of the aforementioned embodiment.
[0250] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0251] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems may also be used together with the teachings based thereon. According to the above description, it is apparent that the structure required for constructing such systems is. In addition, the embodiments of the present disclosure are not directed to any particular programming language either. It should be understood that the contents of the embodiments of the present disclosure described herein may be realized using various programming languages, and the description of the specific languages above is intended to disclose the best mode of implementation of the embodiments of the present disclosure.
[0252] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present disclosure can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0253] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present disclosure, the various features of the embodiments of the present disclosure are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following intention: the claimed embodiments of the present disclosure require more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, the inventive aspects lie in less than all the features of the single embodiment disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the embodiments of the present disclosure.
[0254] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0255] The various component embodiments of the embodiments of the present disclosure may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components of the dynamic picture generation device according to the embodiments of the present disclosure. The embodiments of the present disclosure may also be implemented as a device or apparatus program for executing part or all of the methods described herein. Such a program implementing an embodiment of the present disclosure may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0256] It should be noted that the above embodiments illustrate rather than limit the embodiments of the present disclosure, and that those skilled in the art may design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets should not be constructed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of multiple such elements. The embodiments of the present disclosure may be implemented by means of hardware including several different elements and by means of appropriately programmed computers. In a unit claim that lists several devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names.
[0257] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0258] The above description is only a preferred embodiment of the embodiments of the present disclosure and is not intended to limit the embodiments of the present disclosure. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the embodiments of the present disclosure should be included in the protection scope of the embodiments of the present disclosure.
[0259] The above is only a specific implementation of the embodiment of the present disclosure, but the protection scope of the embodiment of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed by the embodiment of the present disclosure, which should be included in the protection scope of the embodiment of the present disclosure. Therefore, the protection scope of the embodiment of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for training an entity recognition model, characterized in that: include: Get model training text; Based on the multi-domain knowledge base, obtain the domain words corresponding to each character in the model training text, wherein the domain words refer to the vocabulary associated with each character in the model training text in different fields; Obtaining the word category label of each word in the model training text and the word category label of the domain word corresponding to each word; Based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character, the initial entity recognition model is trained to obtain a target entity recognition model; The step of obtaining the domain word corresponding to each character in the model training text based on the multi-domain knowledge base includes: Based on the multi-domain knowledge base, obtaining a first domain word with each character in the model training text as the head position, a second domain word with each character in the model training text as the middle position, and a third domain word with each character in the model training text as the tail position; The first domain word, the second domain word and the third domain word are used as domain words corresponding to each character in the model training text.
2. The method according to claim 1, characterized in that The initial entity recognition model is trained based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character to obtain a target entity recognition model, including: Obtaining a word vector for each word in the model training text, a word vector for the domain word corresponding to each word, a word label vector for the word category label of each word, and a word label vector for the word category label of the domain word corresponding to each word; The initial entity recognition model is trained based on the word vector of each character in the model training text, the word vector of the domain word corresponding to each character, the word label vector of the word category label of each character, and the word label vector of the word category label of the domain word corresponding to each character to obtain the target entity recognition model.
3. The method according to claim 2, characterized in that The step of obtaining the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word includes: Calling the pre-trained model to process each character and the domain word corresponding to each character in the model training text to generate a character vector for each character and a word vector for the domain word corresponding to each character; A multi-layer neural network is called to process the character category label of each character and the word category label of the domain word corresponding to each character, and a character label vector of each character category label and a word label vector of each word category label are generated.
4. The method according to claim 2, characterized in that: The initial entity recognition model includes: a multi-head attention mechanism layer, a feature fusion layer, a bidirectional long short-term memory network layer and a decoding layer, and the model training sample corresponds to an initial category label sequence, wherein the initial entity recognition model is trained based on the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word, to obtain the target entity recognition model, including: Inputting the word vector of each word in the model training text, the word vector of the domain word corresponding to each word, the word label vector of the word category label of each word, and the word label vector of the word category label of the domain word corresponding to each word into the initial entity recognition model; Calling the multi-head attention mechanism layer to perform attention distribution processing on the word vector, the word vector, the word label vector and the word label vector to obtain the attention-enhanced target word vector, target word vector, target word label vector and target word label vector corresponding to the word vector, the word vector, the word label vector and the word label vector respectively; calling the feature fusion layer to perform splicing processing on the target word vector, the target word vector, the target word label vector and the target word label vector to obtain a splicing vector; Calling the bidirectional long short-term memory network layer to process the concatenated vector to obtain a character encoding vector corresponding to each character in the model training text; Calling the decoding layer to decode the word encoding vector to obtain a predicted category label sequence corresponding to the model training text; Based on the initial category label sequence and the predicted category label sequence, a loss value corresponding to the initial entity recognition model is calculated; When the loss value is within a preset range, the trained initial entity recognition model is used as the target entity recognition model.
5. The method according to claim 1, characterized in that After the initial entity recognition model is trained based on each character in the model training text, the domain word corresponding to each character, the character category label of each character, and the word category label of the domain word corresponding to each character to obtain the target entity recognition model, the method further includes: Get the text to be recognized; Obtaining the target domain word corresponding to each character in the text to be recognized; Obtaining a target word category label for each word in the to-be-recognized text and a target word category label for a target domain word corresponding to each word; Input each character in the text to be recognized, the target domain word corresponding to each character, the target character category label of each character, and the target word category label of the target domain word corresponding to each character into the target entity recognition model; Obtaining multiple category label sequences corresponding to the text to be recognized output by the target entity recognition model, and the prediction probability corresponding to each of the category label sequences; Based on the predicted probability, a target label sequence from the multiple category label sequences is obtained, and the target label sequence is used as a category label recognition result of the text to be recognized.
6. The method according to claim 5, characterized in that The step of acquiring a target label sequence from among the plurality of category label sequences based on the predicted probability comprises: A category label sequence with the largest prediction probability among the multiple category label sequences is obtained, and the category label sequence with the largest prediction probability is used as the target label sequence.
7. An entity recognition model training device, characterized in that: include: Model training text acquisition module, used to obtain model training text; A domain word acquisition module is used to acquire the domain word corresponding to each character in the model training text based on a multi-domain knowledge base. The domain word refers to the vocabulary associated with each character in the model training text in different fields. The domain word acquisition module based on the multi-domain knowledge base includes: Based on the multi-domain knowledge base, obtaining a first domain word with each character in the model training text as the head position, a second domain word with each character in the model training text as the middle position, and a third domain word with each character in the model training text as the tail position; Using the first domain word, the second domain word and the third domain word as the domain word corresponding to each character in the model training text; A category label acquisition module, used to acquire the word category label of each word in the model training text, and the word category label of the domain word corresponding to each word; The target entity recognition model acquisition module is used to train the initial entity recognition model based on each character in the model training text, the domain word corresponding to each character, the character category label of each character and the word category label of the domain word corresponding to each character to obtain the target entity recognition model.
8. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the entity recognition model training method according to any one of claims 1 to 6 when executing the program.
9. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, Enables an electronic device to execute the entity recognition model training method described in any one of claims 1 to 6.
Citation Information
Patent Citations
Named entity identification method and device
CN111368541A
Method for identifying policy and regulation text entities in four-insurance and one-fund field
CN112836046A