Named entity identification method and device, computer equipment and storage medium

By extracting feature information using part-of-speech information in the text, and determining the named entity after fusing, the problem of low recognition efficiency caused by relying on user prompts in the prior art is solved, and efficient and accurate naming entity recognition is achieved.

CN119903840APending Publication Date: 2025-04-29TCL TECHNOLOGY GROUP CORPORATION
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202311408431.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-26
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

The existing named entity recognition method relies on prompt construction information input by user assisted input, resulting in low recognition efficiency.

Method used

By using the part-of-speech information of the initial text and its words, the first feature information and the second feature information are extracted and fused to determine the named entity, without relying on prompt construction information with user assistance input.

Benefits of technology

Improve the recognition efficiency of named entities and ensure the accuracy of recognition results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119903840A_ABST
    Figure CN119903840A_ABST
Patent Text Reader

Abstract

The invention provides a named entity recognition method and device, computer equipment and a storage medium. The method comprises the steps of obtaining an initial text to be subjected to entity recognition processing; obtaining first feature information and second feature information of the initial text based on the initial text and the part-of-speech information of each word in the initial text; and determining the named entity in the initial text according to the first feature information and the second feature information. According to the named entity recognition method provided by the embodiment of the invention, the recognition efficiency of the named entity is improved without depending on prompt construction information input by a user in an auxiliary manner, and the accuracy of obtaining the named entity by subsequent decoding is also ensured by fusing the part-of-speech information of the words in the encoding process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of text processing technology, and in particular to a method, apparatus, computer device and storage medium for named entity recognition. Background Art

[0002] Named entities usually refer to names of people, organizations, places, and all other entity types identified by names. Such entity types are usually the basis of technologies such as intelligent question answering, user intent recognition, and chatbots. Therefore, it is very necessary to identify named entities in texts.

[0003] At present, named entity recognition usually uses a pre-training model. In order to avoid the problem of unclear improvement effect caused by a large gap between downstream task objectives and pre-training task objectives, the existing technology usually adopts prompt construction to narrow the gap between downstream tasks and pre-training task objectives. That is, in the process of named entity recognition, auxiliary input prompt construction information is usually required, which affects the efficiency of named entity recognition. Summary of the invention

[0004] Based on this, it is necessary to provide a named entity recognition method, apparatus, computer device and storage medium to address the above technical problems, so as to solve the problem of low efficiency of named entity recognition caused by relying on prompt construction information of user auxiliary input in existing named entity recognition methods.

[0005] In a first aspect, the present application provides a method for named entity recognition, comprising:

[0006] Get the initial text to be processed for entity recognition;

[0007] Based on the initial text and part-of-speech information of each word in the initial text, obtaining first feature information and second feature information of the initial text;

[0008] Determine a named entity in the initial text according to the first feature information and the second feature information.

[0009] As a feasible embodiment of the present application, obtaining the first feature information and the second feature information of the initial text based on the initial text and the part-of-speech information of each word in the initial text includes:

[0010] Performing feature extraction on the initial text to obtain first feature information of the initial text;

[0011] Extracting features of the part-of-speech information of each word in the initial text to obtain the part-of-speech feature information in the initial text;

[0012] The first feature information and the second feature information are merged to obtain the second feature information of the initial text.

[0013] As a feasible embodiment of the present application, determining the named entity in the initial text according to the first feature information and the second feature information includes:

[0014] Based on the second feature information, determining the starting probability of each word in the initial text corresponding to the named entity;

[0015] Determining, based on the first feature information and the second feature information, the end probability of each word corresponding to the named entity in each of the initial texts;

[0016] Based on the start probability and the end probability of each word in the initial text corresponding to the named entity, the words in the initial text are matched to obtain the named entity in the initial text.

[0017] As a feasible embodiment of the present application, the named entity recognition method is applied to a pre-trained multi-interaction entity recognition model;

[0018] The obtaining, based on the initial text and the part-of-speech information of each word in the initial text, the first feature information and the second feature information of the initial text comprises:

[0019] Inputting the initial text and part-of-speech information of each word in the initial text into an encoder in the multi-interactive entity recognition model for processing to obtain first feature information and second feature information of the initial text;

[0020] The determining, according to the first feature information and the second feature information, the named entity in the initial text includes:

[0021] The first feature information and the second feature information are input into a decoder in the multi-interactive entity recognition model for processing to obtain named entities in the initial text.

[0022] As a feasible embodiment of the present application, the decoder includes a feature extraction layer, a feature enhancement layer and an interactive decoding layer;

[0023] The step of inputting the first feature information and the second feature information into a decoder in the multi-interactive entity recognition model for processing to obtain the named entities in the initial text includes:

[0024] Inputting the first feature information and the second feature information into the feature extraction layer for processing to obtain a first feature representation and a second feature representation of the initial text;

[0025] Inputting the first feature representation and the second feature representation of the initial text into the feature enhancement layer for processing to obtain the first enhanced feature representation and the second enhanced feature representation of the initial text;

[0026] The first enhanced feature representation and the second enhanced feature representation are input into the interactive decoding layer for processing to obtain the named entities in the initial text.

[0027] As a feasible embodiment of the present application, the multi-interaction entity recognition model is trained in the following manner:

[0028] Obtaining sample text and named entity tags corresponding to the sample text;

[0029] Inputting the sample text and part-of-speech tagging information corresponding to the sample text into an encoder in an initial entity recognition model to obtain first sample feature information and second sample feature information corresponding to the sample text;

[0030] Inputting the first sample feature information and the second sample feature information into a decoder in an initial entity recognition model to obtain a predicted probability of each word in the sample text corresponding to a named entity;

[0031] According to the difference between the predicted probability and the named entity label, the initial entity recognition model is updated to obtain an updated entity recognition model;

[0032] When the difference between the predicted probability obtained by inputting the sample text into the updated entity recognition model and the named entity label meets the preset requirement, the currently obtained entity recognition model is determined as the multi-interaction entity recognition model.

[0033] As a feasible embodiment of the present application, the step of inputting the first sample feature information and the second sample feature information into a decoder in an initial entity recognition model to obtain a predicted probability of each word in the sample text corresponding to a named entity includes:

[0034] Inputting the first sample feature information and the second sample feature information into a decoder in an initial entity recognition model to obtain a predicted probability of each word in the sample text corresponding to a named entity and a first sample feature representation and a second sample feature representation corresponding to the sample text;

[0035] Determine a loss value corresponding to the initial entity recognition model according to a first similarity between the first sample feature representation and a type-centric feature representation corresponding to a named entity type in the named entity tag, and a second similarity between the second sample feature and the type-centric feature representation;

[0036] The updating of the initial entity recognition model according to the difference between the predicted probability and the named entity label to obtain an updated entity recognition model includes:

[0037] According to the difference between the predicted probability and the named entity label, and the loss value, the initial entity recognition model is updated to obtain an updated entity recognition model.

[0038] As a feasible embodiment of the present application, the obtaining of sample text and a named entity tag corresponding to the sample text includes:

[0039] Get the initial sample text;

[0040] Performing data enhancement processing on the initial sample text to obtain enhanced sample text;

[0041] A sample text carrying a named entity tag is generated according to the enhanced sample text and the named entity type corresponding to the enhanced sample text.

[0042] As a feasible embodiment of the present application, generating a sample text carrying a named entity tag according to the enhanced sample text and the named entity type corresponding to the enhanced sample text includes:

[0043] Calculating the similarity between the enhanced sample text and each preset initial template text;

[0044] Determining a target template text from the initial template text according to the magnitude relationship of the similarities;

[0045] The named entity type corresponding to the target template text is fused with the enhanced sample text to obtain a sample text carrying a named entity tag.

[0046] In a second aspect, the present application provides a named entity recognition device, comprising:

[0047] An acquisition module is used to acquire the initial text to be processed by entity recognition;

[0048] An encoding module, configured to obtain first feature information and second feature information of the initial text based on the initial text and part-of-speech information of each word in the initial text;

[0049] A recognition module is used to determine the named entity in the initial text according to the first feature information and the second feature information.

[0050] In a third aspect, the present application further provides a computer device, the computer device comprising:

[0051] one or more processors;

[0052] Memory; and

[0053] One or more applications, wherein the one or more applications are stored in the memory and are configured to execute any of the named entity recognition methods provided above by the processor.

[0054] In a fourth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is loaded by a processor to execute any of the named entity recognition methods described above.

[0055] The named entity recognition method provided in the embodiment of the present application, after obtaining the initial text to be processed for entity recognition, will use the initial text and the part-of-speech information of the words in the text to obtain the first feature information and the second feature information of the initial text. The feature information makes full use of the vocabulary information, which is helpful for the subsequent identification of the boundaries of the named entities. Therefore, after the first feature information and the second feature information are decoded, the named entities in the initial text can be obtained. The named entity recognition method provided in the embodiment of the present application does not need to rely on the prompt construction information of the user's auxiliary input, thereby improving the recognition efficiency of the named entity, and the integration of the part-of-speech information of the words in the encoding process also ensures the accuracy of the named entity obtained by subsequent decoding. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0057] Figure 1 A schematic diagram of a step flow of a method for named entity recognition provided in an embodiment of the present application;

[0058] Figure 2 A schematic diagram of a process flow of obtaining first feature information and second feature information based on text and part-of-speech information extraction provided in an embodiment of the present application;

[0059] Figure 3 A schematic diagram of a process flow for determining a named entity based on feature information provided in an embodiment of the present application;

[0060] Figure 4 A schematic diagram of a process flow for implementing feature extraction and named entity recognition based on a neural network model provided in an embodiment of the present application;

[0061] Figure 5A schematic diagram of a process flow for decoding feature information provided in an embodiment of the present application;

[0062] Figure 6 A schematic diagram of a step flow for training a model provided in an embodiment of the present application;

[0063] Figure 7 A schematic diagram of a process flow of constructing a loss function to update a model provided in an embodiment of the present application;

[0064] Figure 8 A schematic diagram of a process flow for obtaining a sample text provided in an embodiment of the present application;

[0065] Fig. 9 A schematic diagram of a process flow for constructing a prompt sample text provided in an embodiment of the present application;

[0066] Fig.10 A schematic block diagram of a complete implementation process of a named entity recognition method provided in an embodiment of the present application;

[0067] Fig.11 A schematic diagram of the structure of a named entity recognition device provided in an embodiment of the present application;

[0068] Fig.12 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] The following will be combined with 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 only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0070] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "plurality" means two or more, unless otherwise clearly and specifically defined.

[0071] In the description of the present application, the word "for example" is used to mean "used as an example, illustration or explanation". Any embodiment described as "for example" in the present application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.

[0072] To facilitate understanding of the named entity recognition method provided in the embodiment of the present application, the application scenario of the named entity recognition method provided in the embodiment of the present application is first described. Specifically, the named entity recognition method provided in the embodiment of the present application generally refers to identifying entities identified by names such as names of people, places, names of organizations, etc. in the text input by the user, so as to better perform downstream tasks. For example, by identifying the place name in "I want to buy a plane ticket to XX", the ticket purchase system can quickly identify and understand the user's intention, thereby performing the corresponding ticket issuance operation, or by identifying the school name in "Please briefly introduce XX University", the chatbot can quickly respond to the user's question and make a response content introducing the school. That is, the recognition of named entities in text is usually the basis of technologies such as intelligent question and answer, user intent recognition, and chatbots. Therefore, the recognition of named entities is very necessary.

[0073] At present, named entity recognition usually uses a pre-trained model, so that when dealing with different downstream tasks, such as user intent recognition and intelligent question and answer, the pre-trained model can be reasonably fine-tuned to obtain a model that adapts to downstream tasks. In order to avoid the problem that the improvement effect is not obvious due to the large gap between the downstream task target and the pre-training target, the prior art usually adopts a prompt structure to narrow the gap between the downstream task and the pre-training task target, that is, in the process of named entity recognition, it is usually necessary to input the prompt structure information auxiliaryly, which affects the efficiency of named entity recognition. And it is precisely to solve the above problems that the present application provides a method, device, computer equipment and storage medium for named entity recognition, which encodes the text by using the part-of-speech information of the words in the text, which helps to identify the boundaries of the named entity in the future, and ensures the accuracy of identifying the named entity without relying on the prompt structure information of the user's auxiliary input. Specifically, the named entity recognition method is usually installed in the named entity recognition device in the form of a computer program, and the named entity recognition device is set in the computer device in the form of a processor. The named entity recognition device in the computer device executes the named entity recognition method provided in the embodiment of the present application by running the computer program corresponding to the named entity recognition method.

[0074] like Figure 1 As shown, Figure 1 A schematic flow chart of a method for named entity recognition provided in an embodiment of the present application specifically includes steps S110 to S130:

[0075] S110, obtaining an initial text to be processed for entity recognition.

[0076] In the embodiments of the present application, combined with the application scenarios of the named entity recognition method provided above, it can be known that the initial text usually refers to the text information entered by the user in some systems that can meet the needs of the user. For example, in a self-service ticket purchasing system, "Please give me a ticket to XX" entered by the user is the initial text that needs to be processed by named entity recognition, or in a chatbot system, "Please give me a brief introduction to XX University" output by the user can also be regarded as the initial text that needs to be processed by named entity recognition. Of course, the above examples do not mean that the initial text must contain named entities. When the initial text does not contain named entities, it is only necessary to ensure that the named entities finally output are empty.

[0077] S120: Obtain first feature information and second feature information of the initial text based on the initial text and part-of-speech information of each word in the initial text.

[0078] In the embodiment of the present application, since Chinese text does not have obvious segmentation boundaries and obvious word form transformation features compared to English text, in order to improve the recognition and processing effect of named entities in the text, the embodiment of the present application will make full use of the part-of-speech information of the words in the text to process the text, that is, the initial text and the part-of-speech information of each word in the initial text are used to obtain the first feature information and the second feature information of the initial text, wherein the part-of-speech information of each word in the initial text can be obtained in advance through annotation, and of course can also be determined by using the trained part-of-speech tagging model, and the first feature information generally refers to the feature information of the initial text without the part-of-speech information, and the second feature information generally refers to the feature information of the initial text carrying the part-of-speech information. The specific implementation scheme for obtaining the first feature information and the second feature information can refer to the following Figure 2 and its explanatory contents.

[0079] Specifically, Figure 2 As shown, Figure 2 A schematic flow chart of steps for extracting first feature information and second feature information based on text and part-of-speech information provided in an embodiment of the present application, specifically, comprising steps S210 to S230:

[0080] S210: Extract features from the initial text to obtain first feature information of the initial text.

[0081] In the embodiment of the present application, the first feature information is usually feature information related to the semantics of each word obtained by extracting features from each word in the initial text. Specifically, as a common feasible implementation scheme, the feature extraction of the initial text can usually be implemented based on a neural network model in the field of NLP (Natural language processing).

[0082] S220, performing feature extraction on the part-of-speech information of each word in the initial text to obtain part-of-speech feature information in the initial text.

[0083] In the embodiment of the present application, in addition to the aforementioned feature extraction of the initial text, by extracting the feature information of the part of speech of each word in the initial text, the part of speech feature information related to the part of speech of each word in the initial text can also be obtained. Specifically, the feature extraction of the part of speech information can also be implemented based on the neural network model in the field of NLP. Of course, it can also be implemented by using the neural network model used for the aforementioned feature extraction of the initial text.

[0084] S230: Merge the first feature information and the second feature information to obtain second feature information of the initial text.

[0085] In an embodiment of the present application, after the feature extraction of each word and the part-of-speech information of each word in the initial text is completed, thereby obtaining the first feature information related to the semantics of each word and the part-of-speech feature information related to the part-of-speech of each word, the second feature information that integrates the semantic information and the part-of-speech information can be obtained by fusing the first feature information and the second feature information. Specifically, considering that the dimensions of the first feature information and the second feature information are usually associated with the number of words in the initial text, that is, the dimensions of the first feature information and the second feature information are usually equal, therefore, as a feasible implementation scheme of the present application, the fusion of the first feature information and the second feature information can be achieved by adding them together. Of course, it is also feasible to adopt other fusion schemes.

[0086] S130: Determine a named entity in the initial text according to the first feature information and the second feature information.

[0087] In the embodiment of the present application, after obtaining the feature information of the initial text without part-of-speech information and the feature information of the initial text with part-of-speech information respectively, the named entities in the initial text can be obtained by decoding the first feature information and the second feature information.

[0088] Specifically, in order to improve the accuracy of the identified named entities, as a feasible embodiment of the present application, the recognition of named entities can be realized based on the thinking of the human brain to judge entities, that is, first determine the starting part of the named entity, and then further determine the ending part of the named entity, that is, first determine the possibility that each word in the initial text corresponds to the beginning part of the named entity, and then determine the possibility that each word in the initial text corresponds to the ending part of the named entity. The specific implementation scheme can be referred to in the following continued Figure 3 and its explanatory contents.

[0089] Specifically, Figure 3 As shown, it is a schematic diagram of a process flow of determining a named entity based on feature information provided by an embodiment of the present application, specifically, including steps S310 to S330:

[0090] S310: Determine the starting probability of each word in the initial text corresponding to the named entity based on the second feature information.

[0091] In the embodiment of the present application, since the second feature information integrates the semantic information and part-of-speech information of each word in the initial text, by decoding the second feature information, it is possible to more accurately determine the words in the initial text that may be the starting part of the named entity, that is, to determine the starting probability of each word in the initial text corresponding to the named entity.

[0092] Specifically, the starting probability of each word in the initial text corresponding to the named entity can usually be in the form of a set of vectors, wherein the value of each dimension in the vector is between 0 and 1, corresponding to the possibility that each word in the initial text is the starting part of the named entity. The closer the value is to 1, the higher the possibility that the corresponding word in the initial text is the starting part of the named entity. Conversely, the closer the value is to 0, the lower the possibility that the corresponding word in the initial text is the starting part of the named entity.

[0093] S320: Determine the end probability of each word in the initial text corresponding to the named entity based on the first feature information and the second feature information.

[0094] In the embodiment of the present application, similar to the above, by decoding the first feature information, it is possible to determine the words in the initial text that may be the end of the named entity. However, in order to avoid errors in the early stage, the first feature information does not incorporate part-of-speech information. Therefore, in order to more accurately determine the words in the initial text that may be the end of the named entity, the first feature information and the second feature information can be interacted, and then based on the interactive feature information, the end probability of each word in the initial text corresponding to the named entity can be determined.

[0095] Specifically, the ending probability of each word in the initial text corresponding to the named entity can usually be in the form of a set of vectors, wherein the value of each dimension in the vector is between 0 and 1, corresponding to the possibility that each word in the initial text is the ending part of the named entity. The closer the value is to 1, the higher the possibility that the corresponding word in the initial text is the ending part of the named entity. Conversely, the closer the value is to 0, the lower the possibility that the corresponding word in the initial text is the ending part of the named entity.

[0096] S330, matching the words in the initial text based on the start probability and the end probability of the named entity corresponding to each word in the initial text to obtain the named entity in the initial text.

[0097] In the embodiment of the present application, the starting probability and ending probability of each word pair corresponding to the named entity are determined above, and by reasonably matching the words in the initial text, the boundary of the final named entity can be determined. Specifically, there are many implementation schemes for matching the words in the initial text. For example, as a feasible implementation scheme, the words in the initial text can be matched based on the proximity principle or function matching, so as to determine the starting part and the ending part of the named entity in the initial text, so as to finally obtain the named entity in the initial text. Of course, it is also feasible to use other methods to match the words in the initial text to obtain the named entities in the initial text, and the embodiments of the present application will not be repeated here.

[0098] Furthermore, similar to the aforementioned step of extracting features from the initial text and part-of-speech information to obtain feature information, the processing of feature information provided in the embodiment of the present application to determine the named entities in the initial text can also be implemented based on a neural network model in the NLP field. However, in order to ensure the effect of feature extraction of the initial text and part-of-speech information in the embodiment of the present application, in order to improve the accuracy of the named entities determined by the subsequent decoding of the feature information. As a feasible embodiment of the present application, an implementation scheme is provided for respectively completing step S120 and step S130 using the encoding layer and decoding layer in a neural network model of a specific structure. For the specific implementation scheme, please refer to the subsequent Figure 4 and its explanatory contents.

[0099] Based on the aforementioned identification of named entities in the initial text, downstream tasks can further execute subsequent processes based on the identified named entities. For example, for the place names in the user's ticket purchase needs identified by the autonomous ticket purchasing system, the autonomous ticket purchasing system will execute the ticket issuance process based on the identified named entities, or for the named entities describing the user's intentions identified by the chatbot, the chatbot will output the corresponding response text based on the named entity, etc. The embodiment of the present application does not limit the subsequent downstream task processes executed based on the identification of named entities, that is, it does not limit the application scenarios of the named entity recognition in this application, and all scenarios that require the use of named entity recognition can be regarded as within the scope of protection required by this application.

[0100] The named entity recognition method provided in the embodiment of the present application, after obtaining the initial text to be processed for entity recognition, will use the initial text and the part-of-speech information of the words in the text to obtain the first feature information and the second feature information of the initial text. The feature information makes full use of the vocabulary information, which is helpful for the subsequent identification of the boundaries of the named entities. Therefore, after the first feature information and the second feature information are decoded, the named entities in the initial text can be obtained. The named entity recognition method provided in the embodiment of the present application does not need to rely on the prompt construction information of the user's auxiliary input, thereby improving the recognition efficiency of the named entity, and the integration of the part-of-speech information of the words in the encoding process also ensures the accuracy of the named entity obtained by subsequent decoding.

[0101] like Figure 4 As shown, Figure 4 A schematic flowchart of the steps for implementing feature extraction and named entity recognition based on a neural network model is provided in an embodiment of the present application, which is described in detail as follows.

[0102] In order to determine the named entities in the initial text according to the initial text and the part-of-speech information of each word in the initial text, the embodiment of the present application provides a solution for implementing the above process based on the encoding and decoding module in the neural network model. Specifically, the named entity recognition method provided in the embodiment of the present application is mainly applied to the pre-trained neural network model, that is, the multi-interactive entity recognition model, and specifically includes steps S410 to S420:

[0103] S410, inputting the initial text and the part-of-speech information of each word in the initial text into the encoder in the multi-interactive entity recognition model for processing to obtain first feature information and second feature information of the initial text.

[0104] In an embodiment of the present application, the encoder in the multi-interacting entity recognition model generally refers to a network layer in a language model that encodes language text into a form such as a vector. For example, a relatively common encoder structure is the encoder structure in the Bert (Bidirectional Encoder Representation from Transformers, a bidirectional encoder representation based on Transformer) model. Of course, it is also feasible to use other encoder structures.

[0105] The implementation scheme of the encoder processing the initial text and part-of-speech information to obtain the first feature information and the second feature information can be the same as the above Figure 2 The implementation scheme shown for extracting the first feature information and the second feature information based on text and part-of-speech information is similar, that is, the initial text is first input into the encoder for processing to obtain the first feature information of the initial text, and then the part-of-speech information of each word in the initial text is input into the encoder for processing to obtain the part-of-speech feature information of the initial text, and finally the first feature information and the part-of-speech feature information of the initial text are fused to obtain the second feature information.

[0106] Specifically, taking the encoder structure in the Bert model as an example of the encoder in the multi-interactive entity recognition model, the initial text is input into the encoder for processing, and the first feature information of the initial text can be obtained. Specifically, the first feature information is usually composed of the word vector v t , block vector v s , and the position vector v p It consists of three parts, namely the first feature information v = v t +v s +v p , where v t =e t W t , e t is the one-hot encoding result (i.e., one-hot vector) corresponding to the text sequence, and Wt Then is the parameter in the encoder. Further, the part-of-speech information of each word in the initial text is input into the encoder for processing, and the part-of-speech feature information v can be obtained. psg By fusing the first feature information and the part-of-speech feature information, we can get the second feature information v2=v token +v psg .

[0107] Of course, in order to further improve the encoding effect of the initial text and make the feature information contain richer context information, as a feasible embodiment of the present application, in the process of obtaining the first feature information, the one-hot vector e can be further encoded. t To make corrections, specifically, Bert's masked language model MLM can be used to generate the probability distribution e on the vocabulary M , and then e is transformed into M With one-hot encoding t Combine to get the correction vector e mix , so that e can be used in subsequent encoding operations mix Instead of e t The specific calculation formula is as follows:

[0108] e M =MLM(e t )

[0109] e mix =λe t +(1-λ)e M

[0110] v t-mix =e mix W t

[0111] Among them, v t-mix That is the corrected word vector, v t-mix Instead of v t The corrected first feature information can be obtained, that is, v1 = v token =v t-mix +v s +v p .

[0112] S420: Input the first feature information and the second feature information into a decoder in the multi-interactive entity recognition model for processing to obtain named entities in the initial text.

[0113] In the embodiment of the present application, after encoding the initial text and part-of-speech information, the named entities in the initial text can be obtained by decoding the feature information accordingly. Furthermore, in order to improve the decoding effect of the decoder on the feature information and to improve the accuracy of the output named entities, the embodiment of the present application provides an implementation step for decoding the feature information based on feature extraction, feature enhancement and interactive decoding. Specifically, the decoder includes network layers corresponding to feature extraction, feature enhancement and interactive decoding respectively. The specific implementation scheme can be found in the subsequent Figure 5 and its explanatory contents.

[0114] like Figure 5 As shown, Figure 5 A schematic flow chart of a step of decoding feature information provided in an embodiment of the present application, specifically, comprising steps S510 to S530:

[0115] S510: Input the first feature information and the second feature information into the feature extraction layer for processing to obtain a first feature representation and a second feature representation of the initial text.

[0116] In an embodiment of the present application, after the first feature information v1 and the second feature information v2 are obtained as mentioned above, the first feature information v1 and the second feature information v2 are input into the feature extraction layer in the decoder for processing, so as to obtain the first feature representation B1 and the second feature representation B2 of the initial text. Specifically, the feature extraction layer can adopt the feature extraction layer structure in the Bert model, so as to realize independent and parallel feature extraction of the first feature information and the second feature information to capture context information.

[0117] S520: Input the first feature representation and the second feature representation of the initial text into the feature enhancement layer for processing to obtain the first enhanced feature representation and the second enhanced feature representation of the initial text.

[0118] In order to further improve the decoding effect of feature information, in an embodiment of the present application, a feature enhancement layer based on a multi-head self-attention mechanism is also provided in the decoder. Specifically, during the training process, by introducing prompt construction information, more weight can be given to the key text information with the highest relevance to the prompt, thereby alleviating the model learning pressure and the problem of insufficient utilization of prompt information. Therefore, the first feature representation and the second feature representation of the initial text are input into the feature enhancement layer for processing, and the first enhanced feature representation and the second enhanced feature representation that are more related to the initial text and the key text information can be obtained.

[0119] S530: Input the first enhanced feature representation and the second enhanced feature representation into the interactive decoding layer for processing to obtain the named entities in the initial text.

[0120] After the first enhanced feature representation and the second enhanced feature representation are obtained, they are further input into the interactive decoding layer for final decoding processing, so that the named entities in the initial text can be obtained.

[0121] Specifically, the first enhanced feature representation and the second enhanced feature representation are decoded to obtain the named entity in the initial text, which can also be the same as the aforementioned Figure 3 The steps of determining the named entities in the initial text based on the first feature information and the second feature information are similar, that is, the possibility of each word in the initial text corresponding to the starting part of the named entity can be determined based on the second enhanced feature representation, and then the possibility of each word in the initial text corresponding to the ending part of the named entity can be determined based on the first enhanced feature representation and the second enhanced feature representation, that is, the second enhanced feature representation is input into the interactive decoding layer for processing to obtain the starting probability of each word in the initial text corresponding to the named entity, and the first enhanced feature representation and the second enhanced feature representation are input into the interactive decoding layer for processing to obtain the ending probability of each word in the initial text corresponding to the named entity, and finally the starting probability and ending probability of each word in the initial text corresponding to the named entity are combined to match each word in the initial text, so as to obtain the named entity in the initial text.

[0122] Of course, it should be noted that in order to ensure that decoding the feature information of the encoder can accurately extract the named entities in the initial text, it is usually necessary to train the encoder and decoder parts, that is, it is necessary to train the multi-interactive entity recognition model. The specific training process can be referred to in the subsequent Figure 6 and its explanatory contents.

[0123] like Figure 6 As shown, Figure 6 A schematic flow chart of a step of training a model provided in an embodiment of the present application, specifically, comprising steps S610 to S650:

[0124] S610: Obtain sample text and named entity tags corresponding to the sample text.

[0125] In the embodiments of the present application, the sample text generally refers to a pre-obtained text carrying label information, and the named entity label corresponding to the sample text generally includes the position of the named entity in the sample text, which is generally the same as the probability of each word corresponding to the named entity, and may also exist in the form of one or more vectors. Specifically, in the vector label, the value at the position corresponding to the named entity word in the sample text is 1, or the value at the position corresponding to the beginning and end words of the named entity in the sample text is 1, and the values ​​at other positions in the vector are 0.

[0126] Of course, in addition to the location of the named entity provided above, the named entity tag can usually also include the named entity type. For example, the more common named entity types include human names, place names, organizational structures, and the like.

[0127] Specifically, in order to ensure the training effect of the model, it is usually necessary to provide a large amount of training sample data for model training. Usually, these training samples are obtained by data enhancement of several initial sample texts and fusion with existing prompt template texts. However, for the entity naming recognition model, due to the large number of entity naming types, the number of training samples constructed by fusion with the existing prompt template text will also be exponentially enhanced, affecting the training efficiency of the model. Therefore, as a feasible embodiment of the present application, a method for generating sample text is provided. The specific implementation scheme can be found in the subsequent Figure 8 and its explanatory contents.

[0128] S620: Input the sample text and part-of-speech tagging information corresponding to the sample text into an encoder in an initial entity recognition model to obtain first sample feature information and second sample feature information corresponding to the sample text.

[0129] In the embodiment of the present application, in order to implement model training to obtain a multi-interactive entity recognition model, it is usually necessary to construct an initial entity recognition model. Specifically, the initial entity recognition model is similar to the multi-interactive entity recognition model obtained by training, and also has an encoder for encoding sample text and a decoder for decoding feature information, but the model parameters in the encoder and the model parameters in the decoder are usually preset initial values. Therefore, it is not possible to predict the accurate probability of each word corresponding to the named entity through the initial text and the part-of-speech information of each word in the initial text. Therefore, in the training process, it is necessary to first input the sample text and the part-of-speech tagging information corresponding to the sample text into the encoder in the initial entity recognition model to obtain the first sample feature information and the second sample feature information corresponding to the sample text. Of course, since the model encoder parameters are initialization parameters, the obtained first sample feature information and the second sample feature information cannot be accurately used to decode to obtain the predicted probability of each word corresponding to the named entity.

[0130] S630: Input the first sample feature information and the second sample feature information into a decoder in an initial entity recognition model to obtain a predicted probability of each word in the sample text corresponding to a named entity.

[0131] In the embodiment of the present application, based on the above, by inputting the first sample feature information and the second sample feature information into the decoder in the initial entity recognition model, the predicted probability of each word in the sample text corresponding to the named entity can be obtained. Specifically, the decoder here is similar to the decoder structure in the multi-interactive entity recognition model in the aforementioned application process, and also has a feature extraction layer, a feature enhancement layer, and an interactive decoding layer, but the model parameters in these network layers are all initial values, so there is a certain difference between the obtained predicted probability and the actual result.

[0132] Of course, considering that there are many confusing entities in named entity recognition data, in order to improve the model's ability to distinguish different entity naming types, in the process of training the model, we will also consider introducing auxiliary tasks to learn the unique features of each named entity category, thereby optimizing the feature extraction layer. Specifically, the goal of the auxiliary task is to reduce the distance between the feature representation and the features of other similar named entities, and to increase the distance between the features of other categories of named entities. That is, by constructing an additional loss function, we can reduce the distance between the feature representation and the features of other similar named entities, and to increase the distance between the features of other categories of named entities, thereby improving the model's ability to distinguish easily confused entities. For specific implementation plans, please refer to the subsequent Figure 7 and its explanatory contents.

[0133] S640: Update the initial entity recognition model according to the difference between the predicted probability and the named entity label to obtain an updated entity recognition model.

[0134] In the embodiment of the present application, after the predicted probability of each word in the sample text corresponding to the named entity is obtained by using the initial network model, there is usually a certain difference between the predicted probability and the actual result. Therefore, the initial entity recognition model can be iteratively updated according to the difference between the predicted probability and the named entity label and based on the idea of ​​back propagation optimization, so that the predicted probability obtained by the updated entity recognition model for processing the sample text is more accurate.

[0135] Specifically, considering that in conventional implementations, the predicted probability and the named entity label can usually exist in the form of a vector, therefore, as a feasible embodiment of the present application, the difference between the predicted probability and the named entity label can be calculated by a cross entropy loss function between the two vectors. Specifically, the named entity label includes a first sequence vector describing the beginning position of the named entity in the sample text and a second sequence vector describing the ending position of the named entity in the sample text. The first cross entropy is obtained by calculating the starting probability of each word corresponding to the named entity in the predicted probability with the first sequence vector, and the ending probability of each word corresponding to the named entity in the predicted probability is calculated by calculating the ending probability of each word corresponding to the named entity with the first sequence vector. The second cross entropy is calculated with the second sequence vector, and finally the first cross entropy and the second cross entropy are summed. The final cross entropy loss value is the difference between the predicted probability and the named entity label. Specifically, the larger the cross entropy loss value, the greater the difference between the predicted probability and the named entity label, and the lower the accuracy of the probability that the model predicts the named entity corresponding to each word in the initial text based on the initial text and the part-of-speech information. Conversely, the smaller the cross entropy loss value, the smaller the difference between the predicted probability and the named entity label, and the higher the accuracy of the probability that the model predicts the named entity corresponding to each word in the initial text based on the initial text and the part-of-speech information.

[0136] S650, until the difference between the predicted probability obtained by inputting the sample text into the updated entity recognition model and the named entity label meets the preset requirement, the currently obtained entity recognition model is determined as the multi-interaction entity recognition model.

[0137] In an embodiment of the present application, the entity recognition model is updated through the aforementioned iterations until the difference between the predicted probability and the named entity label obtained by inputting the sample text into the entity recognition model after a certain model update meets the preset requirements. For example, the cross entropy loss value is less than the preset loss threshold for several consecutive times. This indicates that the currently obtained entity recognition model can accurately predict the probability of each word in the initial text corresponding to the named entity based on the initial text and part-of-speech information. At this time, the currently obtained entity recognition model can be determined as the pre-trained multi-interactive entity recognition model for subsequent recognition processing of named entities in the initial text.

[0138] like Figure 7 As shown, Figure 7 A schematic flow chart of a step of constructing a loss function to update a model provided in an embodiment of the present application, specifically, comprising steps S710 to S730:

[0139] S710, inputting the first sample feature information and the second sample feature information into a decoder in an initial entity recognition model to obtain a predicted probability of each word in the sample text corresponding to a named entity and a first sample feature representation and a second sample feature representation corresponding to the sample text.

[0140] In the embodiment of the present application, combined with the relevant description of the aforementioned step S510, it can be known that the decoder in the multi-interactive entity recognition model includes a feature extraction layer. Therefore, the decoder in the initial entity recognition model also includes a feature extraction layer. Therefore, by inputting the first sample feature information and the second sample feature information into the decoder in the initial entity recognition model, in addition to obtaining the predicted probability of each word corresponding to the named entity in the sample text, the result obtained by the feature extraction layer for the first sample feature information and the second sample feature information, that is, the first sample feature representation and the second sample feature representation, can also be extracted.

[0141] S720, determining a loss value corresponding to the initial entity recognition model based on a first similarity between the first sample feature representation and a type-centric feature representation corresponding to the named entity type in the named entity tag, and a second similarity between the second sample feature and the type-centric feature representation.

[0142] In order to improve the model's ability to identify easily confused entities, in an embodiment of the present application, the loss value corresponding to the initial entity recognition model is determined based on the first similarity between the first sample feature representation and the type-centric feature representation corresponding to the named entity type in the named entity tag, and the second similarity between the second sample feature and the type-centric feature representation. Specifically, the similarity here can be calculated using the cosine similarity calculation formula. The higher the first similarity and the second similarity, the smaller the distance between the feature representation obtained by the model processing the feature information of a named entity and the feature representation obtained from other similar named entities. The higher the model's ability to distinguish easily confused entities. Conversely, the smaller the first similarity and the second similarity, the larger the distance between the feature representation obtained by the model processing the feature information of a named entity and the feature representation obtained from other similar named entities. The weaker the model's ability to distinguish easily confused entities. Specifically, the type-centric feature corresponding to a certain named entity type can be calculated by taking the average value of the feature information processed for that type of named entity type, that is, Among them, c i That is, the type-centric feature representation of the i-th named entity type, and is the encoding vector representation of different named entities in this type of named entity, and n is the number of different named entities in this type of named entity in the training sample.

[0143] Of course, in addition to adding the distance between the feature representation obtained by the model processing the feature information of a named entity and the feature representation obtained by other similar named entities, the training effect of the model can also be improved by increasing the distance between the feature representation obtained by the model processing the feature information of a named entity and the feature representation obtained by other non-similar named entities. Specifically, the calculation is shown as follows:

[0144] d self =||Bc i ||2

[0145] d other =||Bc i* ||2

[0146] d self is a feature representation (including B1 and B2) to the same named entity type c i The type center feature represents the distance between them, and d other It is the feature representation (including B1 and B2) to other named entity types c i* The distance between the type center feature representations, the final loss value can be calculated by the following loss function:

[0147]

[0148] Specifically, N is the size of the input batch-size, which describes the number of training texts input in the batch. represents the distance between the jth sample text and the type center feature representation of the same named entity type, d j Table for the jth sample text, d self With d other The cosine similarity of .

[0149] S730, updating the initial entity recognition model according to the difference between the predicted probability and the named entity label, and the loss value, to obtain an updated entity recognition model.

[0150] In an embodiment of the present application, after the aforementioned training task of improving the model's ability to recognize easily confused entities is additionally introduced and the corresponding loss function is constructed, the final loss value is obtained by further fusing the obtained loss value with the difference between the predicted probability and the named entity label that describe the prediction ability of the model. In this way, the model's ability to recognize easily confused entities can be improved while the accuracy of the training model in predicting named entities is improved.

[0151] like Figure 8 As shown, Figure 8A schematic flow chart of a step of obtaining a sample text provided in an embodiment of the present application, specifically, comprising steps S810 to S830:

[0152] S810, obtaining an initial sample text.

[0153] In the embodiment of the present application, the initial sample text refers to a small batch of sample text existing in a real context pre-constructed by a user, which can usually be crawled in advance through web crawler technology.

[0154] S820: Perform data enhancement processing on the initial sample text to obtain enhanced sample text.

[0155] In the embodiment of the present application, in the process of enhancing the data by processing the sample text, such as the model's recognition ability of easily confused entities, in order to expand the number of training sample texts, considering that named entity recognition is a word-level recognition task, the above-mentioned common data enhancement methods are easy to change the contextual semantic relationship of an entity, bringing greater noise influence. Therefore, as a feasible embodiment of the present application, in the process of data enhancement processing of the initial sample text, the similarity between entities can be fully considered. For a certain named entity in the initial sample text, several entities with the highest similarity are selected from the named entities of the same entity type as the named entity, thereby obtaining an enhanced sample text. The specific implementation process is as follows:

[0156] Given that the entity E in the initial sample text is composed of words e1, e2, and e3, the word vector is first obtained through the Bert model Then concatenate to get the vectorized representation of entity E At the same time, the vectorized representation v of other entities is calculated from the entity naming type corresponding to entity E F , then based on v E and v F Select several entities with the highest similarity to replace entity E in the initial sample text, so as to obtain enhanced sample text.

[0157] S830: Generate a sample text carrying a named entity tag according to the enhanced sample text and the named entity type corresponding to the enhanced sample text.

[0158] In an embodiment of the present application, based on the enhanced sample text obtained above, a named entity tag of the sample text can be obtained based on the position of the named entity in the enhanced sample text, and the sample text carrying the named entity tag can be obtained by associating the named entity tag with the enhanced sample text.

[0159] Of course, in order to improve the training effect of the model, in the process of training the model, the named entity label includes not only the location of the named entity in the sample text, but also the named entity type corresponding to the enhanced sample text. Of course, in order to avoid the problem of exponential increase in data volume due to enumerating all the fragments in the training set sentences during the prompt construction process, the embodiment of the present application provides a prompt construction selection strategy based on contrastive learning. For specific implementation schemes, please refer to the subsequent Figure 8 and its explanatory contents.

[0160] like Fig. 9 As shown, Fig. 9 A schematic flow chart of steps for constructing a prompt sample text provided in an embodiment of the present application, specifically, including steps S910 to S930:

[0161] S910, calculating the similarity between the enhanced sample text and each preset initial template text.

[0162] In the embodiment of the present application, in order to expand the sample text, it is usually necessary to combine the enhanced sample text with other template texts with prompt information, that is, entity naming types. However, due to the large number of entity naming types, combining each fragment of the sample text with each template text will produce an exponentially growing sample text. Therefore, in the embodiment of the present application, the similarity between the enhanced sample text and the preset initial template texts will be calculated, and those with higher similarity to the enhanced sample text will be preferably selected, that is, the initial template text with stronger correlation with the enhanced sample text will be selected. Specifically, the similarity here can also be calculated based on the pre-similarity.

[0163] S920: Determine a target template text from the initial template text according to the magnitude relationship of the similarities.

[0164] In an embodiment of the present application, based on the aforementioned determination of the similarity between the enhanced sample text and the preset initial template texts, based on the size relationship of the similarity, the initial template text with a higher correlation with the target template text can be determined from the initial template text, and the named entity type in the target template text can be used as prompt information of the named entity type of the enhanced sample text.

[0165] S930: Merge the named entity type corresponding to the target template text with the enhanced sample text to obtain a sample text carrying a named entity tag.

[0166] In an embodiment of the present application, by using the named entity type corresponding to the target template text as prompt information and fusing it with the enhanced sample text, a sample text carrying a named entity label can be obtained. Specifically, the sample text can be in the form of "[CLS]+prompt+[SEP]+text+[SEP]", where the prompt is the named entity type corresponding to the target template text, and the text is the enhanced sample text provided above.

[0167] To facilitate understanding of the complete implementation scheme of training a multi-interaction entity recognition model provided in the embodiment of the present application, the following will be combined with Fig.10 The model diagram of the multi-interaction entity recognition model provided provides a complete implementation process for training the multi-interaction entity recognition model, as follows:

[0168] 1) The input text of the model is usually the text with prompt information obtained by fusing text and prompt information, that is, [CLS]+Prompt+[SEP]+Contect+[SEP];

[0169] 2) A first encoding vector is obtained based on the word vector, block vector and position vector of the text, and a second encoding vector is obtained based on the part-of-speech encoding of the text, wherein the word vector is the result of modifying the one-hot vector based on the part-of-speech;

[0170] 3) The first encoding vector and the second encoding vector are processed respectively to obtain the first feature representation and the second feature representation, and based on the distance between the feature representations, a feature optimization layer for training the model's ability to recognize easily confusing entities is constructed. The output result Loss1 of this layer corresponds to the aforementioned Figure 7 The loss value provided;

[0171] 4) After the prompt enhancement layer constructed based on the multi-head attention mechanism processes the first feature representation and the second feature representation respectively, the processed first feature representation is decoded to obtain the initial probability of each word in the initial text corresponding to the beginning of the named entity, and then based on the interactive decoding, the processed first feature representation and the second feature representation are used to perform decoding to obtain the end probability of each word in the initial text corresponding to the named entity.

[0172] 5) The second loss value Loss2 and the third loss value Loss3 are calculated based on the difference between the initial probability and the final probability and the label in the input text, and finally the iterative optimization of the entity recognition model is completed by the sum of the loss values ​​of Loss1, Loss2 and Loss3 until the final multi-interaction entity recognition model is obtained.

[0173] In order to better implement the named entity recognition method provided in the embodiment of the present application, on the basis of the named entity recognition method provided in the embodiment of the present application, the embodiment of the present application also provides a named entity recognition device, such as Fig.11 As shown, the named entity recognition device 1100 includes:

[0174] An acquisition module 1110 is used to acquire an initial text to be processed for entity recognition;

[0175] An encoding module 1120, configured to obtain first feature information and second feature information of the initial text based on the initial text and part-of-speech information of each word in the initial text;

[0176] The recognition module 1130 is used to determine the named entity in the initial text according to the first feature information and the second feature information.

[0177] In some embodiments of the present application, the encoding module 1120 is also used to perform feature extraction on the initial text to obtain first feature information of the initial text; perform feature extraction on the part-of-speech information of each word in the initial text to obtain part-of-speech feature information in the initial text; and fuse the first feature information and the second feature information to obtain second feature information of the initial text.

[0178] In some embodiments of the present application, the recognition module 1130 is also used to determine the starting probability of each word in the initial text corresponding to the named entity based on the second feature information; determine the ending probability of each word in the initial text corresponding to the named entity based on the first feature information and the second feature information; and match the words in the initial text based on the starting probability and ending probability of each word in the initial text corresponding to the named entity to obtain the named entities in the initial text.

[0179] In some embodiments of the present application, the encoding module 1120 is also used to input the initial text and the part-of-speech information of each word in the initial text into the encoder in the multi-interactive entity recognition model for processing to obtain the first feature information and the second feature information of the initial text; the decoding module 1030 is also used to input the first feature information and the second feature information into the decoder in the multi-interactive entity recognition model for processing to obtain the named entities in the initial text.

[0180] In some embodiments of the present application, the recognition module 1130 is also used to input the first feature information and the second feature information into the feature extraction layer for processing to obtain the first feature representation and the second feature representation of the initial text; input the first feature representation and the second feature representation of the initial text into the feature enhancement layer for processing to obtain the first enhanced feature representation and the second enhanced feature representation of the initial text; input the first enhanced feature representation and the second enhanced feature representation into the interactive decoding layer for processing to obtain the named entities in the initial text.

[0181] In some embodiments of the present application, the encoding module 1120 is also used to obtain sample text and a named entity tag corresponding to the sample text; input the sample text and the part-of-speech tagging information corresponding to the sample text into the encoder in the initial entity recognition model to obtain first sample feature information and second sample feature information corresponding to the sample text; input the first sample feature information and the second sample feature information into the decoder in the initial entity recognition model to obtain the predicted probability of each word in the sample text corresponding to the named entity; update the initial entity recognition model according to the difference between the predicted probability and the named entity tag to obtain an updated entity recognition model; until the difference between the predicted probability obtained by inputting the sample text into the updated entity recognition model and the named entity tag meets the preset requirements, the currently obtained entity recognition model is determined as the multi-interactive entity recognition model.

[0182] In some embodiments of the present application, the encoding module 1120 is also used to input the first sample feature information and the second sample feature information into a decoder in an initial entity recognition model to obtain a predicted probability of each word in the sample text corresponding to a named entity and a first sample feature representation and a second sample feature representation corresponding to the sample text; determine a loss value corresponding to the initial entity recognition model based on a first similarity between the first sample feature representation and a type-center feature representation corresponding to a named entity type in the named entity label, and a second similarity between the second sample feature and the type-center feature representation; and update the initial entity recognition model based on the difference between the predicted probability and the named entity label, and the loss value, to obtain an updated entity recognition model.

[0183] In some embodiments of the present application, the encoding module 1120 is also used to obtain an initial sample text; perform data enhancement processing on the initial sample text to obtain an enhanced sample text; and generate a sample text carrying a named entity tag based on the enhanced sample text and the named entity type corresponding to the enhanced sample text.

[0184] In some embodiments of the present application, the encoding module 1120 is also used to calculate the similarity between the enhanced sample text and each preset initial template text; determine the target template text from the initial template text based on the size relationship of the similarity; and merge the named entity type corresponding to the target template text with the enhanced sample text to obtain a sample text carrying a named entity tag.

[0185] For the specific definition of the named entity recognition device, please refer to the definition of the named entity recognition method above, which will not be repeated here. The various modules in the above-mentioned named entity recognition device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0186] In some embodiments of the present application, the named entity recognition device 1100 may be implemented in the form of a computer program. The computer program may be implemented in Fig.12 The computer device shown in the figure is run on the computer device. The memory of the computer device can store various program modules constituting the named entity recognition device 1100, for example, Fig.11 The acquisition module 1110, encoding module 1120 and recognition module 1130 are shown. The computer program composed of various program modules enables the processor to execute the steps of the named entity recognition method of each embodiment of the present application described in this specification.

[0187] For example, Fig.12 The computer device shown can be Fig.11 The acquisition module 1110 in the named entity recognition device 1100 shown executes step S110. The computer device can execute step S120 through the encoding module 1120. The computer device can execute step S130 through the recognition module 1130. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external computer device through a network connection. When the computer program is executed by the processor, a method for named entity recognition is implemented.

[0188] Those skilled in the art will understand that Fig.11The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0189] In some embodiments of the present application, a computer device is provided, comprising one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the following steps:

[0190] Get the initial text to be processed for entity recognition;

[0191] Based on the initial text and part-of-speech information of each word in the initial text, obtaining first feature information and second feature information of the initial text;

[0192] Determine a named entity in the initial text according to the first feature information and the second feature information.

[0193] In some embodiments of the present application, a computer-readable storage medium is provided, which stores a computer program. The computer program is loaded by a processor, so that the processor performs the following steps:

[0194] Get the initial text to be processed for entity recognition;

[0195] Based on the initial text and part-of-speech information of each word in the initial text, obtaining first feature information and second feature information of the initial text;

[0196] Determine a named entity in the initial text according to the first feature information and the second feature information.

[0197] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0198] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0199] The above is a detailed introduction to a named entity recognition method, apparatus, computer device and storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for named entity recognition, characterized in that: include: Get the initial text to be processed for entity recognition; Based on the initial text and part-of-speech information of each word in the initial text, obtaining first feature information and second feature information of the initial text; A named entity in the initial text is determined according to the first feature information and the second feature information.

2. The method for named entity recognition according to claim 1, characterized in that: The obtaining, based on the initial text and the part-of-speech information of each word in the initial text, the first feature information and the second feature information of the initial text comprises: Performing feature extraction on the initial text to obtain first feature information of the initial text; Extracting features of the part-of-speech information of each word in the initial text to obtain the part-of-speech feature information in the initial text; The first feature information and the second feature information are merged to obtain the second feature information of the initial text.

3. The method for named entity recognition according to claim 1, characterized in that: The determining, according to the first feature information and the second feature information, the named entity in the initial text includes: Based on the second feature information, determining the starting probability of each word in the initial text corresponding to the named entity; Determining, based on the first feature information and the second feature information, the end probability of each word corresponding to the named entity in each of the initial texts; Based on the start probability and the end probability of each word in the initial text corresponding to the named entity, the words in the initial text are matched to obtain the named entity in the initial text.

4. The method for named entity recognition according to any one of claims 1 to 3, characterized in that: The named entity recognition method is applied to a pre-trained multi-interaction entity recognition model; The obtaining, based on the initial text and the part-of-speech information of each word in the initial text, the first feature information and the second feature information of the initial text comprises: Inputting the initial text and part-of-speech information of each word in the initial text into an encoder in the multi-interactive entity recognition model for processing to obtain first feature information and second feature information of the initial text; The determining, according to the first feature information and the second feature information, the named entity in the initial text includes: The first feature information and the second feature information are input into a decoder in the multi-interactive entity recognition model for processing to obtain named entities in the initial text.

5. The method for named entity recognition according to claim 4, characterized in that: The decoder includes a feature extraction layer, a feature enhancement layer and an interactive decoding layer; The step of inputting the first feature information and the second feature information into a decoder in the multi-interactive entity recognition model for processing to obtain the named entities in the initial text includes: Inputting the first feature information and the second feature information into the feature extraction layer for processing to obtain a first feature representation and a second feature representation of the initial text; Inputting the first feature representation and the second feature representation of the initial text into the feature enhancement layer for processing to obtain the first enhanced feature representation and the second enhanced feature representation of the initial text; The first enhanced feature representation and the second enhanced feature representation are input into the interactive decoding layer for processing to obtain the named entities in the initial text.

6. The method for named entity recognition according to claim 4, characterized in that: The multi-interaction entity recognition model is trained in the following way: Obtaining sample text and named entity tags corresponding to the sample text; Inputting the sample text and part-of-speech tagging information corresponding to the sample text into an encoder in an initial entity recognition model to obtain first sample feature information and second sample feature information corresponding to the sample text; Inputting the first sample feature information and the second sample feature information into a decoder in an initial entity recognition model to obtain a predicted probability of each word in the sample text corresponding to a named entity; According to the difference between the predicted probability and the named entity label, the initial entity recognition model is updated to obtain an updated entity recognition model; When the difference between the predicted probability obtained by inputting the sample text into the updated entity recognition model and the named entity label meets the preset requirement, the currently obtained entity recognition model is determined as the multi-interaction entity recognition model.

7. The method for named entity recognition according to claim 6, characterized in that: The step of inputting the first sample feature information and the second sample feature information into a decoder in an initial entity recognition model to obtain a predicted probability of each word in the sample text corresponding to a named entity includes: Inputting the first sample feature information and the second sample feature information into a decoder in an initial entity recognition model to obtain a predicted probability of each word in the sample text corresponding to a named entity and a first sample feature representation and a second sample feature representation corresponding to the sample text; Determine a loss value corresponding to the initial entity recognition model according to a first similarity between the first sample feature representation and a type-centric feature representation corresponding to a named entity type in the named entity tag, and a second similarity between the second sample feature and the type-centric feature representation; The updating of the initial entity recognition model according to the difference between the predicted probability and the named entity label to obtain an updated entity recognition model includes: According to the difference between the predicted probability and the named entity label, and the loss value, the initial entity recognition model is updated to obtain an updated entity recognition model.

8. The method for named entity recognition according to claim 6, characterized in that: The obtaining of the sample text and the named entity label corresponding to the sample text includes: Get the initial sample text; Performing data enhancement processing on the initial sample text to obtain enhanced sample text; A sample text carrying a named entity tag is generated according to the enhanced sample text and the named entity type corresponding to the enhanced sample text.

9. The method for named entity recognition according to claim 8, characterized in that: The generating of the sample text carrying the named entity tag according to the enhanced sample text and the named entity type corresponding to the enhanced sample text includes: Calculating the similarity between the enhanced sample text and each preset initial template text; Determining a target template text from the initial template text according to the magnitude relationship of the similarities; The named entity type corresponding to the target template text is fused with the enhanced sample text to obtain a sample text carrying a named entity tag.

10. A named entity recognition device, characterized in that: include: An acquisition module is used to acquire the initial text to be processed by entity recognition; An encoding module, configured to obtain first feature information and second feature information of the initial text based on the initial text and part-of-speech information of each word in the initial text; A recognition module is used to determine the named entity in the initial text according to the first feature information and the second feature information.

11. A computer device, characterized in that: The computer device comprises: one or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the named entity recognition method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the named entity recognition method according to any one of claims 1 to 9.

Citation Information

Cited By

  • Information leakage suppression device, information leakage suppression method, and program

    JP7879396B1