Named entity recognition method and device, computer device and readable storage medium

By combining a feature extraction network and a dual affine classifier with a two-dimensional labeled named entity recognition model, the problem of incomplete or inaccurate nested entity recognition in existing technologies is solved, achieving efficient and accurate named entity recognition while reducing computational resource consumption.

CN115952800BActive Publication Date: 2026-04-10HANGZHOU HENGSHENG JUYUAN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU HENGSHENG JUYUAN INFORMATION TECH CO LTD
Filing Date
2022-12-29
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing named entity recognition methods are prone to misidentification of non-entities during the recall and decoding processes, resulting in inaccurate recognition results. This is especially true when dealing with nested entities, where recall is incomplete or recognition is inaccurate. Furthermore, the model training resources are too large, making it difficult to implement.

Method used

A named entity recognition model is adopted, which combines a feature extraction network, a linear mapping layer, a dual affine classifier and a decoding module, with two-dimensional annotation of entity boundaries and word relationships. The model is decoded using a label information matrix, and the probability of nested entities is calculated and the named entity with the highest probability is retained. The model training process is optimized to balance the label distribution.

Benefits of technology

It improves the accuracy of named entity recognition, reduces computational resource consumption, better identifies nested entities, and ensures that the recognition results are semantically consistent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115952800B_ABST
    Figure CN115952800B_ABST
Patent Text Reader

Abstract

The application provides a named entity recognition method and device, computer equipment and a readable storage medium, comprising: predicting a label information matrix corresponding to to-be-recognized text and a probability corresponding to each label in the label information matrix through a named entity recognition model, determining two characters corresponding to a word relationship label in the label information matrix as a group of adjacent entity characters, determining two characters corresponding to an entity boundary label as a group of entity head characters and entity tail characters, extracting at least one named entity from the to-be-recognized text based on the adjacent entity characters and the entity head characters and the entity tail characters; for two nested named entities with different categories, taking the mean of the probabilities of the word relationship labels corresponding to all adjacent entity characters in each named entity as the probability of each named entity, and retaining the named entity with the maximum probability. The application can accurately recognize named entities in accordance with semantics based on the probability of the word relationship label, and improves the recognition accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of natural language processing, in particular to a named entity recognition method and device, computer equipment and readable storage medium. BACKGROUND

[0002] Named Entity Recognition (NER) refers to recognizing entities with specific meanings in a text, mainly including names, place names, organization names, proper nouns, etc. NER is an important basic tool in application fields such as information extraction, question and answer systems, syntax analysis, machine translation, and metadata annotation for Semantic Web, and plays an important role in the process of making natural language processing technology practical.

[0003] At present, the model-based named entity recognition method can recall the start and end characters of the entity, and then a heuristic decoding method similar to SpanNer is used to return the final entity. However, this decoding method is prone to decoding non-entities, and if there are overlapping entities, the entity recalled by this decoding method may not match the actual semantics, so the accuracy of this decoding method is low. Therefore, it is an urgent technical problem to accurately recognize named entities. SUMMARY

[0004] One of the purposes of the present application is to provide a named entity recognition method, device, computer equipment and readable storage medium, which can make the recognized named entities consistent with the actual semantics and improve the accuracy of the recognition results. The technical solution of the present application can be implemented as follows:

[0005] In a first aspect, the present application provides a named entity recognition method, which comprises: predicting a label information matrix corresponding to a to-be-recognized text and a probability corresponding to each label in the label information matrix through a named entity recognition model; wherein the label is used to represent the relationship category of any two characters in the to-be-recognized text; the label includes a word relationship label and an entity boundary label; determining two characters corresponding to the word relationship label as a group of adjacent entity characters, determining two characters corresponding to the entity boundary label as a group of entity head characters and entity tail characters, and extracting at least one named entity from the to-be-recognized text based on the adjacent entity characters and the entity head characters and entity tail characters; for two named entities with different categories and nesting, taking the mean value of the probability of the word relationship label corresponding to all adjacent entity characters in each named entity as the probability of each named entity, and retaining the named entity with the maximum probability.

[0006] In a second aspect, the present application provides a named entity recognition device, comprising a prediction module, a decoding module and an identification module; the prediction module is configured to predict, by a named entity recognition model, a label information matrix corresponding to a to-be-identified text and a probability corresponding to each label in the label information matrix; wherein the label is used to represent a relationship category of any two characters in the to-be-identified text; the label comprises a word relationship label and an entity boundary label; the decoding module is configured to determine two characters corresponding to the word relationship label as a group of adjacent entity characters, determine two characters corresponding to the entity boundary label as a group of entity head characters and entity tail characters, and extract at least one named entity from the to-be-identified text based on the adjacent entity characters and the entity head characters and entity tail characters; the identification module is configured to, for two named entities of different categories and nesting, take an average of probabilities of the word relationship labels corresponding to all the adjacent entity characters in each named entity as a probability of each named entity, and retain the named entity with the maximum probability.

[0007] In a third aspect, the present application provides a computer device, comprising a processor and a memory, wherein the memory stores a computer program capable of being executed by the processor, and the processor can execute the computer program to implement the method of the first aspect.

[0008] In a fourth aspect, the present application provides a readable storage medium, wherein the readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method of the first aspect.

[0009] The named entity recognition method, device, computer device and readable storage medium provided by the present application firstly predict, by a named entity recognition model, a label information matrix corresponding to a to-be-identified text and a probability corresponding to each label in the label information matrix; the label information matrix comprises a word relationship label and an entity boundary label, so two characters corresponding to the word relationship label can be determined as a group of adjacent entity characters, two characters corresponding to the entity boundary label in the label information matrix can be determined as a group of entity head characters and entity tail characters, and at least one named entity can be extracted from the to-be-identified text based on the adjacent entity characters and the entity head characters and entity tail characters; finally, for two named entities of different categories and nesting, an average of probabilities of the word relationship labels corresponding to all the adjacent entity characters in each named entity is taken as a probability of each named entity, and the named entity with the maximum probability is retained. The present application introduces two-dimensional joint labeling of entity boundary and word relationship for decoding, which can guarantee the recall of named entities and also obtain the probability of adjacent entity characters, and finally can accurately identify named entities meeting semantics based on the probability of the word relationship label, thereby improving the recognition accuracy. BRIEF DESCRIPTION OF DRAWINGS

[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0011] Figure 1 The structural example diagram of the named entity recognition model provided for the embodiments of the present application is shown in the figure.

[0012] Figure 2 The example diagram of the label information matrix provided for the embodiments of the present application is shown in the figure.

[0013] Figure 3 The application environment schematic diagram provided for the embodiments of the present application is shown in the figure.

[0014] Figure 4 The training method schematic diagram of the named entity recognition model provided for the embodiments of the present application is shown in the figure.

[0015] Figure 5 The step S420 schematic flow chart provided for the embodiments of the present application is shown in the figure.

[0016] Figure 6 The named entity recognition method schematic flow chart provided for the embodiments of the present application is shown in the figure.

[0017] Figure 7 The step S520 schematic flow chart provided for the embodiments of the present application is shown in the figure.

[0018] Figure 8 The function module diagram of the named entity recognition device provided for the embodiments of the present application is shown in the figure.

[0019] Figure 9 The structural schematic diagram of the computer device provided for the embodiments of the present application is shown in the figure. DETAILED DESCRIPTION

[0020] In order to make the purpose, technical solutions and advantages of the embodiments of the present application more clear, the following will combine the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, not all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0021] Therefore, the following detailed description of the embodiments of the application provided in the accompanying drawings is not intended to limit the scope of the application claimed, but merely represents selected embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of the application.

[0022] It should be noted that similar reference numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0023] In the description of the application, it should be noted that if the terms "upper", "lower", "inner", "outer" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, or the orientation or positional relationship of the product in use, only for the convenience of describing the application and simplifying the description, and not to indicate or imply that the device or element must have a particular orientation, be constructed and operated in a particular orientation, therefore, it cannot be understood as a limitation on the application.

[0024] In addition, if the terms "first", "second" and the like are used only to distinguish the description, and cannot be understood as indicating or implying relative importance.

[0025] It should be noted that the features in the embodiments of the application can be combined with each other without conflict.

[0026] Named entity refers to the name of a person, an organization, a place, and all other entities identified by name, which is divided into general entities, nested entities, and non-continuous entities according to form, for example: "Guangzhou University" is a place entity, "Guangzhou" in "Guangzhou University" is also a place entity, and the two entities have a nested relationship. For example, in the cumulative district-level financial revenue of 123 million yuan, an increase of 3.5% over the same period, "cumulative district-level financial revenue" and "cumulative district-level financial revenue" are economic entities, and "cumulative district-level financial revenue" is a non-continuous entity.

[0027] Named entity recognition refers to the recognition of named entities in a text sentence, which can be realized by training corresponding models, such as deepbiaffine and globalpointer models that can recognize general entities and nested entities, and w2ner that can support general entities, nested entities and non-continuous entity recognition.

[0028] W2NER is the most commonly used named entity recognition model at present, the essence of W2NER is to recall named entities based on entity boundary task (referred to as task one), and then extract continuous or discontinuous entity fragments between the head and tail of the entity according to the word and word relationship task (referred to as task two). On the one hand, this method cannot identify the entities that task one does not recall, and may also mistakenly kill the correct entities recalled by task one in task two, resulting in incomplete or inaccurate named entity recognition results.

[0029] For example, "Guanghua Management College of Peking University" and "Peking University" are two nested organization entities, if only the boundary of "Beijing + University" is recalled, then no matter how it is impossible to identify the organization entity "Guanghua Management College of Peking University", resulting in the problem of incomplete recognition result; when the boundary of "Beijing + University" is recalled, it may not be able to accurately identify the entity fragment in "Beijing + University", which leads to the problem of inaccurate recognition result.

[0030] In actual production environment, the large gpu memory occupied by w2ner training and the long time consumption of reasoning make it difficult to land the method.

[0031] Therefore, the named entity recognition model provided by the application, please see Figure 1 , Figure 1 The structural example diagram of the named entity recognition model provided by the embodiment of the application.

[0032] As shown in Figure 1 The named entity recognition model provided by the embodiment of the application comprises a feature extraction network, a linear mapping layer, a double affine classifier and a decoding module connected in sequence, and a position coding process is further arranged in the linear mapping layer and the double affine classifier.

[0033] The feature extraction network can be but is not limited to a bert model, the input of the feature extraction network is a character (token) sequence corresponding to the text, the feature extraction network can obtain the vector representation of the semantic features of the token sequence by performing feature extraction on the token sequence, for example, if the length of the token sequence is N, then the semantic features are N L vector representation, wherein L is the hidden layer dimension of the feature extraction network, for example, the L of the bert model is 768, so the semantic features are N 768-dimensional vector representation.

[0034] N The semantic feature vector of L is input to a linear mapping layer, and the linear mapping layer reduces the dimension of the semantic feature vector. Specifically, the linear mapping layer can be a gated linear unit (GLU), which actively learns which dimensions to retain and which dimensions to eliminate in the word semantic feature vector through the gating unit, thereby achieving the effect of dimension reduction. For example, assuming that the word semantic feature vector is N 768, then after model training, the linear mapping layer can reduce the semantic feature vector to N 128-dimensional vector representation.

[0035] The embodiment of the present application considers that the parameter dimension of the two-dimensional annotation system is n n h index, where n represents the sequence length, and h represents the hidden layer dimension of the encoding model (such as BERT768), so it is necessary to better save computing resources while minimizing precision loss. Therefore, the embodiment of the present application adds a linear mapping layer in the named entity model to realize dimension reduction, sets the maximum length of the sequence to not more than 256, and removes the bidirectional recurrent neural network unit (BiLSTM) in W2NER. In this way, the precision loss is small, and the parameter amount is greatly reduced, thereby improving the processing efficiency of the named entity model.

[0036] To consider the key information of the distance between the entity head and tail, the embodiment of the present application introduces a rotating position encoding (RoPE) based on the semantic feature vector after dimension reduction by the linear mapping layer. After applying RoPE, the semantic feature vectors at different positions are attenuated according to the relative distance when performing inner product, and the position encoding can greatly improve the entity recognition effect.

[0037] The double-affine classifier is used to predict the relationship category between any two tokens, and a label information matrix is obtained, the size of the label information matrix is N N, which is constructed based on the length N of the token sequence. Each element in the label information matrix represents a label of a relationship category. The relationship category can have three types: non-entity relationship, entity adjacent character relationship, and entity boundary relationship. The entity adjacent character relationship corresponds to a word relationship label, the entity boundary relationship corresponds to an entity boundary label, and the non-entity relationship corresponds to a padding label (or non-entity label). These labels can be represented by different numerical values.

[0038] For easy understanding, please refer to Figure 2 , Figure 2 An example diagram of a label information matrix provided by the embodiment of the present application is shown. The label information matrix can be divided into a word relationship information area and an entity boundary information area by the diagonal line.

[0039] The word relationship information area maintains a label between a character in a text and each character located after the character, including a word relationship label and a non-entity label (such as a value 1 and a value 0 in Figure 2 The entity boundary information area maintains a label corresponding to each character of a character except the first character and located before the character, including an entity boundary label and a non-entity label (such as a value 2 and 0 in Figure 2 The value of the entity boundary label has a mapping relationship with the entity category, so when there are multiple named entities in a text, the corresponding entity boundary labels can be sequentially numbered based on the named entity category, for example, from 2 to m, where m is the number of entity categories; the two characters corresponding to the word relationship label belong to two adjacent characters in the same named entity, the two characters corresponding to the entity boundary label are the head and tail of the same named entity, and the non-entity label represents that the two characters do not belong to the same entity.

[0040] It should be noted that the above values 0, 1 and 2 are only an example of distinguishing the word relationship label, the entity boundary label and the non-entity label, and the above three labels can also be distinguished by other identifiers, and the embodiments of the present application do not limit this.

[0041] The decoding module can decode and recognize the final named entity based on the above obtained label information matrix. Compared with the decoding mode of the traditional heuristic decoding such as SpanNer using the probability of entity boundary, the decoding module in the embodiment of the present application can determine the final entity recognition result by comparing the probability of word and word relationship and the probability of overlapping entity, so as to improve the accuracy of named entity recognition, and the recognition result can be consistent with the actual semantics.

[0042] Based on the named entity model shown in Figure 1 The embodiments of the present application also provide a named entity recognition model training method and a named entity recognition method.

[0043] Considering that in the current named entity model training mode, on the one hand, a named entity has one entity boundary label but e-1 word relationship labels (e is the number of characters in the entity), which leads to uneven distribution of entity boundary labels and word relationship labels, and on the other hand, the labels of different named entity categories are also unevenly distributed, which affects the model training effect, therefore, the named entity recognition model training method provided by the embodiments of the present application can solve the above problems.

[0044] The named entity recognition model training method provided by the present application can be applied to the application environment as shown in Figure 3 Figure 3 ​An application environment schematic diagram provided by the embodiment of the present application is shown in the figure. After the server 104 obtains the training sample labeled with the named entity, the server 104 can first perform data enhancement based on the entity and entity boundary sample in the database 106, then determine the respective weights of the entity boundary label and the word relationship label, construct a total loss function of the named entity recognition model based on the respective weights of the entity boundary label and the word relationship label and the loss function of the entity boundary label and the word relationship label, finally train the named entity recognition model through the training sample and the entity boundary sample to obtain the loss value of the total loss function, and continue to train the named entity recognition model after adjusting the parameters of the named entity recognition model based on the loss value until the training is completed to obtain the trained named entity recognition model. In addition, the trained named entity recognition model can also be transplanted to other servers to perform named entity recognition processing by the other servers, or the trained named entity recognition model can also be loaded into the terminal 102 to enable the terminal 102 to have the named entity recognition capability.

[0045] Considering that the current named entity recognition model trains the corpus through data enhancement, which leads to an increase in the number of entities recalled by the decoding method used first, which means that there will be many overlapping entities, but there may be entities that do not conform to the actual semantics among the recalled entities, so that the entity recognition result is not accurate, therefore the embodiment of the present application also provides a named entity recognition method.

[0046] The named entity recognition method provided by the embodiment of the present application can also be applied Figure 3 As shown in the application environment, the terminal 102 communicates with the server 104 through a network. The terminal 102 can collect a sentence to be recognized and send the sentence to be recognized to the server 104. After receiving the sentence to be recognized, the server 104 determines the label information matrix corresponding to the sentence to be recognized, determines the adjacent entity character and the entity head character and the entity tail character, and extracts at least one named entity from the text to be recognized based on the adjacent entity character and the entity head character and the entity tail character. Then, based on the probability of the word relationship label, the two named entities of the named entity with different categories and nested are identified, and the named entity that finally accurately conforms to the actual semantics is retained. The server 104 can send the identification result to the terminal 102. In addition, the server 104 can also obtain the sentence to be recognized from the database and perform named entity recognition processing on the obtained sentence.

[0047] In the embodiment of the present application, the terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented by an independent server or a server cluster composed of multiple servers.

[0048] The training method of the named entity recognition model is appliedFigure 1 Taking server 104 as an example, let's introduce... Figure 1 The training method of the named entity recognition model shown is as follows: Figure 4 As shown, Figure 4 A schematic diagram of a training method for a named entity recognition model provided in an embodiment of the present invention includes the following steps:

[0049] S410: Obtain multiple training samples and perform data augmentation on the multiple training samples; the training samples have entity boundary labels and word relation labels.

[0050] In the embodiments of the present invention, as Figure 2 As shown, the training samples are labeled with the relationship category to which any two characters belong. For example, in the implementation process, the word relationship label corresponding to adjacent entity characters within the same named entity can be represented by 1, and the two characters that are not related to an entity can be represented by 0. The entity boundary label can be numbered sequentially starting from the value 2 based on the named entity category. For example, the entity boundary label corresponding to the first named entity category is 2, the entity boundary label corresponding to the second named entity category is 3, and so on.

[0051] In this embodiment of the invention, data augmentation of training samples can increase the entity density in the training samples and improve the entity boundary recall rate.

[0052] S420: Divide multiple training samples into multiple batches and determine the weights of word relation labels and entity boundary labels in each batch of training samples.

[0053] In this embodiment of the invention, the weights of word relation labels and each entity boundary label are used to construct the total loss function of the named entity recognition model, which can solve the problem that the uneven distribution of word relation labels and entity boundary labels affects the training effect of the model.

[0054] S430: Construct the total loss function of the named entity recognition model for each batch of training samples based on the weights of the word relation labels and the entity boundary labels in each batch of training samples, and the loss functions corresponding to the word relation labels and entity boundary labels.

[0055] In this embodiment of the invention, the total loss function of the named entity recognition model is in the form of formula (1):

[0056]

[0057] in, The weight of the word relationship label; The weight representing the boundary label of the i-th entity; and These are preset parameters; n is the number of types of entity boundary labels; a loss function of word relation labels; a loss function of entity boundary labels, and The expressions of the loss functions of the word relation labels and the entity boundary labels are respectively as formula (2) and formula (3):

[0058]

[0059] wherein, and respectively represent the i-th probability in the word relation information region and the actual label of the two characters corresponding to the i-th probability; and respectively represent the i-th probability in the entity relation information region and the actual label of the two characters corresponding to the i-th probability.

[0060] S440: input each batch of training samples into the named entity recognition model to be trained for model training until the total loss function converges, and obtain the trained named entity recognition model.

[0061] As can be seen, the named entity model is trained by training the initial named entity model with the data-enhanced training samples in a manner that the pre-constructed total loss function converges, and the total loss function is constructed based on the loss functions of the word relation labels and the entity boundary labels and the weights.

[0062] In the optional implementation, the data enhancement on the training samples can increase the recall rate of the entity boundary, and avoid incomplete recall results of the entity boundary. The data enhancement strategy for improving the recall rate of the entity boundary task provided in the embodiment of the present application is to perform data enhancement through one-to-many replacement of the same type of entities in the word library in the training process, and introduce the entity boundary through external word library matching or even a third-party ner system. Therefore, for the above step S410, the implementation of the embodiment of the present application can be:

[0063] A1: obtain a plurality of texts, and replace the named entities in each text with a named entity category.

[0064] In the embodiment of the present application, the entity boundary sample is introduced through external word library matching or a third-party ner system. It should be noted that the entity length must be greater than 1, because the threshold of the word relation recognition task is at least two characters.

[0065] A2: for each text, obtain at least one named entity with the same named entity category from the entity type library, and replace the named entity category with the named entity;

[0066] A3: use the replaced text and the pre-stored entity boundary sample as the training sample.

[0067] In the embodiment of the present application, all entities in the text can be replaced with "$type" according to the entity position marked in the text corpus, such as replacing the name with "$PER". A text corpus is randomly extracted from the processed text corpus, each "$type" segment is searched forward, and one or two entities of the same type are randomly selected from the type library to replace the searched "$type" segment. If two or more entities are replaced at a time, a space character, a comma, a colon, an ampersand, an "and", a "with" and the like can be randomly added between adjacent entities, and the position information of the new entity is recorded. The training sample set is obtained by repeating step A1, and the test set can also be obtained.

[0068] After obtaining the data enhanced training sample, the training sample is encoded by using the bert model. The bert model includes multiple embedding layers. After gradient descent, the perturbation is injected into each embedding layer by using the FGM method, the gradient is descended and accumulated, the perturbation is deleted, and finally the gradient is updated. Then the entity boundary contained in the training sample is recalled by using the model, and the entity boundary is introduced by using the external word library matching or even the third party ner system, that is, the entity head and the entity tail in the word library matching or the third party ner recognition result are added to the set to be determined. The above method can increase the entity density in the training sample and improve the entity recall rate of the model.

[0069] In the optional implementation, since the distribution of the word relationship label and the entity boundary label is unbalanced, which affects the training effect of the model, the present application can reconstruct the loss function of the named entity model based on the determined weight of each word relationship label and each entity boundary label. The following step S420 is provided in the embodiment of the present application as shown in the embodiment of the present application, Figure 5 Figure 5 The schematic flowchart of step S420 provided in the embodiment of the present application can include the following steps:

[0070] S420-1: The total number of each word relationship label and each entity boundary label and the sub-number of each word relationship label and each entity boundary label in each batch of training samples are counted.

[0071] S420-2: The product of the ratio between each sub-number and the total number and the preset adjustment parameter is taken as the input of the activation function to obtain the weight of each word relationship label and each entity boundary label in each batch of training samples.

[0072] In the embodiment of the present application, it is assumed that the number of the word relationship label is 1, the numbers of the entity boundary labels are 2 to n in sequence, and the total number of 1, 2 to n is counted in all training samples, and the total number is represented as M i ​(i=1,2,3,…n); the training samples are batched to obtain multiple batches, and then the number of subscripts in each batch is counted, denoted as N i (i=1,2,3,…n); then the weight of the word relationship label and each entity boundary label is calculated through the following relationship (4):

[0073]

[0074] where sigmoid is a commonly used activation function, and the value range is (0, 1); is an adjustment parameter, generally 10 exponential power, is a random number between 0 and 1.

[0075] In an optional embodiment, after constructing the total loss function based on the respective weights of the word relationship label and each entity category label and the loss function of the word relationship label and the entity boundary label, the model training process of the embodiment is as follows:

[0076] B1: input each batch of training samples into the named entity recognition model to predict the label probability matrix corresponding to each training sample; wherein the label probability matrix is used to maintain the probability of the label category of any two characters in the training sample;

[0077] In the embodiment, the label probability matrix and Figure 2 The label information matrix shown in the figure is similar, except that the label information matrix maintains the label, and the label probability matrix is used to maintain the probability value of the label.

[0078] B2: based on each probability in the word relationship information region and the entity boundary information region in the label probability matrix and the actual label of the two characters corresponding to each probability, respectively, calculate the loss value of the respective loss functions of the word relationship label and the entity boundary label.

[0079] In the embodiment, the probabilities in the word relationship information region and the entity boundary information region can be tiled respectively, and then the loss value of the word relationship label is calculated through the above formula (2), and the loss value of the entity boundary label is calculated through formula (3).

[0080] B3: calculate the loss value of the total loss function according to the respective loss values of the word relationship label and the entity boundary label, and propagate the loss value back to the named entity recognition model to iteratively update the model parameters of the named entity recognition model until the total loss function converges.

[0081] After the loss values of the word relation label and the entity boundary label are obtained, the loss value of the total loss function can be calculated through the above formula (1), and then the parameters of the named entity recognition model are adjusted based on the loss value, and the training is continued until the training is completed to obtain the trained named entity recognition model.

[0082] The named entity recognition model obtained by the above training method can better cope with the multi-task and multi-label scene, improve the recall rate of the entity boundary, and accurately realize the recognition of the named entity.

[0083] Based on the above obtained named entity recognition model, an embodiment of the present application provides a named entity recognition method, please see Figure 6 , Figure 6 The named entity recognition method provided by the embodiment of the present application can include the following steps:

[0084] S510: predicting the label information matrix corresponding to the to-be-recognized text and the probability corresponding to each label in the label information matrix through the named entity recognition model;

[0085] Wherein, the label is used to represent the relationship category of any two characters in the to-be-recognized text; the label includes the word relation label and the entity boundary label;

[0086] S520: determining the two characters corresponding to the word relation label as a group of adjacent entity characters, determining the two characters corresponding to the entity boundary label as a group of entity head characters and entity tail characters, and extracting at least one named entity from the to-be-recognized text based on the adjacent entity characters and the entity head characters and the entity tail characters;

[0087] S530: for two named entities of different categories and nested, the average of the probabilities of the word relation labels corresponding to all adjacent entity characters in each named entity is taken as the probability of each named entity, and the named entity with the maximum probability is retained.

[0088] In an optional embodiment, the structure of the named entity recognition model in step S510 is as shown in Figure 1 The feature extraction network is used to extract the semantic feature vector corresponding to each character in the to-be-recognized text, the linear mapping layer is used to reduce the dimension of the semantic feature vector, and the reduced semantic feature vector is processed through the position coding and then predicted through the double affine classifier to obtain the label information matrix, and the decoding module decodes the label information matrix to obtain the named entity. Therefore, the embodiment of the above step S510 can be:

[0089] Step 1: input a character sequence of to-be-identified text into a feature extraction network of a named entity recognition model to obtain a semantic feature vector corresponding to each character;

[0090] Step 2: perform dimension reduction on each semantic feature vector through a linear mapping layer of the named entity recognition model, and perform position coding on each feature vector after dimension reduction;

[0091] Step 3: input each semantic feature vector after position coding into a double-affine classifier of the named entity recognition model to predict a probability between any two characters;

[0092] Step 4: determine a relationship category of the two characters corresponding to the probability according to a preset probability threshold and a comparison result of the probability, and determine a label corresponding to the two characters based on the relationship category;

[0093] In the foregoing, it has been introduced that there are three relationship categories in the embodiment of the application: a non-entity relationship, an entity adjacent character relationship and an entity boundary relationship, wherein the non-entity relationship corresponds to a non-entity label, the entity adjacent character relationship corresponds to a word relationship label, and the entity boundary relationship corresponds to an entity boundary label, different labels are identified by different numerical values, therefore, in Step 4, in order to determine the label corresponding to the two characters, a preset probability threshold can be first set, if the probability of a character and any character located after the character is greater than the preset probability threshold, it is determined that the two characters are in an entity adjacent character relationship, and a word relationship label is set for the two characters; otherwise, it is determined that the two characters are in a non-entity relationship, and a non-entity label is set; if the probability of a character other than the first character and any character located before the character is greater than the preset probability threshold, it is determined that the two characters are in an entity boundary relationship, and an entity boundary label is set for the two characters, otherwise, a non-entity label is set for the two characters, different labels can be distinguished by different numerical values, for example, Figure 2 As shown in the table, the word relationship label is represented by the numerical value 1, the non-entity label is represented by the numerical value 0, and the entity boundary label is represented by a numerical value other than 0 and 1.

[0094] Step 5: construct a matrix according to the length of the character sequence, and fill the label corresponding to any two characters in the matrix at the matrix position corresponding to the two characters to obtain the label information matrix.

[0095] In the embodiment of the application, as Figure 2As shown, the size of the label information matrix is N×N. In the label information matrix, the horizontal position identifiers increase sequentially from left to right, and the vertical position identifiers increase sequentially from top to bottom. For any two characters, within the word relationship information area in the label information matrix, their positions can be represented as (y,x), where y is the vertical position identifier of one character and x is the horizontal position identifier of the other character. And (y,x) can also be represented by the sequence numbers of the two characters in the character sequence. For example, the sequence number of "财政" is (0,1), corresponding to the position in the label information matrix where the vertical position identifier is 0 and the horizontal position identifier is 1.

[0096] [[ID=,3]]In an optional embodiment, for the above step S520, the embodiments of the present invention provide an implementation manner as Figure 7 shown. Figure 7 The schematic flowchart of step S520 provided by the embodiments of the present invention may include the following steps:

[0097] S520-1: Determine the vertical position identifier and the horizontal position identifier corresponding to the word relationship label and the entity boundary label respectively from the label information matrix.

[0098] For example, taking Figure 2 as an example, it can be determined that the vertical position identifiers and the horizontal position identifiers corresponding to each 1 are (y = 0, x = 1), (y = 1, x = 2), (y = 2, x = 3), (y = 3, x = 5), and (y = 5, x = 6) in sequence. The horizontal position identifiers and the vertical position identifiers corresponding to each 2 are (x = 0, y = 3) and (x = 0, y = 6).

[0099] S520-2: In the text to be recognized, form a group of adjacent entity characters from the characters at the character positions where the vertical position identifier and the horizontal position identifier are the same as those of the word relationship label, and form a group of entity start characters and entity end characters from the characters at the character positions where the horizontal position identifier and the vertical position identifier are the same as those of the entity boundary label.

[0100] In the embodiments of the present invention, there is a corresponding relationship between the matrix positions in the label information matrix and the character positions in the text to be recognized. For the word relationship label, the character corresponding to the horizontal position identifier is the next character of the character corresponding to the vertical position identifier; for the entity boundary label, the character corresponding to the horizontal position identifier is the entity start character, and the character corresponding to the vertical position identifier is the entity end character.

[0101] For example, in Figure 2The text to be identified is “fiscal revenue x growth y”, with character position numbers from 0 to 6. The position identifier corresponding to word relation label 1 is (y=0, x=1), which means that the 0th and 1st characters in the text to be identified are a pair of adjacent entity characters, namely (finance, government). Similarly, the position identifier of the entity boundary label is (x=0, y=3), which means that the 0th and 3rd characters are the head and tail of the same named entity, that is, the entity head character is finance and the entity tail character is income.

[0102] S520-3: Combine adjacent entity characters located between a set of entity header characters and entity tail characters in sequence to obtain a named entity.

[0103] To extract named entities, embodiments of the present invention can first determine the positions of characters contained within the same named entity based on the tag information matrix, and then combine the characters at these positions in sequence, specifically:

[0104] First, within the word relationship information area, for all word relationship tags, a list corresponding to each vertical position identifier is established. The horizontal position identifier corresponding to the vertical position identifier and the probability of the word relationship tag corresponding to the vertical position identifier and the horizontal position identifier are written into the list to obtain a word relationship dictionary.

[0105] For example, with Figure 2 Taking the tag information matrix shown as an example, the vertical position identifiers corresponding to the word relationship tags can be represented as: key=0, key=1, key=2, key=3, and key=5. Then, a list is built for each key. For example, key=0, x=1, probability p1; key=1, x=2, probability p2; key=2, x=3, probability p3; key=3, x=5, probability p4; key=5, x=6, probability p5. Then, the adjacent entity characters and their probabilities can be obtained as (Financial, p1), (Government Revenue, p2), (Revenue, p3), (Income Growth, p4), (Growth, p5).

[0106] In real-world scenarios, each vertical position identifier may correspond to more than one horizontal position identifier, so the list of that vertical position identifier will also contain more than one horizontal position identifier and probability.

[0107] Then, within the entity boundary information area, for each entity boundary label, it is traversed from top to bottom and from left to right. If the horizontal position identifier of the entity header and the vertical position identifier of the entity tail corresponding to the label can be found in the aforementioned word relation dictionary, it is recorded as a word block, and its probability is recorded. If the vertical position identifier of the word block is not a key in the word relation dictionary, the search for this label ends; otherwise, the search continues to the next word block. The result of the traversal is that each entity boundary label corresponds to one or more words.

[0108] For example, Figure 2 The position of entity boundary label 2 in Figure 2 can be represented as (3, 0). Here, 3 is the vertical position identifier, and the corresponding entity start and end characters are "Ru" (入). 0 is the horizontal position identifier, and the corresponding entity start character is "Cai" (财). Then the entity boundary can be recorded as "Cai + Ru". Starting from the character "Cai", traverse in the order of top - to - bottom and left - to - right. For example, assume the current traversal pointer is at the position (y = 0, x = 0). Since x = 0 is not in the list with key = 0, continue to the next position (y = 0, x = 1). Since x = 1 is in the list with key = 0, a word block "Caizheng" (财政) is obtained. Continuing the traversal, the next word block "Caizhengshou" (财政收) is obtained at the position (y = 1, x = 2), and the next word "Caizhengshouru" (财政收入) is obtained at the position (y = 2, x = 3). Until (y = 3, x = 0), it is found that y is the same as the vertical position identifier of the entity end character and x = 0 is not in the list with key = 3, then the traversal of this entity boundary label stops, and the named entity "Caizhengshouru" (财政收入) is obtained. For the next entity boundary label, continue to use the above - mentioned search method until the next named entity "Caizhengshouru zengzhang" (财政收入增长) is obtained.

[0109] Through the above - mentioned implementation method, each named entity existing in the text to be recognized can be accurately extracted.

[0110] In an optional implementation method, the embodiment of the present invention takes into account that the current decoding method will use the entity boundary with a relatively large entity boundary probability or meeting the threshold to determine the final entity recognition result. However, there may be a problem that the finally obtained named entity does not conform to the actual semantics.

[0111] For example, for the text "Liu Xiaohua is a person who has made contributions to the company", the existing decoding method filters out the final entity boundaries "Liu + Hua" and "Hua + Si" through the entity boundary probability. When "Hua is a company" actually exists, the finally recognized named entities are Liu Xiaohua and Hua is a company. Obviously, the named entity "Hua is a company" does not conform to the actual semantics. Therefore, this recognition method has a low accuracy.

[0112] To solve the above problem, after obtaining the named entity, the embodiment of the present invention will also determine the probability of the named entity based on the probability corresponding to the characters with an adjacent relationship included in each named entity, and perform screening based on the probability of the named entity and whether the named entities overlap, so as to determine the finally named entity that conforms to the actual semantics and improve the accuracy of the entity recognition result. Therefore, after obtaining the named entity in step S520, steps S530 and S540 can be executed.

[0113] S530: For the two different categories and nested named entities, the mean of the probability of the word relationship label corresponding to all adjacent entity characters in each named entity is taken as the probability of each named entity, and the named entity with the maximum probability is retained.

[0114] For example, the two named entities of “Liu Xiaohua” and “Hua is a company”, “Liu Xiaohua” and “Hua is a company” are two different categories and nested named entities, and the probability of “Liu Xiaohua” is the maximum, so “Liu Xiaohua” is determined to be retained according to the maximum probability.

[0115] For another example, in the Guanghua Management College of Peking University, two named entities of “Peking University” and “Peking University Guanghua Management College” are identified, which are same-type nested entities, and finally both entities are retained.

[0116] In order to verify the named entity recognition effect of the named entity recognition model provided by the embodiment of the application, the embodiment of the application also performs comparative experiments on multiple mainstream methods on two open source flat data sets (not containing nested entities and non-continuous entities) and one internal data set (containing nested entities and non-continuous entities), as shown in Table 1, and all results in Table 1 are the average of three best f1, and the benchmark of parameters / memory / inference speed is length 256 and entity type number 6.

[0117] Compared with the baseline model w2ner, the named entity recognition model provided by the application improves the f1 index on the resume and hsjy-ner data sets, and reduces the memory occupation by 2 / 3, and the inference speed is also improved by 30%.

[0118] Compared with the classic sequence labeling method bert+crf, the final f1 index of the named entity recognition model provided by the application is superior, although the parameters and memory occupation are more, but the inference speed is equivalent.

[0119] Compared with GlobalPointer, the final f1 index of the named entity recognition model provided by the application is superior on the peopledaily and resume data sets, and the parameters and memory are equivalent, and GlobalPointer is divergent on the hsjy-ner, which may be related to the existence of extreme data in the larger data set.

[0120] Table 2 is a progressive experiment on w2ner after modifying the network structure on the resume data set, it can be seen that the introduction of each structure of GLU, RoPE and doublebiaffine improves the effect of the model, and the external vocabulary and heuristic decoding also improve the f1 index, and the w2ner with the same configuration (128 dimensions) improves the effect by 1 percentage point.

[0121] Table 1

[0122]

[0123] Table 2

[0124]

[0125] Based on the same inventive concept, the embodiment of the present application also provides a named entity recognition device. The named entity recognition device comprises a prediction module, a decoding module and an identification module. Figure 8 Figure 8 The named entity recognition device provided by the embodiment of the present application comprises a prediction module, a decoding module and an identification module.

[0126] The prediction module is configured to predict, by a named entity recognition model, a label information matrix corresponding to the to-be-recognized text and a probability corresponding to each label in the label information matrix, wherein the label is used to represent a relationship category of any two characters in the to-be-recognized text, and the label comprises a word relationship label and an entity boundary label.

[0127] The decoding module is configured to determine two characters corresponding to the word relationship label as a group of adjacent entity characters, determine two characters corresponding to the entity boundary label as a group of entity head characters and entity tail characters, and extract at least one named entity from the to-be-recognized text based on the adjacent entity characters and the entity head characters and the entity tail characters.

[0128] The identification module is configured to, for two named entities of different categories and nested, take an average of probabilities of word relationship labels corresponding to all adjacent entity characters in each named entity as a probability of each named entity, and retain a named entity with the maximum probability.

[0129] The identification module is further configured to, for two named entities of the same category and nested, retain a named entity with the longest string length.

[0130] It can be understood that the prediction module, the decoding module and the identification module can cooperatively execute each step in the method to achieve the corresponding technical effects. Figure 6

[0131] ​​In an optional implementation, the decoding module 620 is configured to determine, from the label information matrix, the longitudinal position identifier and the transverse position identifier corresponding to each of the word relation label and the entity boundary label; regard characters at positions consistent with the longitudinal position identifier and the transverse position identifier of the word relation label as a group of adjacent entity characters in the text to be recognized, and regard characters at positions consistent with the longitudinal position identifier and the transverse position identifier of the entity boundary label as a group of entity head characters and entity tail characters; and combine the adjacent entity characters between the group of entity head characters and entity tail characters in sequence to obtain a named entity.

[0132] In an optional implementation, the prediction module 610 is configured to input a character sequence of the text to be recognized into a feature extraction network of the named entity recognition model to obtain a semantic feature vector corresponding to each character; perform dimension reduction on each semantic feature vector through a linear mapping layer of the named entity recognition model, and perform position coding on each feature vector after the dimension reduction; input each semantic feature vector after the position coding to a double-affine classifier of the named entity recognition model, predict a relation category between any two characters and a probability corresponding to the relation category, and set a label corresponding to each relation category; construct a matrix according to the length of the character sequence, and fill the labels in the matrix to obtain a label information matrix.

[0133] In an optional implementation, the named entity recognition apparatus 600 can include a training module configured to obtain a plurality of training samples, and perform data enhancement on the plurality of training samples; the training samples have entity boundary labels and word relation labels; divide the plurality of training samples into a plurality of batches, and determine a weight of each of the word relation labels and the entity boundary labels in each batch of training samples; construct a total loss function corresponding to each batch of training samples according to the weight of each of the word relation labels and the entity boundary labels in each batch of training samples and a loss function corresponding to the word relation labels and the entity boundary labels; and input each batch of training samples into the named entity recognition model to be trained to perform model training until the total loss function converges, so as to obtain a trained named entity recognition model.

[0134] In an optional implementation, the training module is configured to count a total number of each of the word relation labels and the entity boundary labels and a sub-number of each of the word relation labels and the entity boundary labels in each batch of training samples; regard a product between a ratio between each sub-number and the total number and a preset adjustment parameter as an input of an activation function to obtain the weight of each of the word relation labels and the entity boundary labels in each batch of training samples.

[0135] In an optional implementation, the training module is configured to obtain a plurality of texts, replace the named entity in each training sample with a named entity category; for each text, obtain at least one target named entity same as the named entity category from an entity type library, and replace the named entity category with the target named entity; and use the replaced text and the pre-stored entity boundary sample as the training sample.

[0136] In an optional implementation, the training module is configured to input each batch of training samples to the named entity recognition model, and predict a label probability matrix of each training sample; the label probability matrix is configured to maintain the probability of the label category of any two characters in the training sample; and the loss value of the loss function of the word relationship label and the loss value of the loss function of the entity boundary label are respectively calculated based on each probability in the word relationship information region and the entity boundary information region in the label probability matrix and the actual label of the two characters corresponding to each probability.

[0137] It should be noted that the division of the modules in the above embodiments of the present application is illustrative, and is only a logical function division. In actual implementation, another division manner can be used. In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or can be physically separated, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0138] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application, essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the methods in the embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0139] Based on the above embodiments, the present application also provides a schematic diagram of a computer device for implementing the structure method of the wireless table in the above embodiments. Referring to FIG. 8, the computer device includes a processor 801, a memory 802, a bus 803, a communication interface 804, and a power supply 805.Figure 9 As shown, Figure 9 A structural block diagram of a computer device provided by an embodiment of the present application is shown in FIG. 7. The computer device 700 includes a memory 701, a processor 702, a communication interface 703, and a bus 704. The memory 701, the processor 702, and the communication interface 703 are electrically connected to each other directly or indirectly to realize the transmission or interaction of data. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines.

[0140] Optionally, the bus 704 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, Figure 9 In the figure, only one thick line is used to represent the bus, but this does not mean that there is only one bus or only one type of bus.

[0141] In the embodiments of the present application, the processor 702 can be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the disclosed methods, steps, and logic block diagrams in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware processor for execution, or a combination of hardware and software modules in the processor for execution. The software module can be located in the memory 701, and the processor 702 reads the program instructions in the memory 701 to complete the steps of the above method in combination with the hardware.

[0142] In the embodiments of the present application, the memory 701 can be a non-volatile memory such as a hard disk drive (HDD) or a solid-state drive (SSD), etc., and can also be a volatile memory such as a RAM. The memory can also be any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but is not limited to this. The memory in the embodiments of the present application can also be a circuit or any other device capable of realizing a storage function, used for storing instructions and / or data.

[0143] The memory 701 can be used to store software programs and modules, such as the instructions / modules of the named entity recognition apparatus 600 provided by the embodiments of the present application, which can be stored in the memory 701 in the form of software or firmware or be solidified in the operating system (OS) of the computer device 700, and the processor 702 can perform various functional applications and data processing by executing the software programs and modules stored in the memory 701. The communication interface 703 can be used for signaling or data communication with other node devices.

[0144] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the apparatuses and units described above can refer to the corresponding processes in the foregoing method embodiments, which will not be described herein.

[0145] It can be understood that, Figure 9 The structure shown is only schematic, and the computer device 700 can further include more or less components than those shown, or have a different configuration of components than those shown. Figure 9 The components shown can be implemented in hardware, software, or a combination thereof. Figure 9 The components shown can be implemented in hardware, software, or a combination thereof. Figure 9 The components shown can be implemented in hardware, software, or a combination thereof.

[0146] Based on the foregoing embodiments, the present application further provides a storage medium, which stores a computer program. When the computer program is executed by a computer, the computer program causes the computer to perform the named entity recognition method provided in the foregoing embodiments.

[0147] Based on the foregoing embodiments, the present application further provides a computer program, which causes a computer to perform the named entity recognition method provided in the foregoing embodiments when the computer program is run on the computer.

[0148] Based on the foregoing embodiments, the present application further provides a chip, which is used to read a computer program stored in a memory and is used to perform the named entity recognition method provided in the foregoing embodiments.

[0149] The present application further provides a computer program product, which includes instructions, and causes a computer to perform the named entity recognition method provided in the foregoing embodiments when the computer program product is run on the computer.

[0150] The embodiments of the present application are described with reference to the flowchart illustrations and / or block diagrams of the methods, apparatus (systems) and computer program products according to the embodiments of the present application. It is understood that each flow and / or block in the flowchart illustrations and / or block diagrams, and a combination of flows and / or blocks in the flowchart illustrations and / or block diagrams, can be implemented by Figure 1 one or more flows and / or blocks Figure 1 one or more flows and / or blocks

[0151] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device that implements the function specified in the flow Figure 1 one or more flows and / or blocks Figure 1 one or more flows and / or blocks

[0152] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process so that the instructions executed on the computer or other programmable apparatus provide steps for implementing the function specified in the flow Figure 1 one or more flows and / or blocks Figure 1 one or more flows and / or blocks

[0153] The above, merely is the specific implementation of the present application, but the protection scope of the present application is not limited to this, any skilled person in the art can easily think of the change or replacement within the technical range disclosed by the present application, should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method of named entity recognition, characterized by, The method comprises: Through a named entity recognition model, a label information matrix corresponding to the to-be-recognized text and a probability corresponding to each label in the label information matrix are predicted; wherein the label is used to represent a relationship category of any two characters in the to-be-recognized text; the label comprises a word relationship label and an entity boundary label; From the label information matrix, the vertical position identifier and the horizontal position identifier corresponding to the word relationship label and the entity boundary label are determined; in the to-be-recognized text, the characters at the character positions consistent with the vertical position identifier and the horizontal position identifier of the word relationship label are taken as a group of adjacent entity characters, and the characters at the character positions consistent with the vertical position identifier and the horizontal position identifier of the entity boundary label are taken as a group of entity head characters and entity tail characters; the adjacent entity characters between the group of entity head characters and entity tail characters are sequentially combined to obtain at least one named entity; For two nested named entities of different categories, the mean of the probabilities of the word relationship labels corresponding to all the adjacent entity characters in each named entity is taken as the probability of each named entity, and the named entity with the maximum probability is retained.

2. The named entity recognition method of claim 1, wherein, Through a named entity recognition model, a label information matrix corresponding to the to-be-recognized text and a probability corresponding to each label in the label information matrix are predicted, comprising: The character sequence of the to-be-recognized text is input into the feature extraction network of the named entity recognition model to obtain a semantic feature vector corresponding to each character; Each semantic feature vector is reduced in dimension through a linear mapping layer of the named entity recognition model, and each reduced feature vector is positionally encoded; Each positionally encoded semantic feature vector is input into a double-affine classifier of the named entity recognition model to predict the probability between any two characters; According to a preset probability threshold and a comparison result of the probability, the relationship category of the two characters corresponding to the probability is determined, and a label is set for the relationship category; A matrix is constructed according to the length of the character sequence, and the label corresponding to any two characters is filled in the matrix position corresponding to the two characters to obtain the label information matrix. 3.The named entity recognition method of claim 1 or 2, characterized in that, The named entity recognition model is obtained by training in the following manner: A plurality of training samples are obtained, and the plurality of training samples are subjected to data enhancement; the training samples have the entity boundary label and the word relationship label; The plurality of training samples are divided into a plurality of batches, and the weight of each entity boundary label and the word relationship label in each batch of training samples is determined; According to the weight of each entity boundary label and the word relationship label in each batch of training samples and the loss function corresponding to the entity boundary label and the word relationship label, a total loss function corresponding to each batch of training samples is constructed; Each batch of training samples is input into a to-be-trained named entity recognition model for model training until the total loss function converges, and a trained named entity recognition model is obtained.

4. The named entity recognition method of claim 3, wherein, The plurality of training samples are divided into batches, and the weight of each of the word relation label and the entity boundary label in each batch of training samples is determined, including: The total number of each of the word relation label and the entity boundary label and the sub-number of each of the word relation label and the entity boundary label in each batch of training samples are counted; The product of the ratio between each of the sub-number and the total number and a preset adjustment parameter is taken as the input of the activation function to obtain the weight of each of the word relation label and the entity boundary label in each batch of training samples.

5. The named entity recognition method of claim 3, wherein, A plurality of training samples are obtained, and data augmentation is performed on the plurality of training samples, including: A plurality of texts are obtained, and a named entity in each of the texts is replaced by a named entity category; For each of the texts, at least one named entity of the same named entity category as the named entity is obtained from an entity type library, and the named entity category is replaced by the named entity; The replaced text and a pre-stored entity boundary sample are taken as the training sample.

6. The named entity recognition method of claim 3, wherein, The each batch of training samples is input into a named entity recognition model to be trained for model training until the total loss function converges, and the trained named entity recognition model is obtained, including: The each batch of training samples is input into the named entity recognition model to predict a label probability matrix of each of the training samples; wherein the label probability matrix is used to maintain the probability of the label category of any two characters in the training sample; The loss value of the loss function of each of the word relation label and the entity boundary label is calculated based on each probability in the word relation information region and the entity boundary information region of the label probability matrix and the actual label of the two characters corresponding to each probability; The loss value of the total loss function is calculated according to the loss value of each of the word relation label and the entity boundary label, and the loss value is back-propagated to the named entity recognition model to iteratively update the model parameters of the named entity recognition model until the total loss function converges.

7. A named entity recognition apparatus characterized by comprising: Including: A prediction module, a decoding module and an identification module; The prediction module is configured to predict, by the named entity recognition model, a label information matrix corresponding to the to-be-identified text and a probability corresponding to each label in the label information matrix; wherein the label is used to represent the relationship category of any two characters in the to-be-identified text; and the label includes a word relation label and an entity boundary label. The decoding module is configured to determine the longitudinal position identifier and the transverse position identifier corresponding to each of the word relation label and the entity boundary label from the label information matrix; take characters at character positions consistent with the longitudinal position identifier and the transverse position identifier of the word relation label as a group of adjacent entity characters, and take characters at character positions consistent with the longitudinal position identifier and the transverse position identifier of the entity boundary label as a group of entity head characters and entity tail characters; and combine the adjacent entity characters between the group of entity head characters and entity tail characters in sequence to obtain at least one named entity. The recognition module is configured to, for two named entities of different categories and nesting, take the mean of probabilities of the word relation labels corresponding to all the adjacent entity characters in each of the named entities as the probability of each of the named entities, and retain the named entity with the maximum probability.

8. A computer device, comprising: A computer program product comprising a processor and a memory storing a computer program executable by the processor, the processor being executable to implement the method of any one of claims 1 to 6.

9. A readable storage medium, having stored thereon a computer program, characterized in that, The computer program product, when executed by a processor, implements the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Named entity identification method and device, electronic equipment and storage medium

    CN113761923A

  • Nested named entity recognition method based on generative adversarial training

    CN114218947A