Training methods for entity recognition models, entity recognition methods and related equipment

By constructing a multi-level contrastive learning model in the entity recognition model and calculating the loss using named entity labels and predicted labels, the problem of excessive noise under weakly supervised training is solved, and higher accuracy in named entity recognition is achieved.

CN116402045BActive Publication Date: 2026-11-17BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310382097.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-11
Publication Date
2026-11-17
Estimated Expiration
2043-04-11

AI Technical Summary

Technical Problem

In existing technologies, entity recognition models trained using weak supervision methods suffer from excessive noise, resulting in low accuracy.

Method used

By acquiring named entity labels from sample sentences, processing the sample sentences using an entity recognition model, calculating word vectors and sentence vectors, and training the model based on label classification loss, sentence dimension loss, and word dimension loss, a multi-level contrastive learning model is constructed to alleviate noise overfitting and promote the utilization of pre-trained knowledge.

Benefits of technology

It improved the overall performance of the entity recognition model and increased the accuracy of named entity recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116402045B_ABST
    Figure CN116402045B_ABST
Patent Text Reader

Abstract

This disclosure provides a training method for an entity recognition model, an entity recognition method, and related equipment. The training method for the entity recognition model includes: acquiring multiple sample sentences and determining the named entity labels of each word in each sample sentence; processing the multiple sample sentences through the entity recognition model to obtain the word vectors of each word in each sample sentence, the predicted labels of each word under the named entity category, and the sentence vectors of each sample sentence; calculating the label classification loss based on the named entity labels and predicted labels of each word; determining the positive and negative examples of the sentences based on the sentence vectors of the sample sentences, and calculating the sentence dimension loss based on the positive and negative examples; determining the positive and negative examples of words based on the named entity labels and word vectors, and calculating the word dimension loss based on the positive and negative examples; training the entity recognition model based on the label classification loss, sentence dimension loss, and word dimension loss to obtain the trained entity recognition model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of network models, and more particularly to a training method for an entity recognition model, an entity recognition method, and related equipment. Background Technology

[0002] With the continuous development of computer and internet technologies, natural language processing (NLP) has become an important direction in the fields of computer science and artificial intelligence. Named entity recognition (NER) is a fundamental task in NLP, aiming to identify named entities, such as names of people, places, and organizations, from text. NER is widely used in applications such as information extraction, machine translation, and question-answering systems.

[0003] In related technologies, the entity categories of samples are typically labeled using weak supervision first, and then an entity recognition model is trained based on the labeling results from the weak supervision method. However, the labeling results from the weak supervision method usually contain a lot of noise and have low accuracy, so the accuracy of the trained entity recognition model is also low.

[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] The purpose of this disclosure is to provide a training method, apparatus, electronic device, and storage medium for an entity recognition model, so as to obtain an entity recognition model with good entity category recognition performance.

[0006] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.

[0007] According to one aspect of this disclosure, a method for training an entity recognition model is provided, comprising: acquiring multiple sample sentences and determining named entity labels for each word in each sample sentence; processing the multiple sample sentences through the entity recognition model to obtain word vectors for each word in each sample sentence, predicted labels for each word under named entity categories, and sentence vectors for each sample sentence; calculating label classification loss based on the named entity labels and predicted labels for each word; determining positive and negative examples of the sentences based on the sentence vectors of the sample sentences, and calculating sentence dimension loss based on the positive and negative examples; determining positive and negative examples of words based on the named entity labels and word vectors, and calculating word dimension loss based on the positive and negative examples; training the entity recognition model based on the label classification loss, sentence dimension loss, and word dimension loss to obtain a trained entity recognition model.

[0008] In one embodiment of this disclosure, multiple sample sentences are processed by an entity recognition model to obtain word vectors of each word in each sample sentence, predicted labels of each word under named entity categories, and sentence vectors of each sample sentence. This includes: performing two forward processing steps on the multiple sample sentences using a feature extraction network in the entity recognition model to obtain two processing results; each processing result includes: word vectors of each word in all sample sentences, and probability vectors of each word under named entity categories; using the word vectors in the first processing result as the word vectors of each word in each sample sentence; determining the predicted labels of each word under named entity categories based on the probability vectors in the first processing result; and performing pooling processing on the word vectors of each word in each sample sentence in the two processing results to obtain two sentence vectors for each sample sentence.

[0009] In one embodiment of this disclosure, determining the predicted label of each word under the named entity category based on the probability vector in the first processing result includes: using the probability vector in the first processing result as the soft predicted label of each word under the named entity category; determining the hard predicted label of each word under the named entity category based on the largest element in the probability vector in the first processing result; and determining the predicted label of each word under the named entity category based on the soft predicted label and the hard predicted label.

[0010] In one embodiment of this disclosure, the named entity label includes hard labels and soft labels. The hard labels indicate the named entity category corresponding to the word, and the soft labels indicate the probability value of the word belonging to each named entity category. The label classification loss is calculated based on the named entity labels and predicted labels of each word, including: calculating a first label classification loss based on the soft labels and soft predicted labels; calculating a second label classification loss based on the hard labels and hard predicted labels; and determining the label classification loss based on the first label classification loss and the second label classification loss.

[0011] In one embodiment of this disclosure, determining positive and negative statements based on the statement vectors of sample statements includes: for any target statement among a plurality of sample statements, taking two statement vectors of the target statement as positive statements, and taking any statement vector of the target statement and any statement vector of other statements besides the target statement as negative statements.

[0012] In one embodiment of this disclosure, determining positive and negative word examples based on the named entity tags and word vectors includes: determining the named entity category to which each word belongs based on the named entity tags of each word; taking the word vectors of words with the same named entity category as positive word examples, and taking the word vectors of words with different named entity categories as negative word examples.

[0013] In one embodiment of this disclosure, determining the named entity label of each word in each sample statement includes: using multiple named entity annotation functions to annotate the named entity categories of the words in each sample statement, obtaining the entity category annotation results of each named entity annotation function for each word in each sample statement; and aggregating all entity category annotation results of each sample statement to obtain the named entity label of each word in each sample statement.

[0014] According to another aspect of this disclosure, a method for entity recognition is provided, comprising: acquiring a statement to be recognized; processing the statement to be recognized by a trained entity recognition model to obtain predicted category labels for each word in the statement under named entity categories; wherein the trained entity recognition model is trained by the training method of the entity recognition model provided in this disclosure; and determining the named entity category of each word in the statement to be recognized based on the predicted category labels.

[0015] According to another aspect of this disclosure, a training apparatus for an entity recognition model is provided, comprising: a determination module for acquiring multiple sample sentences and determining named entity labels for each word in each sample sentence; a processing module for processing the multiple sample sentences through the entity recognition model to obtain word vectors for each word in each sample sentence, predicted labels for each word under named entity categories, and sentence vectors for each sample sentence; a loss calculation module for calculating label classification loss based on the named entity labels and predicted labels for each word; the loss calculation module is further configured to determine positive and negative examples of sentences based on the sentence vectors of the sample sentences, and calculate sentence dimension loss based on the positive and negative examples; the loss calculation module is further configured to determine positive and negative examples of words based on the named entity labels and word vectors of words, and calculate word dimension loss based on the positive and negative examples; and a training module for training the entity recognition model based on the label classification loss, sentence dimension loss, and word dimension loss to obtain a trained entity recognition model.

[0016] According to another aspect of this disclosure, an entity recognition apparatus is provided, comprising: an acquisition module for acquiring a statement to be recognized; an recognition module for processing the statement to be recognized using a trained entity recognition model to obtain predicted category labels for each word in the statement under named entity categories; wherein the trained entity recognition model is trained using the training method of the entity recognition model provided in this disclosure; and a category determination module for determining the named entity category of each word in the statement to be recognized based on the predicted category labels.

[0017] According to another aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described method for training an entity recognition model.

[0018] According to another aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the above-described training method for an entity recognition model by executing the executable instructions.

[0019] The entity recognition model training method provided in this disclosure first determines the named entity labels of each word in a sample sentence. Then, the entity recognition model processes the sample sentence to obtain word vectors, predicted labels of words under named entity categories, and sentence vectors of the sample sentence. Next, multiple dimensions of loss, including label classification loss, sentence dimension loss, and word dimension loss, can be calculated using the named entity labels, predicted labels, word vectors, and sentence vectors. Finally, the entity recognition model is trained based on the label classification loss, sentence dimension loss, and word dimension loss to obtain a trained entity recognition model. Therefore, this method can simultaneously train the entity recognition model using label classification loss to perform NER (Named Entity Recognition) tasks while constructing a multi-level contrastive learning model composed of sentence dimension loss and word dimension loss. This alleviates overfitting of the entity recognition model to label noise and promotes the utilization of pre-trained knowledge, thereby improving the overall performance of the entity recognition model and obtaining an entity recognition model with good entity category recognition performance.

[0020] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0021] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0022] Figure 1 A schematic diagram of an exemplary system architecture for training a training method of an entity recognition model to which embodiments of the present disclosure can be applied is shown;

[0023] Figure 2 A flowchart illustrating a training method for an entity recognition model according to an embodiment of the present disclosure is shown;

[0024] Figure 3 A flowchart illustrating the determination of named entity labels for words in a training method for an entity recognition model according to an embodiment of the present disclosure is shown.

[0025] Figure 4A flowchart illustrating the process of multiple sample sentences by an entity recognition model in a training method of an entity recognition model according to an embodiment of the present disclosure is shown.

[0026] Figure 5 This diagram illustrates a comparative learning process at the sentence dimension in a training method for an entity recognition model according to an embodiment of the present disclosure.

[0027] Figure 6 This diagram illustrates a comparative learning process at the word dimension in the training method of an entity recognition model according to an embodiment of the present disclosure.

[0028] Figure 7 A flowchart illustrating an entity recognition method according to an embodiment of this disclosure is shown;

[0029] Figure 8 A block diagram of a training apparatus for an entity recognition model according to an embodiment of the present disclosure is shown;

[0030] Figure 9 A block diagram of an entity recognition apparatus according to an embodiment of the present disclosure is shown; and

[0031] Figure 10 A structural block diagram of a computer device for training an entity recognition model according to an embodiment of the present disclosure is shown. Detailed Implementation

[0032] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0033] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0034] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this disclosure, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0035] Figure 1 A schematic diagram of an exemplary system architecture for training a method of entity recognition model to which embodiments of the present disclosure can be applied is shown.

[0036] like Figure 1 As shown, the system architecture may include a server 101, a network 102, and a client 103. The network 102 serves as the medium for providing a communication link between the client 103 and the server 101. The network 102 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0037] In an exemplary embodiment, server 101 may be a server providing various services, such as a backend management server supporting the device operated by the user using client 103. The backend management server can analyze and process received requests and other data, and feed the processing results back to client 103. Server 101 may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. In some practical applications, server 101 may also be a server for a network platform, such as a trading platform, live streaming platform, social platform, or music platform; this embodiment does not limit this. The server may be a single server or a cluster of multiple servers; this disclosure does not limit the specific architecture of the server.

[0038] In an exemplary embodiment, the client 103 that transmits data with the server 101 may include, but is not limited to, electronic devices such as smartphones, desktop computers, tablets, laptops, smart speakers, digital assistants, AR (Augmented Reality) devices, VR (Virtual Reality) devices, and smart wearable devices.

[0039] In an exemplary embodiment, the process by which server 101 implements the training method for the entity recognition model may be as follows: server 101 acquires multiple sample sentences and determines the named entity labels of each word in each sample sentence; server 101 processes the multiple sample sentences through the entity recognition model to obtain the word vectors of each word in each sample sentence, the predicted labels of each word under the named entity category, and the sentence vectors of each sample sentence; server 101 calculates the label classification loss based on the named entity labels and predicted labels of each word; server 101 determines the positive and negative examples of the sentences based on the sentence vectors of the sample sentences, and calculates the sentence dimension loss based on the positive and negative examples; server 101 determines the positive and negative examples of words based on the named entity labels and word vectors of the words, and calculates the word dimension loss based on the positive and negative examples; server 101 trains the entity recognition model based on the label classification loss, sentence dimension loss, and word dimension loss to obtain the trained entity recognition model.

[0040] In addition, it should be noted that, Figure 1 The example shown is merely one application environment of the training method for the entity recognition model provided in this disclosure. Figure 1 The number of servers 101, networks 102, and clients 103 shown is merely illustrative; any number of clients, networks, and servers can be used as needed.

[0041] To enable those skilled in the art to better understand the technical solutions of this disclosure, the following will describe in more detail each step of the training method for the entity recognition model in the example embodiments of this disclosure, in conjunction with the accompanying drawings and examples.

[0042] Figure 2 A flowchart illustrating a training method for an entity recognition model according to an embodiment of this disclosure is shown. The method provided in this disclosure can be employed by, for example... Figure 1 The server 101 or client 103 shown may execute this, but this disclosure is not limited thereto.

[0043] In the following example, server 101 is used as the execution subject for illustration.

[0044] like Figure 2 As shown, the training method for the entity recognition model provided in this embodiment may include the following steps.

[0045] Step S201: Obtain multiple sample statements and determine the named entity tags of each word in each sample statement.

[0046] In this step, multiple sample statements can include Chinese statements or foreign language statements from one or more domains. The named entity tags of each word in the sample statement can represent the named entity category corresponding to the word. The named entity category can come from the candidate entity set corresponding to the domain.

[0047] For example, if multiple sample sentences come from the Conll03 dataset (a standard dataset for named entity recognition and text segmentation that collects entities in English news text, including names of people, places, organizations, etc.), then the candidate entity set can include entity categories such as "personal name entity", "place name entity", "organization entity", and "other". If multiple sample sentences come from the BC5CDR dataset (a dataset for biomedical entity recognition and relation extraction that includes chemical substances and disease entities in the biomedical field), then the candidate entity set can include entity categories such as "chemical substance", "disease", "with treatment relationship", and "without treatment relationship".

[0048] In some practical applications, named entity tags for each word in each sample statement can be obtained from a specified database. Alternatively, a tagging tool can be used to automatically annotate the sample statements with named entity categories, thereby obtaining the named entity tags for each word in each sample statement. These named entity tags can be represented using vectors.

[0049] In some embodiments, named entity tags may include hard tags and soft tags, wherein hard tags may indicate the named entity category corresponding to a word, and soft tags may indicate the probability value of a word belonging to each named entity category.

[0050] For example, suppose there are four candidate named entity categories in the candidate entity set: "personal name entity", "place name entity", "organization entity", and "other". If the hard label of a Chinese character in a sample Chinese sentence is [0,1,0,0], it means that the named entity category corresponding to the Chinese character is "place name entity". If the soft label of the Chinese character is [0.1,0.8,0.07,0.03], it means that the probability values ​​of the Chinese character belonging to "personal name entity", "place name entity", "organization entity", and "other" are 0.1, 0.8, 0.07, and 0.03, respectively.

[0051] Figure 3 A flowchart illustrating the determination of named entity labels for words in a training method for an entity recognition model according to an embodiment of this disclosure is shown. For example... Figure 3 As shown, in one embodiment of this disclosure, step S201, "determining the named entity tags of each word in each sample statement", may further include the following steps.

[0052] Step S301: Use multiple named entity annotation functions to annotate the words in each sample statement with named entity categories, and obtain the entity category annotation results of each named entity annotation function for each word in each sample statement.

[0053] Named entity labeling functions can be, for example, LF functions (Labeling Functions). LF is a semi-supervised learning technique used to quickly label large-scale datasets, assigning labels to samples within the dataset. LF functions can handle complex labeling tasks, such as multi-label classification and entity relation extraction. Common labeling functions can include NER (Named Entity Recognition) models pre-trained on other datasets, and regular expression-based labeling functions (which can be used to match specific patterns or words in a document, thereby labeling entities within the document).

[0054] In this embodiment, multiple LF functions can be used to label the words in the sample statement with named entity categories. Each LF function can output a statement labeling result for the sample statement. This statement labeling result can consist of a set of weak labels, where each weak label is the entity category labeling result for a word in the sample statement. The weak labels can be from a set of labels. One-hot vectors under (i.e., candidate entity set).

[0055] For example, suppose there is a sample statement W, which has T characters, i.e., W = {w1, ..., w2}. t ,…,w T Given N labeling functions LF, the nth labeling function LF_n among the N labeling functions can obtain a statement labeling result after labeling the original sample statement W. t∈{1,…,T}; where, This can represent a weak label obtained by the labeling function LF_n labeling the t-th character in W, which is based on the label set. The representation is a one-hot vector, where 0 indicates a mismatch with the candidate entity category and 1 indicates a match. This one-hot vector can be used as the entity category labeling result for the word. To further illustrate, suppose a tag set... There are four candidate entity categories: “personal name entity”, “place name entity”, “organization entity”, and “other”. The labeling function LF_n determines that the t-th character in W belongs to the category “other”. Then the weak label (i.e. entity category labeling result) output by the labeling function LF_n for this character is [0,0,0,1].

[0056] Step S303: Aggregate all entity category annotation results for each sample statement to obtain named entity tags for each word in each sample statement.

[0057] A label aggregation model can be used to aggregate the annotation results of each sample sentence to obtain the aggregated label features of each sample sentence. The named entity tags of each word in the sample sentence can be elements in the aggregated label features of that sample sentence. Label aggregation models can be, for example, HMM (Hidden Markov Model), CHMM (Continuous Hidden Markov Model), or Sparse CHMM (Continuous Hidden Markov Model based on sparse structure).

[0058] The tag aggregation model can be used to analyze the N tagging results output by N tagging functions for sample statement W. The aggregation process is performed to obtain the aggregated label feature Y of the sample statement W. T ={y1,…,y t},y t ∈{0,1} L Aggregate label features Y T y in t It can be used as the named entity tag of the t-th character in W.

[0059] Taking a Hidden Markov Model (HMM) as an example for label aggregation, we can use the HMM to estimate the hidden value Z = {z1, ..., z2} based on the original sample sentence W and multiple observations (i.e., sentence labeling results) X. t After obtaining Z, the named entity label Y is calculated using the Viterbi algorithm. In addition to HMM, aggregation processing can also be achieved using CHMM and Sparse-CHMM algorithms, which are improvements on the HMM model.

[0060] Through such Figure 3The method for determining named entity labels for words, as shown, can automatically output the entity category labeling results for each word using an unsupervised method through a labeling function, and can automatically label the named entity labels for each word using a label aggregation model, thus achieving an automated entity category labeling method. Furthermore, by performing aggregation processing through the label aggregation model, an unsupervised method can be used to denoise and aggregate the weak labels output by multiple named entity labeling functions, reducing the noise present in the named entity labels and making the generated named entity labels as close as possible to the actual labels of each word in the sample sentence, thus reducing unnecessary interference data in subsequent model training steps and increasing the robustness and accuracy of the entity recognition model training method provided in this disclosure.

[0061] Furthermore, in some embodiments, the entity category annotation results of each sample statement are aggregated to obtain hard and soft tags for each word, which are then used as named entity tags for the word.

[0062] The soft label of a word can be obtained by using a label aggregation model and a softmax (soft maximum value function, or normalized exponential function) operator to output the probability of the word in each candidate named entity category. Then, a feature vector is generated based on these probabilities to serve as the soft label of the word. The hard label of a word can be obtained by using a label aggregation model and an argmax (maximum index function) operator to determine the named entity category in which the word has the highest probability. The element corresponding to the named entity category with the highest probability is then assigned a value of 1, and the elements in other positions are assigned a value of 0, thus generating a feature vector as the hard label of the word.

[0063] Step S203: Process multiple sample sentences through an entity recognition model to obtain the word vectors of each word in each sample sentence, the predicted labels of each word under the named entity category, and the sentence vectors of each sample sentence.

[0064] The entity recognition model can process sample sentences according to their word dimensions and perform NER tasks to extract multiple feature vectors for each word, including word vectors and predicted label vectors of words under named entity categories. It can also obtain sentence vectors of sample sentences based on word vectors. Then, word vectors, predicted labels, and sentence vectors are used for multi-level comparative learning in subsequent steps to train the entity recognition model.

[0065] The entity recognition model may include a sequence model, which extracts multiple feature vectors for each word in the sample sentence. The sequence model can be a feature extraction network model such as LSTM (Long Short-Term Memory) or BERT (Bidirectional Encoder Representations from Transformers, a deep bidirectional pre-trained language representation model based on Transformers), and this disclosure does not limit this to any particular model.

[0066] Step S205: Calculate the label classification loss based on the named entity label and predicted label of each word.

[0067] Label classification loss can be used to train an entity recognition model to fit the named entity category of each word in a sample sentence.

[0068] Step S207: Determine the positive and negative examples of the statements based on the statement vectors of the sample statements, and calculate the statement dimension loss based on the positive and negative examples.

[0069] By utilizing sentence dimension loss, comparative learning of sentence dimensions can be performed, allowing the entity recognition model to retain its ability to represent the entire sentence, rather than completely fitting to the parameter distribution under the noisy NER task, thereby mitigating overfitting.

[0070] Step S209: Determine positive and negative word examples based on the named entity tags and word vectors, and calculate word dimension loss based on the positive and negative word examples.

[0071] Since there may be mislabeled labels in the named entity labels of words, word dimension loss can be used to perform comparative learning at the word dimension. In the vector space composed of word vectors, the distance between word representations (i.e. word vectors) of the same entity category can be shortened, while the distance between word representations of different entity categories can be widened. The correspondence between word vectors and named entity labels helps the entity recognition model obtain more aligned word vectors, thereby promoting the named entity labels to better complete the NER task.

[0072] Specifically, since the essence of the NER task is word-level classification, each word representation can be assigned its most relevant label (i.e., predicted label). However, using contrastive learning based on word representations, entity recognition models tend to incorporate pre-trained knowledge (pre-trained word representations), meaning that word representations are restricted to other word representations under the same named entity label. If a word's label is incorrect (i.e., different from the actual label), then with the help of word-level contrastive learning, the word will still tend to be closer to other word representations with its correct label in the semantic space. This achieves a denoising effect and improves the entity recognition model's ability to represent word vectors.

[0073] Step S211: Train the entity recognition model based on label classification loss, sentence dimension loss and word dimension loss to obtain the trained entity recognition model.

[0074] Multiple losses calculated in steps S205 to S209 can be used together to train the entity recognition model. Among them, the label classification loss is used to directly characterize the effect of the entity recognition model in completing the NER task, while the sentence dimension loss and word dimension loss can be used to form multi-level contrastive learning to alleviate the overfitting of the entity recognition model to label noise, promote the utilization of pre-trained knowledge by the entity recognition model, and improve the overall performance of the entity recognition model.

[0075] In some practical applications, weight values ​​can be set for the label classification loss, sentence dimension loss, and word dimension loss respectively. The weight values ​​can be adjusted based on the actual training needs to control the degree of influence of different tasks (including NER tasks, sentence dimension contrastive learning tasks, and word dimension contrastive learning tasks) on the overall result.

[0076] The training method for the entity recognition model provided in this disclosure first determines the named entity labels of each word in the sample sentence. Then, the entity recognition model processes the sample sentence to obtain word vectors, predicted labels of words under named entity categories, and sentence vectors. Next, multiple dimensions of loss, including label classification loss, sentence dimension loss, and word dimension loss, are calculated using the named entity labels, predicted labels, word vectors, and sentence vectors. Finally, the entity recognition model is trained based on the label classification loss, sentence dimension loss, and word dimension loss to obtain the trained entity recognition model. It is evident that this method allows for the simultaneous training of the entity recognition model using label classification loss to perform NER (Named Entity Recognition) tasks, while simultaneously constructing a multi-level contrastive learning mechanism composed of sentence dimension loss and word dimension loss. This alleviates overfitting of the entity recognition model to label noise and promotes the utilization of pre-trained knowledge, thereby improving the overall performance of the entity recognition model and resulting in an entity recognition model with good entity category recognition performance.

[0077] Figure 4 A flowchart illustrating the process of multiple sample sentences using an entity recognition model in a training method according to an embodiment of this disclosure is provided. Figure 4 As shown, in some embodiments, step S203 may further include:

[0078] Step S401: Perform two forward processing steps on multiple sample sentences through the feature extraction network in the entity recognition model to obtain two processing results; wherein, each processing result includes: word vectors of each word in all sample sentences, and probability vectors of each word under the named entity category.

[0079] The entity recognition model can include the BERT model, which can be used to process sample sentences to obtain the results. The probability vector of a word can consist of multiple element values, where the total number of elements can be the number of candidate named entity categories, and each element value can represent the probability value of the word under the named entity category at the corresponding position.

[0080] In some practical applications, the BERT model can perform batch processing on data. Multiple sample statements can be used as a batch in the BERT model and fed together into the BERT model for processing (i.e., forward processing) to obtain a processing result.

[0081] Because the feature extraction network contains a dropout layer, the results of each forward processing step can be different. This characteristic can then be used in subsequent steps to simulate two different data augmentations on the sample statements to create positive and negative examples. Furthermore, this step can involve performing two forward processing steps on multiple sample statements to obtain two processing results, or performing more than two forward processing steps and then selecting two results to retain; this disclosure does not limit this approach.

[0082] Step S403: Use the word vectors in the first processing result of the two processing results as the word vectors of each word in each sample sentence.

[0083] Step S405: Determine the predicted label of each word under the named entity category based on the probability vector in the first processing result.

[0084] The first processing result can be either of the two processing results.

[0085] In some embodiments, step S405 may further include: using the probability vector in the first processing result as the soft prediction label for each word under the named entity category; determining the hard prediction label for each word under the named entity category based on the largest element in the probability vector in the first processing result; and determining the prediction label for each word under the named entity category based on the soft prediction label and the hard prediction label.

[0086] In this context, the logits directly output by the entity recognition model can be used as the soft prediction label. Logits is a vector of size equal to the number of categories, where each element corresponds to the score of a category.

[0087] Step S407: Perform pooling on the word vectors of each sample sentence in the two processing results to obtain two sentence vectors for each sample sentence.

[0088] In this step, pooling methods include, but are not limited to, mean pooling, maximum pooling, and directly using word vectors at the [CLS] (the marker used in the BERT model to represent the beginning of the input position) position.

[0089] In some embodiments, where the named entity label includes hard labels and soft labels, and the predicted label includes soft predicted labels and hard predicted labels, step S405 may further include: calculating a first label classification loss based on the soft labels and soft predicted labels; calculating a second label classification loss based on the hard labels and hard predicted labels; and determining the label classification loss based on the first label classification loss and the second label classification loss.

[0090] The first label classification loss can be understood as the KL divergence between the soft label and the soft predicted label, and the second label classification loss can be understood as the cross-entropy loss of the entity recognition model when performing the NER task. By determining the label classification loss based on the first label classification loss and the second label classification loss, the ability of the entity recognition model to complete the NER task can be trained more comprehensively.

[0091] In some embodiments, step S207, "determining positive and negative examples of statements based on the statement vectors of sample statements", may further include: for any target statement among a plurality of sample statements, taking the two statement vectors of the target statement as positive examples of statements, and taking any statement vector of the target statement and any statement vector of other statements besides the target statement as negative examples of statements.

[0092] For example, assuming that multiple sample statements include a first statement and a second statement, the two statement vectors of the first statement can be used as a pair of positive statements, and the two statement vectors of the second statement can also be used as a pair of positive statements. Then, the negative statements can be determined based on any statement vector of the first statement and any statement vector of the second statement.

[0093] In some practical applications, for the i-th sample statement and the j-th sample statement in the same processing batch, it is assumed that the feature extraction network has different dropout masks d corresponding to the i-th sample statement. i and d′ i There are different dropout masks dj and d′ corresponding to the j-th sample statement. i Then you can use and Represent the two statement vectors of the i-th sample statement, using and Let L represent the two statement vectors of the j-th sample statement. Then, the statement dimension loss L is calculated based on the positive and negative statements. scl The expression can be:

[0094]

[0095] Where sim(·) is a similarity measurement function, such as the cosine similarity function.

[0096] Figure 5 The diagram illustrates a comparative learning process at the sentence dimension in the training method of an entity recognition model according to an embodiment of this disclosure. Figure 5As shown, sentences 1 and 2 are included. The entity recognition model obtains sentence vectors 501 and 502 after processing sentence 1, and sentence vectors 503 and 504 after processing sentence 2. 501 and 502 can form a pair of positive sentences, and 503 and 504 can form another pair of positive sentences; 501 and 504 can form a pair of negative sentences, and 502 and 503 can form another pair of negative sentences. Positive sentences are connected by solid double-headed arrows, and negative sentences are connected by dashed double-headed arrows.

[0097] refer to Figure 5 The learning objective of contrastive learning at the sentence dimension is to narrow the distance between positive sentence examples and widen the distance between negative sentence examples, so that the entity recognition model retains its ability to represent the entire sentence, rather than completely fitting the parameter distribution under the noisy NER task, thereby alleviating overfitting.

[0098] In some embodiments, step S209, "determining positive and negative examples of words based on the named entity labels and word vectors of words", may further include: determining the named entity category to which each word belongs based on the named entity labels of each word; taking the word vectors of words with the same named entity category as positive examples of words, and taking the word vectors of words with different named entity categories as negative examples of words.

[0099] Specifically, word vectors of any two words with the same named entity category can be used as positive word examples, and word vectors of any two words with different named entity categories can be used as negative word examples. For example, for word A with a named entity category of "O (undefined entity)", the word vectors of word B, which is also in the category of "O", and A can be used as a pair of positive word examples, and the word vectors of word C, which is in the category of "B-LOC (location-starting)", and A can be used as a pair of negative word examples.

[0100] In some practical applications, in comparative learning at the word level, positive and negative examples can be constructed for each word. Specifically, for the word representation (word vector) e p Positive examples of related words χ p This can be represented as words with the same entity label (named entity category) in all sentences within the same processing batch:

[0101] χ p ={(e q ,y q )∈χ|y p =y q ,p≠q} (2)

[0102] In the above formula, assuming there are x sentences and y words in a training batch, p represents the p-th word among the y words, and q represents the q-th word among the y words. If the q-th word and the p-th word have the same entity label, then the representation of the q-th word is added to e. p The word is in the positive example.

[0103] Furthermore, the word dimension loss L is calculated based on positive and negative word examples. wcl The expression can be:

[0104]

[0105] Here, d(·) represents the distance metric function, such as Euclidean distance or cosine distance. The KL divergence of a Gaussian distribution can be used as the distance metric function. Specifically, the word representations can first be mapped to a Gaussian space:

[0106]

[0107] Here f μ (·) and f σ (·) represents the MLP layer, ∈≈1e-14. This is obtained by obtaining a Gaussian distribution (N) of word representations. p ,N q After that, the KL divergence D of the two distributions can be calculated. KL (N) p ,N q Since KL divergence is direction-dependent, the distance metric can be defined as:

[0108]

[0109] Figure 6 The diagram illustrates a word-dimensional contrastive learning process in the training method of an entity recognition model according to an embodiment of this disclosure. Figure 6 As shown, this includes four named entity categories: 601, 602, 603, and 604, and word vectors 605, 606, and 607, represented by squares. Word vectors 605, 606, and 607 correspond to words A, B, and C, respectively. Words A, B, and C are actually words belonging to the same named entity category 601 (in this embodiment, words of the same category are represented by identical patterns on the squares). Figure 6 As shown in the left-hand side, due to mislabeled tags in the named entity labels of these words, the word vector 607 of word C is not distributed in named entity category 601, but rather in named entity category 602. By constructing comparative learning at the word dimension, the distance between word vectors of the same type can be made closer, such as... Figure 6As shown in the right-hand section, the word vectors 608, 609, and 610 of words A, B, and C output by the trained entity recognition model are all distributed within their corresponding named entity categories 601. It can be seen that, through methods such as... Figure 6 The illustrated embodiment can optimize the distance between word vectors to reduce classification errors caused by mislabeled tags.

[0110] Figure 7 A flowchart of an entity recognition method according to an embodiment of this disclosure is shown, as follows: Figure 7 As shown, the entity recognition method provided in this embodiment may include the following steps.

[0111] Step S701: Obtain the statement to be recognized.

[0112] The statement to be recognized can be a statement from a dialogue, a statement from an article, etc.; the form of the statement to be recognized can be text information. In some practical applications, the statement to be recognized can also be text information converted from speech information, video information, or audio information.

[0113] Step S703: The entity recognition model is trained to process the sentence to be recognized and obtain the predicted category label of each word in the sentence under the named entity category; wherein, the trained entity recognition model is trained by the entity recognition model training method provided in this disclosure.

[0114] In this step, the trained entity recognition model processes the input statement to be recognized and outputs at least one of the hard prediction label and soft prediction label for each word in the statement under the named entity category. Then, the predicted category label can be determined based on at least one of the hard prediction label and soft prediction label.

[0115] In some embodiments, step S703 may further include: performing forward processing on the statement to be identified through the feature extraction network in the trained entity recognition model to obtain the predicted probability vector of each word in the statement under the named entity category; and determining the predicted category label of each word under the named entity category based on the maximum element in the predicted probability vector.

[0116] In this embodiment, each element in the prediction probability vector can represent the probability that a word belongs to each named entity category; the prediction probability vector of a word under a named entity category can be understood as the soft prediction label of the word under the named entity category. Determining the predicted category label of each word under the named entity category based on the largest element in the prediction probability vector can be understood as determining the hard prediction label of each word under the named entity category based on the largest element in the prediction probability vector, and then using the hard prediction label as the predicted category label.

[0117] Step S705: Determine the named entity category of each word in the sentence to be identified based on the predicted category label.

[0118] As mentioned above, the largest element in the predicted probability vector can be understood as the named entity category to which a certain word is most likely to belong. Therefore, the named entity category of each word in the sentence to be identified can be directly determined based on the predicted category label.

[0119] like Figure 7 The entity recognition method shown can process various business data for entity recognition in multiple business scenarios, and can meet the application needs of various business scenarios such as address classification, product name breakdown, and extraction of key attributes of User-Agent (UA).

[0120] Figure 7 Other aspects of the embodiments can be referred to in the other embodiments described above, and will not be repeated here.

[0121] The entity recognition method provided in this disclosure can process the sentence to be recognized by the trained entity recognition model and directly obtain the named entity category of each word in the sentence to be recognized. Furthermore, since the entity recognition model used is trained by the entity recognition model training method provided in this disclosure, the recognition result of the entity category to which each word in the sentence belongs is highly accurate and has a good recognition effect.

[0122] It should be noted that the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Furthermore, it is readily understood that these processes may, for example, be executed synchronously or asynchronously in multiple modules.

[0123] Figure 8 A block diagram of a training apparatus 800 for an entity recognition model according to an embodiment of the present disclosure is shown; as follows: Figure 8 As shown, it includes:

[0124] The determination module 801 is used to acquire multiple sample sentences and determine the named entity labels of each word in each sample sentence; the processing module 802 is used to process multiple sample sentences through an entity recognition model to obtain the word vectors of each word in each sample sentence, the predicted labels of each word under the named entity category, and the sentence vectors of each sample sentence; the loss calculation module 803 is used to calculate the label classification loss based on the named entity labels and predicted labels of each word; the loss calculation module 803 is also used to determine the positive and negative examples of the sentences based on the sentence vectors of the sample sentences, and calculate the sentence dimension loss based on the positive and negative examples; the loss calculation module 803 is also used to determine the positive and negative examples of words based on the named entity labels and word vectors of words, and calculate the word dimension loss based on the positive and negative examples of words; the training module 804 is used to train the entity recognition model based on the label classification loss, sentence dimension loss, and word dimension loss to obtain the trained entity recognition model.

[0125] The training apparatus for the entity recognition model provided in this disclosure allows for the first determination of named entity labels for each word in a sample sentence. Then, the entity recognition model processes the sample sentence to obtain word vectors, predicted labels for each word under its named entity category, and sentence vectors. Next, the named entity labels, predicted labels, word vectors, and sentence vectors are used to calculate losses across multiple dimensions, including label classification loss, sentence dimension loss, and word dimension loss. Finally, the entity recognition model is trained based on these losses to obtain a trained entity recognition model. Therefore, this method allows for the simultaneous training of the entity recognition model using label classification loss for NER (Named Entity Recognition) tasks, while simultaneously constructing a multi-level contrastive learning mechanism composed of sentence dimension loss and word dimension loss. This mitigates overfitting of the entity recognition model to label noise and promotes the utilization of pre-trained knowledge, thereby improving the overall performance of the entity recognition model and resulting in an entity recognition model with good entity category recognition performance.

[0126] In some embodiments, the processing module 802 processes multiple sample sentences through an entity recognition model to obtain word vectors of each word in each sample sentence, predicted labels of each word under named entity categories, and sentence vectors of each sample sentence. This includes: performing two forward processing steps on the multiple sample sentences through a feature extraction network in the entity recognition model to obtain two processing results; wherein each processing result includes: word vectors of each word in all sample sentences, and probability vectors of each word under named entity categories; using the word vectors in the first processing result as word vectors of each word in each sample sentence; determining the predicted labels of each word under named entity categories based on the probability vectors in the first processing result; and performing pooling processing on the word vectors of each word in each sample sentence in the two processing results to obtain two sentence vectors for each sample sentence.

[0127] In some embodiments, the processing module 802 determines the predicted label of each word under the named entity category based on the probability vector in the first processing result, including: using the probability vector in the first processing result as the soft predicted label of each word under the named entity category; determining the hard predicted label of each word under the named entity category based on the largest element in the probability vector in the first processing result; and determining the predicted label of each word under the named entity category based on the soft predicted label and the hard predicted label.

[0128] In some embodiments, named entity labels include hard labels and soft labels. Hard labels indicate the named entity category corresponding to a word, and soft labels indicate the probability value of a word belonging to each named entity category. The loss calculation module 803 calculates the label classification loss based on the named entity labels and predicted labels of each word, including: calculating a first label classification loss based on the soft labels and soft predicted labels; calculating a second label classification loss based on the hard labels and hard predicted labels; and determining the label classification loss based on the first label classification loss and the second label classification loss.

[0129] In some embodiments, the loss calculation module 803 determines positive and negative examples of statements based on the statement vectors of sample statements, including: for any target statement among a plurality of sample statements, taking two statement vectors of the target statement as positive examples of statements, and taking any statement vector of the target statement and any statement vector of other statements besides the target statement as negative examples of statements.

[0130] In some embodiments, the loss calculation module 803 determines positive and negative word examples based on the named entity labels and word vectors of the words, including: determining the named entity category to which each word belongs based on the named entity labels of each word; taking the word vectors of words with the same named entity category as positive word examples, and taking the word vectors of words with different named entity categories as negative word examples.

[0131] In some embodiments, the determining module 801 determines the named entity tags of each word in each sample statement, including: using multiple named entity annotation functions to annotate the named entity categories of the words in each sample statement, and obtaining the entity category annotation results of each named entity annotation function for each word in each sample statement; and aggregating all entity category annotation results of each sample statement to obtain the named entity tags of each word in each sample statement.

[0132] Figure 8 Other aspects of the embodiments can be found in the other embodiments described above.

[0133] Figure 9 A block diagram of an entity recognition apparatus 900 according to an embodiment of the present disclosure is shown, as follows: Figure 9 As shown, it includes: an acquisition module 901, used to acquire the statement to be recognized; an identification module 902, used to process the statement to be recognized through a trained entity recognition model to obtain the predicted category label of each word in the statement under the named entity category; wherein, the trained entity recognition model is trained by the training method of the entity recognition model provided in this disclosure; and a category determination module 903, used to determine the named entity category of each word in the statement to be recognized based on the predicted category label.

[0134] In some embodiments, the recognition module 902 processes the statement to be recognized through the trained entity recognition model to obtain the predicted category label of each word in the statement under the named entity category, including: performing forward processing on the statement to be recognized through the feature extraction network in the trained entity recognition model to obtain the predicted probability vector of each word in the statement under the named entity category; and determining the predicted category label of each word under the named entity category based on the largest element in the predicted probability vector.

[0135] The entity recognition apparatus provided in this disclosure can process the sentence to be recognized by the trained entity recognition model and directly obtain the named entity category of each word in the sentence to be recognized. Furthermore, since the entity recognition model used is trained by the entity recognition model training method provided in this disclosure, the recognition result of the entity category to which each word in the sentence belongs is highly accurate and has a good recognition effect.

[0136] Those skilled in the art will understand that various aspects of the present invention can be implemented as systems, methods, or program products. Therefore, various aspects of the present invention can be specifically implemented in the following forms: entirely hardware implementations, entirely software implementations (including firmware, microcode, etc.), or implementations combining hardware and software aspects, collectively referred to herein as “circuits,” “modules,” or “systems.”

[0137] Figure 10 This diagram illustrates a structural block diagram of a computer device for training an entity recognition model according to an embodiment of the present disclosure. It should be noted that the illustrated electronic device is merely an example and should not be construed as limiting the functionality or scope of the embodiments of the present invention.

[0138] The following reference Figure 10 To describe an electronic device 1000 according to this embodiment of the present invention. Figure 10 The electronic device 1000 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0139] like Figure 10 As shown, the electronic device 1000 is manifested in the form of a general-purpose computing device. The components of the electronic device 1000 may include, but are not limited to: at least one processing unit 1010, at least one storage unit 1020, and a bus 1030 connecting different system components (including storage unit 1020 and processing unit 1010).

[0140] The storage unit stores program code that can be executed by the processing unit 1010, causing the processing unit 1010 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 1010 can perform, as follows: Figure 2 The method shown.

[0141] Storage unit 1020 may include readable media in the form of volatile storage units, such as random access memory (RAM) 10201 and / or cache memory 10202, and may further include read-only memory (ROM) 10203.

[0142] Storage unit 1020 may also include a program / utility 10204 having a set (at least one) program module 10205, such program module 10205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0143] Bus 1030 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the multiple bus structures.

[0144] Electronic device 1000 can also communicate with one or more external devices 1100 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with electronic device 1000, and / or any device that enables electronic device 1000 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 1050. Furthermore, electronic device 1000 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 1060. As shown, network adapter 1060 communicates with other modules of electronic device 1000 via bus 1030. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0145] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above is stored. In some possible embodiments, various aspects of the invention may also be implemented as a program product comprising program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of the invention described in the "Exemplary Methods" section of this specification.

[0146] According to embodiments of the present invention, a program product for implementing the above-described method may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0147] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0148] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0149] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0150] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0151] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0152] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.

[0153] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0154] According to one aspect of this disclosure, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the above embodiments.

[0155] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.

Claims

1. A method for training an entity recognition model, the method comprising: include: Obtain multiple sample statements and determine the named entity tags of each word in each sample statement; The entity recognition model processes the multiple sample sentences to obtain the word vectors of each word in each sample sentence, the predicted labels of each word under the named entity category, and the sentence vectors of each sample sentence. Calculate the label classification loss based on the named entity labels and predicted labels of each word; Based on the statement vector of the sample statement, positive and negative statements are determined, and statement dimension loss is calculated based on the positive and negative statements. Based on the named entity tags and word vectors of the words, positive and negative examples of the words are determined, and word dimension loss is calculated based on the positive and negative examples of the words. The entity recognition model is trained using the label classification loss, the sentence dimension loss, and the word dimension loss to obtain the trained entity recognition model.

2. The method of claim 1, wherein, The multiple sample sentences are processed by an entity recognition model to obtain the word vectors of each word in each sample sentence, the predicted labels of each word under the named entity category, and the sentence vectors of each sample sentence, including: The feature extraction network in the entity recognition model performs two forward processing steps on the multiple sample sentences to obtain two processing results; each processing result includes: the word vector of each word in all sample sentences, and the probability vector of each word under the named entity category; The word vectors in the first processing result of the two processing results are used as the word vectors of each word in each sample sentence; The predicted label of each word under the named entity category is determined based on the probability vector in the first processing result; Pooling is performed on the word vectors of each sample sentence in the two processing results to obtain two sentence vectors for each sample sentence.

3. The method according to claim 2, characterized in that, Based on the probability vector in the first processing result, the predicted label of each word under the named entity category is determined, including: The probability vectors in the first processing result are used as soft prediction labels for each word under the named entity category; The hard predicted label of each word under the named entity category is determined based on the maximum element in the probability vector of the first processing result. The predicted label for each word under the named entity category is determined based on the soft prediction label and the hard prediction label.

4. The method according to claim 3, characterized in that, The named entity tags include hard tags and soft tags. The hard tags indicate the named entity category corresponding to the word, and the soft tags indicate the probability value of the word belonging to each named entity category. The label classification loss is calculated based on the named entity labels and predicted labels of each word, including: Calculate the first label classification loss based on the soft label and the soft predicted label; Calculate the second label classification loss based on the hard label and the hard predicted label; The label classification loss is determined based on the first label classification loss and the second label classification loss.

5. The method according to claim 2, characterized in that, Based on the statement vector of the sample statements, positive and negative statements are determined, including: For any target statement among the plurality of sample statements, the two statement vectors of the target statement are taken as positive examples of the statement, and any statement vector of the target statement and any statement vector of other statements besides the target statement are taken as negative examples of the statement.

6. The method according to claim 1, characterized in that, Based on the named entity tags and word vectors of the words, positive and negative examples of the words are determined, including: The named entity category to which each word belongs is determined based on the named entity tag of each word; The word vectors of words with the same named entity category are used as positive examples of the word, and the word vectors of words with different named entity categories are used as negative examples of the word.

7. The method according to any one of claims 1-6, characterized in that, Determine the named entity tags for each word in each sample statement, including: Multiple named entity annotation functions are used to annotate the words in each sample sentence with named entity categories, and the entity category annotation results of each named entity annotation function for each word in each sample sentence are obtained. The entity category annotation results for each sample statement are aggregated to obtain the named entity tags for each word in each sample statement.

8. A method for entity recognition, characterized in that, include: Obtain the statement to be recognized; The entity recognition model is trained to process the sentence to be recognized, and the predicted category label of each word in the sentence to be recognized under the named entity category is obtained; wherein the trained entity recognition model is trained by the method described in any one of claims 1 to 7. The named entity category of each word in the sentence to be identified is determined based on the predicted category label.

9. The method according to claim 8, characterized in that, The trained entity recognition model processes the sentence to be recognized to obtain the predicted category label of each word in the sentence under the named entity category, including: The feature extraction network in the trained entity recognition model is used to perform forward processing on the sentence to be recognized, so as to obtain the predicted probability vector of each word in the sentence under the named entity category. The predicted category label for each word under the named entity category is determined based on the largest element in the predicted probability vector.

10. A training device for an entity recognition model, characterized in that, include: The determination module is used to acquire multiple sample statements and determine the named entity tags of each word in each sample statement; The processing module is used to process the multiple sample sentences through an entity recognition model to obtain the word vector of each word in each sample sentence, the predicted label of each word under the named entity category, and the sentence vector of each sample sentence. The loss calculation module is used to calculate the label classification loss based on the named entity labels and predicted labels of each word; The loss calculation module is also used to determine positive and negative examples of statements based on the statement vector of the sample statements, and to calculate the statement dimension loss based on the positive and negative examples of statements. The loss calculation module is also used to determine positive and negative word examples based on the named entity tags and word vectors of the words, and to calculate word dimension loss based on the positive and negative word examples; The training module is used to train the entity recognition model based on the label classification loss, the sentence dimension loss, and the word dimension loss, so as to obtain the trained entity recognition model.

11. An entity recognition device, characterized in that, include: The acquisition module is used to acquire the statement to be recognized; The recognition module is used to process the sentence to be recognized through a trained entity recognition model to obtain the predicted category label of each word in the sentence under the named entity category; wherein the trained entity recognition model is trained by the method described in any one of claims 1 to 7. The category determination module is used to determine the named entity category of each word in the sentence to be identified based on the predicted category label.

12. A computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement a training method for an entity recognition model as claimed in any one of claims 1 to 7 or a method for entity recognition as claimed in any one of claims 8 to 9.

13. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the training method of the entity recognition model as claimed in any one of claims 1 to 7 or the entity recognition method as claimed in any one of claims 8 to 9.