Hierarchical cascade nested entity recognition model and its construction method and storage medium
Through the hierarchical and cascaded nested entity recognition model, ERNIE3.0 and BiGRU+CRF models are used to identify complex nested entities, which solves the problem that traditional methods are difficult to deal with nested entities and improves the accuracy and efficiency of recognition.
Patent Information
- Application Number
- CN202410991129.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-09-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional named entity recognition methods are difficult to handle complex nested and cross-entity structures, resulting in difficulties in exploring and understanding overlapping entities in areas such as legal document analysis, and incomplete or misunderstood information.
A hierarchical and cascaded nested entity recognition model is used to perform hierarchical entity annotation on sample sentences through preset entity categories and nesting levels. The ERNIE3.0 pre-training model and BiGRU+CRF model are used for sequence annotation and feature extraction. Identify outer entities and recursively identify inner entities, and determine nested relationships based on semantic similarity and dependency relationships.
It improves the accuracy and efficiency of nested entity recognition, can better decompose outer entities into fine-grained inner entities, and accurately reflects the nested relationships and contextual connections between entities.
Smart Images

Figure CN118520876B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing, and in particular to a hierarchical cascade nested entity recognition model and a construction method and storage medium thereof. Background Art
[0002] Named entity recognition is a core task in natural language processing. Its goal is to identify entities with specific meanings or attributes from text and classify them into predefined categories. For example, from the sentence "Wang XX is one of the founders of XX Group. He was born in XX City, XX Province in 1954.", we can identify "Wang XX" as a person's name (character), "XX Group" as an organization name (organization), "1954" as a time expression (time), and "XX City, XX Province" as a place name (place). By identifying and classifying entities, named entity recognition (NER) helps to have a deeper understanding and analysis of text content. This is of great significance for many advanced natural language processing applications, such as question-answering systems, semantic search, text summarization, sentiment analysis, information retrieval, speech recognition post-processing, knowledge graph construction, etc.
[0003] Traditional named entity recognition (NER) methods can usually only capture single-level entities, such as names, time or institutions, and cannot handle more complex nested and intersecting multi-level entity structures in text. This limitation leads to certain difficulties in exploring and understanding overlapping entities in information containing nested entities, such as legal document analysis and biomedical literature mining. In addition, these methods may cause incomplete or misunderstood information because single-level entity recognition cannot accurately reflect the nested relationship and contextual connection between entities.
[0004] In recent years, with the development of deep learning technology, especially the emergence of pre-trained models such as BERT and ERNIE, the field of named entity recognition has made rapid progress. These models can automatically learn the deep features of text, thereby greatly improving the accuracy and robustness of entity recognition. However, although these models have achieved good results in many tasks, there are still some challenges in the named entity recognition task, such as failure to utilize the interactive information of inner and outer entities, and blurred entity boundaries. Summary of the invention
[0005] In view of the above problems, the present invention is proposed to provide a hierarchical cascade nested entity recognition model and a construction method and storage medium thereof that overcome the above problems or at least partially solve the above problems.
[0006] One aspect of the present invention provides a method for constructing a hierarchical cascade nested entity recognition model, the method comprising:
[0007] Perform hierarchical entity annotation on sample sentences according to preset entity categories and nesting levels;
[0008] The hierarchical entity annotation results of the sample sentences are sequence-annotated for each entity layer according to the BIESO annotation mode;
[0009] The sequence labeling results are used as sample input data to input into the ERNIE3.0 pre-training model for pre-training to obtain the dynamic word vector corresponding to the sample sentence;
[0010] Using a preset outer entity recognition model to learn and train the dynamic word vector to obtain a first recognition result of the outer entity in the sample sentence;
[0011] Identify, from the first recognition result, an outer entity having an inner entity nested therein;
[0012] According to the entity category to which the outer layer entity belongs, the outer layer entity is input into a preset inner layer entity recognition model corresponding to the entity category to perform learning and training, so as to obtain a second recognition result of the second layer entity in the outer layer entity.
[0013] Optionally, after obtaining the second recognition result of the second layer entity in the outer layer entity, the method further includes:
[0014] Identify, from the second recognition result, a second-level entity in which an inner-level entity is nested;
[0015] If a second-layer entity is identified that is nested with an inner-layer entity, the second-layer entity is input into a preset inner-layer entity recognition model corresponding to the entity category to which it belongs for learning and training, and a third recognition result of the third-layer entity in the second-layer entity is obtained. A recursive recognition method is then adopted to continue the recognition of the next layer of entities until the entity recognition results of all layers in the sample sentence are obtained.
[0016] Optionally, the step of performing hierarchical entity labeling on the sample sentences according to preset entity categories and nesting levels includes:
[0017] The deepest nesting level of predefined entities is 4, and entity categories include place name entity, organization entity, name entity, position entity and time entity;
[0018] According to the number of nested layers corresponding to each sample sentence, hierarchical entity annotation is performed on the place name entity, organization entity, name entity, position entity and / or time entity contained in each layer of the sample sentence from the inner layer to the outer layer.
[0019] Optionally, a preset outer entity recognition model is used to learn and train the dynamic word vector to obtain a first recognition result of the outer entity in the sample sentence, including:
[0020] The outer entity recognition model includes a first BiGRU model and a first CRF model, and the first BiGRU model is used to extract deep features of the dynamic word vector to obtain a second dynamic word vector that highlights the contextual semantic association information of the sample sentence;
[0021] Use a preset natural language processing toolkit to perform part-of-speech analysis and syntactic analysis on the sample sentences to determine the words contained in the sample sentences and the dependency relationships between the words;
[0022] The first CRF model is used to learn and train the second dynamic word vector and the words in the sample sentence and the dependency relationship between the words to identify the noun phrases in the sample sentence and obtain the first recognition result of the outer entity in the sample sentence.
[0023] Optionally, identifying an outer entity in which an inner entity is nested from the first recognition result includes:
[0024] Use a preset natural language processing tool to perform part-of-speech analysis and syntactic analysis on the outer entities identified from the sample sentences to determine the words contained in the outer entities and the dependency relationships between the words;
[0025] Take each word contained in the outer entity as a substring, extract the word vector of each substring from the dynamic word vector corresponding to the sample sentence, and calculate the semantic similarity between the substrings. The semantic similarity calculation formula is:
[0026]
[0027] in, , Represent the word vectors of the two substrings respectively, Representing word vectors With word vector The dot product of ‖and‖ ‖ represents the modulus of the corresponding word vector;
[0028] Whether there is an inner entity nested inside is comprehensively judged based on the semantic similarity between the substrings contained in the outer entity and the words contained in the outer entity and the dependency relationship between the words.
[0029] Optionally, according to the entity category to which the outer-layer entity belongs, the outer-layer entity is input into a preset inner-layer entity recognition model corresponding to the entity category to perform learning and training, so as to obtain a second recognition result of the second-layer entity in the outer-layer entity, including:
[0030] The inner entity recognition model consists of four models, including the inner entity recognition model corresponding to the place name entity category, the inner entity recognition model corresponding to the organization entity category, the inner entity recognition model corresponding to the name entity category, and the inner entity recognition model corresponding to the position entity category;
[0031] The inner entity recognition model of each category includes a second BiGRU model and a second CRF model. The second BiGRU model is used to extract deep features of the outer entity to obtain a third dynamic word vector that highlights the contextual semantic association information of the sample sentence.
[0032] Acquire a preset entity nesting rule corresponding to the entity category to which the outer entity belongs, wherein the entity nesting rule uses a regular expression to represent the inner entity division mode of the corresponding entity category;
[0033] The second CRF model is used to learn and train the entity nesting rules corresponding to the third dynamic word vector and the current outer entity to identify the second-layer entity in the outer entity, and obtain a second recognition result of the second-layer entity in the outer entity.
[0034] Optionally, the method further comprises:
[0035] The overall loss of the hierarchical cascaded nested entity recognition model is calculated as follows:
[0036] L = L 外层实体识别模型 + L 内层实体识别模型 + L 额外
[0037] Among them, L 外层实体识别模型 is the CRF loss of the outer entity recognition model, L 内层实体识别模型 is the CRF loss of the inner entity recognition model, L 额外 It is the recognition error loss when the outer entity recognition model correctly recognizes the outer entity but fails to recognize that the current outer entity is nested with an inner entity, and the recognition error loss when the inner entity recognition model correctly recognizes the inner entity but fails to recognize that the current inner entity is still nested with an inner entity.
[0038] Another aspect of the present invention further provides a hierarchical cascade nested entity recognition model, the model comprising:
[0039] An entity annotation module is used to perform hierarchical entity annotation on sample sentences according to preset entity categories and nesting levels;
[0040] The sequence labeling module is used to label each entity layer in sequence according to the BIESO labeling mode based on the hierarchical entity labeling results of the sample sentence;
[0041] The pre-training module is used to input the sequence labeling results as sample input data into the ERNIE3.0 pre-training model for pre-training to obtain the dynamic word vector corresponding to the sample sentence;
[0042] An outer entity recognition module, used to use a preset outer entity recognition model to learn and train the dynamic word vector to obtain a first recognition result of the outer entity in the sample sentence;
[0043] A context analysis module, used to identify an outer entity in which an inner entity is nested from the first recognition result;
[0044] The inner entity recognition module is used to input the outer entity into a preset inner entity recognition model corresponding to the entity category for learning and training according to the entity category to which the outer entity belongs, so as to obtain a second recognition result of the second layer entity in the outer entity.
[0045] The third aspect of the present invention further provides a nested entity recognition method based on a hierarchical cascade nested entity recognition model, the method comprising:
[0046] The sentence to be recognized is used as input data into the ERNIE3.0 pre-trained model for feature extraction to obtain the target dynamic word vector corresponding to the sentence to be recognized;
[0047] Using a pre-trained outer entity recognition model to perform outer entity recognition on the target dynamic word vector to obtain at least one target outer entity in the sentence to be recognized;
[0048] Identify the outer-layer entities to be identified that have inner-layer entities nested in them from each target outer-layer entity;
[0049] According to the entity category to which the outer-layer entity to be identified belongs, the outer-layer entity to be identified is input into a preset inner-layer entity recognition model corresponding to the entity category to perform inner-layer entity recognition, and at least one second-layer entity in the outer-layer entity to be identified is obtained.
[0050] The fourth aspect of the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for constructing the above-mentioned hierarchical cascaded nested entity recognition model, or the steps of the nested entity recognition method based on the hierarchical cascaded nested entity recognition model.
[0051] The hierarchical cascade nested entity recognition model and its construction method and storage medium provided by the embodiment of the present invention perform hierarchical entity annotation on sample sentences according to preset entity categories and nested levels, and perform sequence annotation on each entity layer according to the BIESO annotation mode, and then pre-train the sequence annotation results through the ERNIE3.0 pre-training model to obtain the dynamic word vector of the sample sentence, and use the preset outer entity recognition model to learn and train the dynamic word vector to obtain the outer entity in the sample sentence, and identify the outer entity with the inner entity nested from each outer entity, and finally input the outer entity into the inner entity recognition model corresponding to the entity category to which the outer entity belongs for learning and training to obtain the inner entity nested in the outer entity. The present invention utilizes the nested relationship and contextual connection between entities, can better decompose the outer entity in the sentence into fine-grained inner entities, and hierarchically recognize the nested entities in the sentence, which greatly improves the accuracy and efficiency of nested entity recognition.
[0052] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0054] Figure 1 A flowchart of a method for constructing a hierarchical cascade nested entity recognition model provided by an embodiment of the present invention;
[0055] Figure 2 A schematic diagram of sequence labeling results of performing sequence labeling in the BIESO labeling mode proposed in an embodiment of the present invention;
[0056] Figure 3 A structural block diagram of a hierarchical cascade nested entity recognition model proposed in an embodiment of the present invention;
[0057] Figure 4 The overall architecture diagram of the hierarchical cascade nested entity recognition model proposed in the embodiment of the present invention;
[0058] Figure 5 The present invention is a flowchart of a nested entity recognition method based on a hierarchical cascaded nested entity recognition model proposed in an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0060] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0061] Those skilled in the art will understand that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined.
[0062] Figure 1 The flowchart schematically shows a method for constructing a hierarchical cascade nested entity recognition model according to an embodiment of the present invention. Figure 1 The method for constructing a hierarchical cascade nested entity recognition model according to an embodiment of the present invention specifically includes the following steps:
[0063] S11. Perform hierarchical entity labeling on sample sentences according to preset entity categories and nesting levels.
[0064] In this embodiment, firstly, the text characteristics are deeply analyzed, and the deepest nesting level of the entity is predefined as 4 layers, and the entity categories include five entity categories: place name entity (Loc), organization entity (Org), name entity (Name), position entity (Pos) and time entity (Time). Then, the sample sentences are sequenced. In the labeling process, hierarchical entity labeling is performed on the place name entity, organization entity, name entity, position entity and / or time entity contained in each layer of the sample sentence from the inner layer to the outer layer according to the number of nesting layers corresponding to each sample sentence.
[0065] S12. Sequence labeling is performed on each entity layer according to the BIESO labeling mode based on the hierarchical entity labeling results of the sample sentence.
[0066] In this embodiment, after all the data in each layer are labeled, the labeled data are sequence labeled for each entity layer according to the BIESO annotation mode, and converted into the BIESO annotation mode. Where B- indicates the beginning of the entity, I- indicates the middle of the entity, E- indicates the end of the entity, S- indicates a single-word entity, and O indicates a non-entity part). The sequence labeling result is as follows: Figure 2 shown.
[0067] S13. Input the sequence labeling results as sample input data into the ERNIE3.0 pre-training model for pre-training to obtain the dynamic word vector corresponding to the sample sentence.
[0068] The embodiment of the present invention inputs the sequence labeling result as sample input data into the ERNIE3.0 pre-training model for pre-training to obtain a dynamic word vector corresponding to the sample sentence, so as to perform subsequent analysis based on the dynamic word vector to realize nested entity recognition.
[0069] Among them, the ERNIE pre-training model is a pre-training model released by Baidu, including different versions such as ERNIE1.0, 2.0, and 3.0. The present invention uses the latest version of the ERNIE3.0 pre-training model to pre-train sample sentences to vectorize the text where the entity is located, wherein the text is vectorized, that is, to express these texts in the form of data. Specifically, it is in the form of a vector, so it is also called a word vector, and the pre-training model will assign different weights to the words in the sentence according to the order of sentences and tasks each time to form different dynamic word vectors. The ERNIE3.0 pre-training model is different from the BERT pre-training model in that the former uses a variety of joint training tasks, which can better understand the semantics and structural information of the text, and uses technical means such as a multi-head attention mechanism to enhance the modeling ability of the model. Therefore, ERNIE3.0 can better process natural language text data, improve the performance and robustness of the model, and can be more suitable for Chinese language tasks.
[0070] S14, using a preset outer entity recognition model to learn and train the dynamic word vector to obtain a first recognition result of the outer entity in the sample sentence;
[0071] S15, identifying an outer entity having an inner entity nested therein from the first recognition result;
[0072] S16. Input the outer-layer entity into a preset inner-layer entity recognition model corresponding to the entity category to perform learning and training according to the entity category to which the outer-layer entity belongs, and obtain a second recognition result of the second-layer entity in the outer-layer entity.
[0073] The method for constructing a hierarchical cascade nested entity recognition model provided by the embodiment of the present invention performs hierarchical entity annotation on sample sentences according to preset entity categories and nested levels, and performs sequence annotation on each entity layer according to the BIESO annotation mode, and then pre-trains the sequence annotation results through the ERNIE3.0 pre-training model to obtain the dynamic word vector of the sample sentence, and uses the preset outer entity recognition model to learn and train the dynamic word vector to obtain the outer entity in the sample sentence, and recognizes the outer entity with the inner entity nested from each outer entity, and finally inputs the outer entity into the inner entity recognition model corresponding to the entity category to which the outer entity belongs for learning and training to obtain the inner entity nested in the outer entity. The present invention utilizes the nested relationship and contextual connection between entities, can better decompose the outer entity in the sentence into fine-grained inner entities, and hierarchically recognizes the nested entities in the sentence, which greatly improves the accuracy and efficiency of nested entity recognition.
[0074] The present invention constructs a model to identify nested entities in the case of data stratification, and divides the model into two layers. The outer entity recognition model and the inner entity recognition model are both composed of BiGRU+CRF. BiGRU can effectively capture information when processing long sequences and can dynamically extract features, which is very important for understanding the entire sentence structure and entities in the context, and the CRF layer can effectively consider the dependencies between labels. For example, in the BIESO labeling system, the B label is usually followed by the I label or the E label, and the I label is followed by the E label. CRF can help the model learn these rules, thereby improving the overall labeling accuracy.
[0075] Further, in an optional embodiment of the present invention, the step S14 uses a preset outer entity recognition model to learn and train the dynamic word vector to obtain a first recognition result of the outer entity in the sample sentence, which specifically includes the following steps not shown in the figure:
[0076] S141. The outer entity recognition model includes a first BiGRU model and a first CRF model. The first BiGRU model is used to extract deep features of the dynamic word vector to obtain a second dynamic word vector that highlights the contextual semantic association information of the sample sentence.
[0077] In the embodiment of the present invention, a bidirectional GRU is used to capture the global features of a sentence. GRU is a recurrent neural network that can capture temporal dependencies in sequence data. The bidirectional GRU models sentences from two directions, thereby capturing inter-sentence information and contextual semantic association information of the sentence.
[0078] S142: Use a preset natural language processing toolkit to perform part-of-speech analysis and syntactic analysis on the sample sentence to determine the words contained in the sample sentence and the dependency relationship between the words.
[0079] S143. Use the first CRF model to learn and train the second dynamic word vector and the words in the sample sentence and the dependency relationship between the words to identify the noun phrases in the sample sentence and obtain a first recognition result of the outer entity in the sample sentence.
[0080] In this embodiment, first, the sequence-annotated data is input into the ERNIE3.0 model for pre-training to obtain a dynamic word vector corresponding to the sample sentence. Then it is input into the first layer model, that is, the outer entity recognition model, so that the BIGRU model encodes the sentence to capture the contextual information in the sentence. Then the part-of-speech tagging information and syntactic analysis are used as additional features to provide more useful information to the model to identify basic entities (i.e., flat entities). In a specific example, taking "XX City Housing and Urban-Rural Construction Bureau quickly entered the household for identification after hearing the news and supported Yang's family to implement the transformation again." as an example, each word in the second dynamic word vector obtained by the BIGRU model contains the information of its surrounding words, and then the part-of-speech tagging tool is used to perform part-of-speech analysis and syntactic analysis on the sample sentence to determine the part of speech of each word. It is found that the core word of the entity is the noun "Housing and Urban-Rural Construction Bureau", and its modified word "XX City" may be part of the entity. "XX City Housing and Urban-Rural Construction Bureau" is a noun phrase as a whole. The sample sentence is then syntactically analyzed using the dependency syntactic analysis tool to understand the dependency relationship between words and determine that "XX City Housing and Urban-Rural Construction Bureau" is the subject of the sentence. The CRF model then labels and predicts each word in the sentence. At this time, the results of dependency syntactic analysis and part-of-speech analysis can be used to help determine the entity boundary, because usually, there is a specific dependency relationship between the core word of the entity and other modifying words, such as the attributive relationship or the verb-object relationship. Based on these dependencies, the entity boundary can be inferred. Part-of-speech analysis can determine the part of speech of each word, such as noun, verb, adjective, etc. Entities are usually composed of nouns, so part-of-speech analysis can help determine the core words of the entity, so that according to the results of part-of-speech tagging, the noun phrases in the sentence can be identified, and then the entity boundary can be determined. In this example, the first-layer model will eventually label "XX City Housing and Urban-Rural Construction Bureau" as an outer entity of the entire Org (organization).
[0081] Further, in an optional embodiment of the present invention, identifying the outer entity having the inner entity nested therein from the first recognition result in step S15 specifically includes the following steps not shown in the drawings:
[0082] S151, using a preset natural language processing tool to perform part-of-speech analysis and syntactic analysis on the outer entity identified from the sample sentence to determine the words contained in the outer entity and the dependency relationship between the words;
[0083] S152, taking each word contained in the outer entity as a substring, extracting the word vector of each substring from the dynamic word vector corresponding to the sample sentence, and calculating the semantic similarity between the substrings. The semantic similarity calculation formula is:
[0084]
[0085] in, , Represent the word vectors of the two substrings respectively, Representing word vectors With word vector The dot product of ‖ and ‖b‖ represent the modulus of the corresponding word vector;
[0086] S153: Comprehensively determine whether an inner entity is nested based on the semantic similarity between substrings contained in the outer entity and the words contained in the outer entity and the dependency relationship between the words.
[0087] In this step, for the coarse-grained entities (outer-layer entities) already identified by the first-layer model, i.e., the outer-layer entity recognition model, the context analysis module is used to further analyze its internal structure to determine whether there are more fine-grained entities. If so, they are input into the next-layer model, i.e., the inner-layer entity recognition model, according to the type to which the entity belongs. In the present invention, the context analysis module uses a preset natural language processing tool to perform dependency syntax analysis and part-of-speech analysis on the coarse-grained entities again, extracts the word vectors of each substring from the dynamic word vectors corresponding to the sample sentences (i.e., the dynamic word vectors pre-trained by ERNIE 3.0), and calculates the semantic similarity of the dynamic word vectors of the coarse-grained entities. In this embodiment, when calculating the semantic similarity, cosine similarity is used, that is, the included angle between word vectors is measured in a high-dimensional space. The semantic similarity in the embodiments of the present invention refers to calculating the substring-level similarity. The higher the similarity value, the more similar the semantics between words. In the present invention, the similarity threshold can be set to a threshold greater than or equal to 0.7, preferably 0.7 to 0.9. If a certain word has a high similarity with the surrounding words, it may indicate that the word is an entity, thereby judging the possibility of containing fine-grained entities. Here, the "certain word" refers to a substring, such as "XX City", "Housing and Urban-Rural Development Bureau", and the "surrounding words" refer to the words or substrings next to the "certain word". In the same phrase, these words are adjacent to the "certain word" in space. For example, for "XX City Housing and Urban-Rural Development Bureau", if the "certain word" is "XX City", then the "surrounding words" are "Housing and Urban-Rural Development Bureau". Substring analysis helps to capture more complex and detailed semantic relationships, especially when dealing with nested entities or entities with complex semantics. Although in Chinese, a single Chinese character often carries rich meanings and can be used as a word independently, single-character analysis may not be able to capture the complete semantics of phrases or word groups composed of multiple characters, because single-character entities are very few. For example, "Tianchang" as a whole represents a regional name, while the individual characters "Tian" and "Chang" do not have such semantics.In the above example, after the context analysis module analyzes "XX City Housing and Urban-Rural Construction Bureau", dependency syntactic analysis can provide the grammatical relationship between the various components (substrings) within the entity. It can identify "XX City" as the attributive of "Housing and Urban-Rural Construction Bureau" and "Housing and Urban-Rural Construction Bureau" as the central word, indicating that the two parts are syntactically related, which helps to determine which substring combinations should be considered when analyzing the entity; the part-of-speech analysis result can help determine the entity category to which the substring may belong. "XX City" may be marked as a place name, such as using the label NR or NS, representing a proper noun or a place name, while "Housing and Urban-Rural Construction Bureau" may be marked as an institution name, such as using the label NT, representing an institutional group noun. Such information is very useful for judging whether a substring should be treated as an independent entity; for each substring, such as "XX City" and "Housing and Urban-Rural Construction Bureau", the word vectors of each substring are extracted from the dynamic word vector corresponding to the sample sentence, and the semantic similarity between these substrings is calculated, which can help determine whether these substrings are semantically close enough and whether they should be regarded as independent entities. After analysis by this module, it is determined that the entity may be an entity composed of "XX City" and "Housing and Urban-Rural Construction Bureau". In the first-level model, "XX City Housing and Urban-Rural Construction Bureau" has been identified as an Org entity, and the context model analysis shows that there is a high possibility that there are fine-grained entities within this entity, so it is input into the second-level model.
[0088] It should be noted that the natural language processing tools preset in the present invention can all be implemented using the StanfordNLP toolkit, which can perform syntactic analysis and part-of-speech tagging on input sample sentences / coarse-grained entities.
[0089] Further, in an optional embodiment of the present invention, in step S16, the outer-layer entity is input into a preset inner-layer entity recognition model corresponding to the entity category to which the outer-layer entity belongs for learning and training, so as to obtain a second recognition result of the second-layer entity in the outer-layer entity, which specifically includes the following steps not shown in the accompanying drawings:
[0090] S161, the inner entity recognition model of each category includes a second BiGRU model and a second CRF model, and the second BiGRU model is used to extract deep features of the outer entity to obtain a third dynamic word vector that highlights the contextual semantic association information of the sample sentence;
[0091] S162, obtaining a preset entity nesting rule corresponding to the entity category to which the outer entity belongs, wherein the entity nesting rule uses a regular expression to represent the inner entity division mode of the corresponding entity category;
[0092] S163. Use the second CRF model to learn and train the third dynamic word vector and the entity nesting rule corresponding to the current outer entity to identify the second-layer entity in the outer entity and obtain a second recognition result of the second-layer entity in the outer entity.
[0093] In this embodiment, in the previous annotation and nesting summary, it can be found that among the preset 5 entity types, the Time entity type does not have a nested relationship, which means that the entity of this type will only be recognized in the first layer model and will not appear in the second layer model. In order to make the model learn the association between each type in the process of identifying nested entities, the second layer model adopts the idea of divide and conquer, and learns and processes different entity types respectively, that is, the inner layer entity recognition model consists of 4 models, including the inner layer entity recognition model corresponding to the place name entity category, namely the "Loc" model, the inner layer entity recognition model corresponding to the organization entity category, namely the "Org" model, the inner layer entity recognition model corresponding to the name entity category, namely the "Name" model, and the inner layer entity recognition model corresponding to the position entity category, namely the "Pos" model. For example, "XX City Housing and Urban-Rural Construction Bureau" is judged as the "Org" entity type by the first layer model and after judgment, it will be directly input into the "Org" model of the second layer. After receiving the entity passed in by the previous layer, continue to use BiGRU+CRF to learn it, and match the entity according to the pattern in the pattern library. The pattern library is a set of entity nesting rules summarized during the annotation work. The rules in the pattern library use regular expressions to represent the inner entity division pattern of the corresponding entity category to help the model better decompose the outer entity into fine-grained entities. For example, if "XX City Education Bureau" is identified as "Org", then in the second-level Org model, the entity will be pattern matched. According to the rules summarized in the early stage, there is only one nesting type of coarse-grained entity for the institutional entity, that is, "[Org]=[Loc] + [Org]". Then the rules can be used to identify whether "XX City Education Bureau" meets the entity division pattern of "[Org]=[Loc] + [Org]". If it meets the requirements, it will be disassembled into two entities according to the model learning situation.
[0094] Furthermore, after obtaining the second recognition result of the second-layer entity in the outer-layer entity, the method also includes: identifying the second-layer entity in which the inner-layer entity is nested from the second recognition result; if the second-layer entity in which the inner-layer entity is nested is identified, the second-layer entity is input into a preset inner-layer entity recognition model corresponding to the entity category to which the second-layer entity belongs for learning and training, obtaining a third recognition result of the third-layer entity in the second-layer entity, and continuing to recognize the next layer of entities in a recursive recognition manner until the entity recognition results of all layers in the sample sentence are obtained.
[0095] In the embodiment of the present invention, there may be third-layer or fourth-layer entities for the entities recognized by the second-layer model. Therefore, a recursive recognition method can be adopted to input the entities into the inner-layer entity recognition model corresponding to the second layer for further recognition based on the disassembly results and judgment results.
[0096] In the embodiment of the present invention, the loss of the model is mainly determined by the difference between the recognition results of the first and second layer models and the original labels, that is, the CRF loss of the first and second layer models. However, an additional part of the loss needs to be calculated, that is, the model correctly recognizes the outer layer entity, but judges it as a flat entity and does not input it into the next layer model for recognition, which will cause the entity that is a nested entity to be misjudged as a flat entity. Therefore, under the conditions of this model, the loss consists of three parts.
[0097] Specifically, the overall loss of the hierarchical cascade nested entity recognition model can be calculated as follows:
[0098] L = L 外层实体识别模型 + L 内层实体识别模型 + L 额外
[0099] Among them, L 外层实体识别模型 is the CRF loss of the outer entity recognition model, L 内层实体识别模型 is the CRF loss of the inner entity recognition model, L 额外 It is the recognition error loss when the outer entity recognition model correctly recognizes the outer entity but fails to recognize that the current outer entity is nested with an inner entity, and the recognition error loss when the inner entity recognition model correctly recognizes the inner entity but fails to recognize that the current inner entity is still nested with an inner entity.
[0100] Understandable, L 额外 This does not only include the recognition error loss of the outer entity recognition model, because the inner entity recognition model of the second layer may also have additional losses, failing to correctly recognize the entities of the third and fourth layers. Therefore, L in this embodiment 额外 In addition to the recognition error loss caused by the outer entity recognition model correctly recognizing the outer entity but failing to recognize that the current outer entity is nested with an inner entity, it also includes the recognition error loss caused by the inner entity recognition model correctly recognizing the inner entity but failing to recognize that the current inner entity is still nested with an inner entity during the recursive recognition process.
[0101] For the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0102] Figure 3 The structure block diagram of the hierarchical cascade nested entity recognition model of the embodiment of the present invention is schematically shown. Figure 3 The hierarchical cascade nested entity recognition model of the embodiment of the present invention specifically includes an entity labeling module 201, a sequence labeling module 202, a pre-training module 203, an outer entity recognition module 204, a context analysis module 205 and an inner entity recognition module 206, wherein:
[0103] An entity labeling module 201 is used to label sample sentences with hierarchical entities according to preset entity categories and nesting levels;
[0104] A sequence labeling module 202 is used to perform sequence labeling on each entity layer according to the BIESO labeling mode based on the hierarchical entity labeling results of the sample sentence;
[0105] A pre-training module 203 is used to input the sequence labeling results as sample input data into the ERNIE3.0 pre-training model for pre-training to obtain a dynamic word vector corresponding to the sample sentence;
[0106] The outer entity recognition module 204 is used to use a preset outer entity recognition model to learn and train the dynamic word vector to obtain a first recognition result of the outer entity in the sample sentence;
[0107] A context analysis module 205, configured to identify an outer entity having an inner entity nested therein from the first recognition result;
[0108] The inner entity recognition module 206 is used to input the outer entity into a preset inner entity recognition model corresponding to the entity category for learning and training according to the entity category to which the outer entity belongs, so as to obtain a second recognition result of the second layer entity in the outer entity.
[0109] In the embodiment of the present invention, the deepest nesting level of the predefined entity is 4 layers, and the entity categories include place name entity, organization entity, name entity, position entity and time entity;
[0110] Furthermore, the entity labeling module 201 is specifically used to perform hierarchical entity labeling on the place name entities, organization entities, name entities, position entities and / or time entities contained in each layer of the sample sentences from the inner layer to the outer layer according to the number of nesting layers corresponding to each sample sentence.
[0111] In the embodiment of the present invention, the outer entity recognition model includes a first BiGRU model and a first CRF model;
[0112] Furthermore, the outer entity recognition module 204 is specifically used to use the first BiGRU model to extract deep-level features of the dynamic word vector to obtain a second dynamic word vector that highlights the contextual semantic association information of the sample sentence; use a preset natural language processing toolkit to perform part-of-speech analysis and syntactic analysis on the sample sentence to determine the words contained in the sample sentence and the dependency relationship between the words; use the first CRF model to learn and train the second dynamic word vector and the words in the sample sentence and the dependency relationship between the words to identify the noun phrases in the sample sentence, and obtain a first recognition result of the outer entity in the sample sentence.
[0113] In the embodiment of the present invention, the context analysis module 205 is specifically used to use a preset natural language processing tool to perform part-of-speech analysis and syntactic analysis on the outer entity identified from the sample sentence to determine the words contained in the outer entity and the dependency relationship between the words; take each word contained in the outer entity as a substring, extract the word vector of each substring from the dynamic word vector corresponding to the sample sentence, and calculate the semantic similarity between the substrings; comprehensively judge whether there is an inner entity nested inside according to the semantic similarity between the substrings contained in the outer entity and the words contained in the outer entity and the dependency relationship between the words, wherein the semantic similarity calculation formula is:
[0114]
[0115] in, , Represent the word vectors of the two substrings respectively, Representing word vectors With word vector The dot product of ‖and‖ ‖ represents the modulus of the corresponding word vector.
[0116] In an embodiment of the present invention, the inner entity recognition model is composed of four models, including an inner entity recognition model corresponding to a place name entity category, an inner entity recognition model corresponding to an organization entity category, an inner entity recognition model corresponding to a name entity category, and an inner entity recognition model corresponding to a position entity category; the inner entity recognition model of each category includes a second BiGRU model and a second CRF model.
[0117] Furthermore, the inner entity recognition module 206 is specifically used to use the second BiGRU model to extract deep features of the outer entity to obtain a third dynamic word vector that highlights the contextual semantic association information of the sample sentence; obtain a preset entity nesting rule corresponding to the entity category to which the outer entity belongs, and the entity nesting rule uses a regular expression to represent the inner entity division pattern of the corresponding entity category; use the second CRF model to learn and train the third dynamic word vector and the entity nesting rule corresponding to the current outer entity to identify the second-layer entity in the outer entity, and obtain a second recognition result of the second-layer entity in the outer entity.
[0118] In an optional embodiment of the present invention, the context analysis module 205 is further configured to, after obtaining a second recognition result of a second-layer entity in an outer-layer entity, identify a second-layer entity in which an inner-layer entity is nested from the second recognition result.
[0119] Furthermore, the inner layer entity recognition module 206 is specifically used for inputting the second layer entity into a preset inner layer entity recognition model corresponding to the entity category to which the second layer entity belongs for learning and training if the context analysis module 205 recognizes that the second layer entity is nested with the inner layer entity, so as to obtain a third recognition result of the third layer entity in the second layer entity, and continue to perform the next layer entity recognition in a recursive recognition manner until the entity recognition results of all layers in the sample sentence are obtained.
[0120] The hierarchical cascade nested entity recognition model provided in this embodiment further includes an overall loss calculation module, which is used to calculate the overall loss of the hierarchical cascade nested entity recognition model in the following manner:
[0121] L = L 外层实体识别模型 + L 内层实体识别模型 + L 额外
[0122] Among them, L 外层实体识别模型 is the CRF loss of the outer entity recognition model, L 内层实体识别模型 is the CRF loss of the inner entity recognition model, L 额外 It is the recognition error loss when the outer entity recognition model correctly recognizes the outer entity but fails to recognize that the current outer entity is nested with an inner entity, and the recognition error loss when the inner entity recognition model correctly recognizes the inner entity but fails to recognize that the current inner entity is still nested with an inner entity.
[0123] Figure 4 The overall architecture diagram of the hierarchical cascade nested entity recognition model provided by the embodiment of the present invention is schematically shown. Figure 4The present invention inputs the labeled sample sentences into the ERNIE3.0 pre-training model, pre-trains the sequence labeling results through the ERNIE3.0 pre-training model to obtain the dynamic word vector of the sample sentence, uses the preset outer entity recognition model to learn and train the dynamic word vector to obtain the outer entity in the sample sentence, and recognizes the outer entity with the inner entity nested in each outer entity according to the context analysis module, and finally the inner entity recognition module inputs the outer entity into the inner entity recognition model corresponding to the entity category to which the outer entity belongs for learning and training to obtain the inner entity nested in the outer entity, and finally obtains the entity recognition result including the inner entity and the outer entity. The hierarchical cascade nested entity recognition model provided by the present invention can better decompose the outer entity in the sentence into fine-grained inner entities by utilizing the nested relationship and contextual connection between entities, and recognize the nested entities in the sentence in layers, which greatly improves the accuracy and efficiency of nested entity recognition.
[0124] Figure 5 The flowchart of a nested entity recognition method based on a hierarchical cascade nested entity recognition model according to an embodiment of the present invention is schematically shown. Figure 5 The nested entity recognition method based on the hierarchical cascade nested entity recognition model of the embodiment of the present invention specifically includes the following steps:
[0125] S21, input the sentence to be recognized as input data into the ERNIE3.0 pre-trained model for feature extraction to obtain the target dynamic word vector corresponding to the sentence to be recognized;
[0126] S22, using a pre-trained outer entity recognition model to perform outer entity recognition on the target dynamic word vector to obtain at least one target outer entity in the sentence to be recognized;
[0127] S23, identifying the outer-layer entities to be identified that have inner-layer entities nested therein from each target outer-layer entity;
[0128] S24. Input the outer-layer entity to be identified into a preset inner-layer entity recognition model corresponding to the entity category to perform inner-layer entity recognition according to the entity category to which the outer-layer entity to be identified belongs, and obtain at least one second-layer entity in the outer-layer entity to be identified.
[0129] Furthermore, after obtaining at least one second-layer entity in the outer-layer entities to be identified, the method further includes: identifying the second-layer entities to be identified in which the inner-layer entities are nested from the second-layer entities.
[0130] Furthermore, according to the entity category to which the second-layer entity to be identified belongs, the second-layer entity to be identified is input into a preset inner-layer entity recognition model corresponding to the entity category to perform inner-layer entity recognition, and at least one third-layer entity in the second-layer entity to be identified is obtained. In summary, the present invention adopts a recursive recognition method to continue to identify the next layer of entities until entity recognition results of all layers in the sample sentence are obtained.
[0131] The nested entity recognition method based on the hierarchical cascade nested entity recognition model provided in the embodiment of the present invention utilizes the nested relationship and contextual connection between entities, can better decompose the outer entities in the sentence into fine-grained inner entities, and recognize the nested entities in the sentence in a hierarchical manner, thereby greatly improving the accuracy and efficiency of nested entity recognition.
[0132] In addition, an embodiment of the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for constructing the above-mentioned hierarchical cascaded nested entity recognition model, and / or the steps of the nested entity recognition method based on the hierarchical cascaded nested entity recognition model.
[0133] In this embodiment, the method for constructing the hierarchical cascade nested entity recognition model or the nested entity recognition method based on the hierarchical cascade nested entity recognition model can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media does not include electrical carrier signals and telecommunication signals.
[0134] In addition, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method for constructing the hierarchical cascade nested entity recognition model and / or the steps of the nested entity recognition method based on the hierarchical cascade nested entity recognition model are implemented. Figure 1 Steps S11 to S16 shown, and / or Figure 5 Alternatively, when the processor executes the computer program, the functions of each module / unit in the hierarchical cascade nested entity recognition model embodiment are implemented, for example Figure 3 The illustrated modules include an entity tagging module 201 , a sequence tagging module 202 , a pre-training module 203 , an outer entity recognition module 204 , a context analysis module 205 , and an inner entity recognition module 206 .
[0135] The hierarchical cascade nested entity recognition model and its construction method and storage medium provided by the embodiment of the present invention perform hierarchical entity annotation on sample sentences according to preset entity categories and nested levels, and perform sequence annotation on each entity layer according to the BIESO annotation mode, and then pre-train the sequence annotation results through the ERNIE3.0 pre-training model to obtain the dynamic word vector of the sample sentence, and use the preset outer entity recognition model to learn and train the dynamic word vector to obtain the outer entity in the sample sentence, and identify the outer entity with the inner entity nested from each outer entity, and finally input the outer entity into the inner entity recognition model corresponding to the entity category to which the outer entity belongs for learning and training to obtain the inner entity nested in the outer entity. The present invention utilizes the nested relationship and contextual connection between entities, can better decompose the outer entity in the sentence into fine-grained inner entities, and hierarchically recognize the nested entities in the sentence, which greatly improves the accuracy and efficiency of nested entity recognition.
[0136] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0137] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, any one of the claimed embodiments may be used in any combination.
[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for constructing a hierarchical cascade nested entity recognition model, characterized in that: The method comprises: Perform hierarchical entity annotation on sample sentences according to preset entity categories and nesting levels; The hierarchical entity annotation results of the sample sentences are sequence-annotated for each entity layer according to the BIESO annotation mode; The sequence labeling results are used as sample input data to input into the ERNIE3.0 pre-training model for pre-training to obtain the dynamic word vector corresponding to the sample sentence; The dynamic word vector is trained by using a preset outer entity recognition model to obtain a first recognition result of an outer entity in a sample sentence, including: the outer entity recognition model includes a first BiGRU model and a first CRF model, and the first BiGRU model is used to extract deep features of the dynamic word vector to obtain a second dynamic word vector that highlights the contextual semantic association information of the sample sentence; the sample sentence is analyzed for part of speech and syntax using a preset natural language processing toolkit to determine the words contained in the sample sentence and the dependency relationship between the words; the second dynamic word vector and the words in the sample sentence and the dependency relationship between the words are trained by using the first CRF model to identify the noun phrases in the sample sentence, and obtain a first recognition result of the outer entity in the sample sentence; Identifying an outer entity in which an inner entity is nested from the first recognition result includes: using a preset natural language processing tool to perform part-of-speech analysis and syntactic analysis on the outer entity identified from the sample sentence to determine the words contained in the outer entity and the dependency relationship between the words; taking each word contained in the outer entity as a substring, extracting the word vector of each substring from the dynamic word vector corresponding to the sample sentence, and calculating the semantic similarity between the substrings, the semantic similarity calculation formula is: in, , Represent the word vectors of the two substrings respectively, Representing word vectors With word vector The dot product of ‖and‖ ‖ represents the modulus of the corresponding word vector; based on the semantic similarity between the substrings contained in the outer entity and the words contained in the outer entity and the dependency relationship between the words, it is comprehensively judged whether there is an inner entity nested inside; According to the entity category to which the outer entity belongs, the outer entity is input into a preset inner entity recognition model corresponding to the entity category to be learned and trained, and a second recognition result of the second layer entity in the outer entity is obtained, including: the inner entity recognition model is composed of 4 models, including an inner entity recognition model corresponding to the place name entity category, an inner entity recognition model corresponding to the organization entity category, an inner entity recognition model corresponding to the name entity category, and an inner entity recognition model corresponding to the position entity category; the inner entity recognition model of each category includes a second BiGRU model and a second CRF model, and the second BiGRU model is used to extract deep features of the outer entity to obtain a third dynamic word vector that highlights the contextual semantic association information of the sample sentence; a preset entity nesting rule corresponding to the entity category to which the outer entity belongs is obtained, and the entity nesting rule uses a regular expression to represent the inner entity division mode of the corresponding entity category; the second CRF model is used to learn and train the third dynamic word vector and the entity nesting rule corresponding to the current outer entity to identify the second layer entity in the outer entity, and obtain the second recognition result of the second layer entity in the outer entity.
2. The method according to claim 1, characterized in that After obtaining a second recognition result of the second layer entity in the outer layer entity, the method further includes: Identify, from the second recognition result, a second-level entity in which an inner-level entity is nested; If a second-layer entity is identified that is nested with an inner-layer entity, the second-layer entity is input into a preset inner-layer entity recognition model corresponding to the entity category to which it belongs for learning and training, and a third recognition result of the third-layer entity in the second-layer entity is obtained. A recursive recognition method is then adopted to continue the recognition of the next layer of entities until the entity recognition results of all layers in the sample sentence are obtained.
3. The method according to claim 1, characterized in that The step of performing hierarchical entity labeling on the sample sentences according to the preset entity categories and nesting levels includes: The deepest nesting level of predefined entities is 4, and entity categories include place name entity, organization entity, name entity, position entity and time entity; According to the number of nested layers corresponding to each sample sentence, hierarchical entity annotation is performed on the place name entity, organization entity, name entity, position entity and / or time entity contained in each layer of the sample sentence from the inner layer to the outer layer.
4. The method according to claim 1, characterized in that: The method further comprises: The overall loss of the hierarchical cascaded nested entity recognition model is calculated as follows: L= L 外层实体识别模型 + L 内层实体识别模型 + L 额外 Among them, L 外层实体识别模型 is the CRF loss of the outer entity recognition model, L 内层实体识别模型 is the CRF loss of the inner entity recognition model, L 额外 It is the recognition error loss when the outer entity recognition model correctly recognizes the outer entity but fails to recognize that the current outer entity is nested with an inner entity, and the recognition error loss when the inner entity recognition model correctly recognizes the inner entity but fails to recognize that the current inner entity is still nested with an inner entity.
5. A hierarchical cascade nested entity recognition model, characterized in that: The model includes: An entity annotation module is used to perform hierarchical entity annotation on sample sentences according to preset entity categories and nesting levels; The sequence labeling module is used to label each entity layer in sequence according to the BIESO labeling mode based on the hierarchical entity labeling results of the sample sentence; The pre-training module is used to input the sequence labeling results as sample input data into the ERNIE3.0 pre-training model for pre-training to obtain the dynamic word vector corresponding to the sample sentence; The outer entity recognition module is used to learn and train the dynamic word vector using a preset outer entity recognition model to obtain a first recognition result of the outer entity in the sample sentence; the outer entity recognition model includes a first BiGRU model and a first CRF model; the outer entity recognition module is specifically used to extract deep-level features of the dynamic word vector using the first BiGRU model to obtain a second dynamic word vector that highlights the contextual semantic association information of the sample sentence; Use a preset natural language processing toolkit to perform part-of-speech analysis and syntactic analysis on the sample sentences to determine the words contained in the sample sentences and the dependency relationships between the words; The first CRF model is used to learn and train the second dynamic word vector and the words in the sample sentence and the dependency relationship between the words to identify the noun phrases in the sample sentence and obtain the first recognition result of the outer entity in the sample sentence; The context analysis module is used to identify the outer entity in which the inner entity is nested from the first recognition result; the context analysis module is specifically used to use a preset natural language processing tool to perform part-of-speech analysis and syntactic analysis on the outer entity identified from the sample sentence to determine the words contained in the outer entity and the dependency relationship between the words; each word contained in the outer entity is taken as a substring, the word vector of each substring is extracted from the dynamic word vector corresponding to the sample sentence, and the semantic similarity between the substrings is calculated; based on the semantic similarity between the substrings contained in the outer entity and the words contained in the outer entity and the dependency relationship between the words, it is comprehensively judged whether the inner entity is nested inside, wherein the semantic similarity calculation formula is: in, , Represent the word vectors of the two substrings respectively, Representing word vectors With word vector The dot product of ‖and‖ ‖ represents the modulus of the corresponding word vector; The inner entity recognition module is used to input the outer entity into a preset inner entity recognition model corresponding to the entity category to which the outer entity belongs for learning and training, so as to obtain a second recognition result of the second entity in the outer entity; the inner entity recognition model is composed of 4 models, including an inner entity recognition model corresponding to the place name entity category, an inner entity recognition model corresponding to the organization entity category, an inner entity recognition model corresponding to the name entity category, and an inner entity recognition model corresponding to the position entity category; the inner entity recognition model of each category includes a second BiGRU model and a second CRF model; the inner entity recognition module is specifically used to use the second BiGRU model to extract deep-level features of the outer entity to obtain a third dynamic word vector that highlights the contextual semantic association information of the sample sentence; obtain a preset entity nesting rule corresponding to the entity category to which the outer entity belongs, and the entity nesting rule uses a regular expression to represent the inner entity division mode of the corresponding entity category; use the second CRF model to learn and train the third dynamic word vector and the entity nesting rule corresponding to the current outer entity to identify the second entity in the outer entity, so as to obtain a second recognition result of the second entity in the outer entity.
6. A nested entity recognition method based on the hierarchical cascade nested entity recognition model of claim 5, characterized in that: The method comprises: The sentence to be recognized is used as input data into the ERNIE3.0 pre-trained model for feature extraction to obtain the target dynamic word vector corresponding to the sentence to be recognized; Using a pre-trained outer entity recognition model to perform outer entity recognition on the target dynamic word vector to obtain at least one target outer entity in the sentence to be recognized; Identify the outer-layer entities to be identified that have inner-layer entities nested in them from each target outer-layer entity; According to the entity category to which the outer-layer entity to be identified belongs, the outer-layer entity to be identified is input into a preset inner-layer entity recognition model corresponding to the entity category to perform inner-layer entity recognition, and at least one second-layer entity in the outer-layer entity to be identified is obtained.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 or the steps of the method according to claim 6 are implemented.
