Named entity recognition method and device
By using a neural network model to filter word segmentation and word vectors in the named entity recognition method, and combining global information to discover new words, the problem of insufficient new word discovery ability in the existing technology is solved, and more accurate naming entity recognition is achieved.
Patent Information
- Application Number
- CN202111649563.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2041-12-29
AI Technical Summary
The existing named entity recognition methods fail to effectively utilize the ability to discover new words, resulting in insufficient ability to identify new named entities in the corpus, which in turn affects the accuracy of named entity recognition.
The first neural network model is used to perform word segmentation processing on the target statement, obtain the word vector set, and obtain the candidate word vector set through context information filtering, and then add it to the target dictionary, and recognise word segmentation and named entity again, using the second nerve The network model recognizes the identification results by naming entities.
By considering the global information of words in the entire corpus, the ability to discover new words is improved, thereby improving the accuracy of naming entity recognition and solving the problem of inaccurate naming entity recognition.
Smart Images

Figure CN114298048B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of language processing, and more specifically, to a method and device for named entity recognition. Background Art
[0002] Named Entity Recognition (NER) is a very basic task in NLP (Neuro Linguistic Programming), which refers to identifying named referents from text, paving the way for tasks such as relationship extraction. In the field of named entity recognition, a compromise method is to perform sequence annotation based on the character level and integrate word information into the character sequence. The problem with this method is that although it considers the local information of the word set, it does not consider the global information of the word in the entire corpus, and the ability to discover new words is not reflected in the recognition process of word fusion, resulting in the inability to recognize new named entities.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a method and apparatus for named entity recognition, so as to at least solve the technical problem of inaccurate named entity recognition caused by failure to utilize new word discovery capabilities.
[0005] According to one aspect of an embodiment of the present application, a method for named entity recognition is provided, including: using a first neural network model to perform word segmentation on a target sentence to obtain a first word vector set; filtering words in the first word vector set based on context information of any word vector in the first word vector set to obtain a candidate word vector set; adding the candidate word vector set to a target dictionary; performing word segmentation on the target sentence based on the target dictionary to obtain a second word vector set; and using a second neural network model to recognize named entities in the second word vector set to obtain a recognition result.
[0006] Optionally, the method also includes: after segmenting the target sentence based on the target dictionary, obtaining a first word vector set; using a second neural network model to recognize named entities in the second word vector set to obtain a recognition result, including: obtaining the weight of any word vector in the second word vector set and any word vector in the first word vector set in the target corpus; performing named entity recognition on the target sentence based on the weight.
[0007] Optionally, the words in the first word vector set are filtered based on the context information of any one word vector in the first word vector set to obtain a candidate word vector set, including: calculating the mutual information and information entropy between each word in the first word vector set; filtering the words in the first word vector set based at least on the mutual information and information entropy to obtain a candidate word vector set.
[0008] Optionally, before using the first neural network model to perform word segmentation on the target sentence and obtaining the first word vector set, the method also includes: receiving an input instruction of the target object and determining the character length in the input instruction, wherein the character length is the length of the byte fragment sequence based on which the target sentence is segmented.
[0009] Optionally, before using the first neural network model to perform word segmentation processing on the target sentence to obtain the first word vector set, the method also includes: detecting the voice instructions of the target object; recognizing the voice instructions to obtain text information corresponding to the voice instructions, and using the text information as the target sentence.
[0010] Optionally, after a second neural network model is used to identify named entities in a second word vector set and a recognition result is obtained, the method further includes: determining response information corresponding to the recognition result and outputting the response information.
[0011] According to another aspect of an embodiment of the present application, a named entity recognition device is also provided, including: an acquisition module, used to use a first neural network model to perform word segmentation processing on a target sentence to obtain a first word vector set; a screening module, used to filter words in the first word vector set from the context information of any word vector in the first word vector set to obtain a candidate word vector set; an adding module, used to add the candidate word vector set to a target dictionary; a word segmentation module, used to perform word segmentation on the target sentence based on the target dictionary to obtain a second word vector set; and a recognition module, used to use a second neural network model to recognize named entities in the second word vector set to obtain a recognition result.
[0012] Optionally, the device also includes: a word vector module, which is used to obtain a first word vector set after segmenting the target sentence based on the target dictionary; a recognition submodule, which is used to obtain the weight of any word vector in the second word vector set and any word vector in the first word vector set in the target corpus; and perform named entity recognition on the target sentence based on the weight.
[0013] According to another aspect of the embodiments of the present application, a non-volatile storage medium is provided, the non-volatile storage medium including a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the above-mentioned named entity recognition method.
[0014] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including: a memory and a processor; the processor is used to run a program, wherein the above-mentioned named entity recognition method is executed when the program is running.
[0015] In the embodiment of the present application, a first neural network model is used to segment the target sentence to obtain a first word vector set; the words in the first word vector set are filtered from the context information of any word vector in the first word vector set to obtain a candidate word vector set; the candidate word vector set is added to the target dictionary; the target sentence is segmented based on the target dictionary to obtain a second word vector set; the named entities in the second word vector set are recognized using a second neural network model to obtain a recognition result. In this way, the target sentence is segmented by the neural network model to obtain a word vector set and filtered to obtain a candidate word vector, and then the candidate word vector is added to the target dictionary to segment the target sentence, and finally the neural network model recognizes the word vector set to achieve the global information of the target word in the entire corpus, thereby utilizing the new word discovery capability, thereby achieving the technical effect of improving the accuracy of named entity recognition, and further solving the technical problem of inaccurate named entity recognition caused by not utilizing the new word discovery capability. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 is a schematic diagram of an optional named entity recognition method according to an embodiment of the present application;
[0018] Figure 2 is a schematic diagram of an optional process of discovering new words according to an embodiment of the present application;
[0019] Figure 3 is a schematic diagram of another optional named entity recognition method according to an embodiment of the present application;
[0020] Figure 4 is a schematic diagram of an optional named entity recognition device according to an embodiment of the present application DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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 ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] According to an embodiment of the present application, a method embodiment of named entity recognition is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0024] Figure 1 is a method for named entity recognition according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0025] Step S102, using a first neural network model to perform word segmentation on the target sentence to obtain a first word vector set;
[0026] Step S104, filtering the words in the first word vector set based on the context information of any word vector in the first word vector set to obtain a candidate word vector set;
[0027] Step S106, adding the candidate word vector set to the target dictionary;
[0028] Step S108, segmenting the target sentence based on the target dictionary to obtain a second word vector set;
[0029] Step S110: Use a second neural network model to recognize named entities in the second word vector set to obtain a recognition result.
[0030] Take the first neural network model as BILSTM+CRF model (named entity overall logical framework) model. For example, Figure 2 As shown, through the data initiation process in four directions, the BILSTM+CRF model is used to perform Chinese word segmentation and new word discovery, the results of new word discovery are added to the target dictionary, and then the word vectors and character vectors are extracted to form a second word vector set. The second neural network model is used to recognize the named entities in the second word vector set to obtain the recognition results.
[0031] It should be noted that the second neural network model has the same structure as the first neural network model, and both can use the BILSTM+CRF model. The difference is that the second neural network model is used for named entity recognition, while the first neural network model is only used for word segmentation. At the same time, the training samples of the first neural network model are corpus samples, such as corpus samples obtained by splitting documents based on paragraph markers, article end markers, and sentence end markers, and then manually segmenting and part-of-speech tagging the corpus samples to obtain training samples; while the training samples of the second neural network model are named entity samples, such as: entity class, time class, number class; text information such as names of people, places, institutions, time, date, and currency.
[0032] Named Entity Recognition (NER), also known as "proper name recognition", refers to the recognition of entities with specific meanings in text, mainly including names of people, places, institutions, proper nouns, etc. Chinese text does not have explicit word boundary markers like spaces in English text. Determining word boundaries is called word segmentation, and determining character boundaries is called character segmentation.
[0033] Through the above steps, it is possible to segment the target sentence through the neural network model to obtain a word vector set and filter to obtain candidate word vectors, and then add the candidate word vectors to the target dictionary to segment the target sentence. Finally, the neural network model recognizes the word vector set to achieve the global information purpose of the target words and sentences in the entire corpus, thereby achieving the technical effect of improving the accuracy of named entity recognition, and further solving the technical problem of inaccurate named entity recognition caused by not considering the global information of words and sentences in the entire corpus.
[0034] In some embodiments of the present application, a target sentence is segmented based on a target dictionary to obtain a first word vector set; a second neural network model is used to recognize named entities in the second word vector set to obtain a recognition result, including: obtaining the weights of any word vector in the second word vector set and any word vector in the first word vector set in the target corpus; and performing named entity recognition on the target sentence based on the weights.
[0035] When considering word weights, the global weight of the word in the entire corpus is taken into account. Second, BILSTM+CRF is used for new word discovery. This new word discovery method does not rely on the rule base, and because N can be set, it is not limited to the discovery of shorter words. The two are combined for named entity recognition.
[0036] The word vector is extracted using the BILSTM+CRF model. In order to take into account the global weight of the word in the entire corpus, the TF-IDF (Term Frequency-inverse Document Frequency) algorithm is used, a statistical analysis method for keywords, which is used to evaluate the importance of a word to a document set or a corpus. The importance of a word is proportional to the number of times it appears in the article and inversely proportional to the number of times it appears in the corpus. This calculation method can effectively avoid the influence of common words on keywords and improve the relevance between keywords and articles. The calculated weight of the word in the entire corpus is recorded as W i , introduce the word weight into the word fusion encoding strategy. The specific formula is as follows: in, h i =o i ⊙tanh(c i ), where i represents input, f{is the forget gate, o represents output, σ represents the sigmoid function, h represents the hidden layer, and W P and b p represents the model parameters, W i Represents the word weight.
[0037] In some embodiments of the present application, the words in the first word vector set are filtered based on the context information of any one word vector in the first word vector set to obtain a candidate word vector set, including: calculating the mutual information and information entropy between each word in the first word vector set; filtering the words in the first word vector set based at least on the mutual information and information entropy to obtain a candidate word vector set.
[0038] It should be noted that the words in the first word vector set are filtered based on mutual information and information entropy. Specifically, the corpus text needs to be converted into a string, and then a dictionary is generated for N-gram (a commonly used language model), and the word frequency is counted. The point-to-point mutual information is used to filter out candidate word vectors from the previous N-gram dictionary. The final output candidate word vector set is then filtered out from the candidate new words through left and right entropy. Mutual information represents the connection between information, and information entropy is used to quantify information.
[0039] Specifically, in a specific embodiment, Figure 3As shown in the figure, the process of discovering the candidate word vector set combines the recurrent neural network and the segmentation probability model of the conditional random scene to segment the sentences of the test set documents, generate a sequence of segmentation probabilities, use the filtering rules combined with the segmentation probabilities to filter out noise words, obtain the candidate word vector set, and finally add the candidate word vector set to the target dictionary.
[0040] The original corpus is segmented, and the N-gram method is used to scan the string. The choice of N can be set manually, and then the mutual information, left information entropy, and right information entropy of each word are calculated. After manual filtering, candidate new words are obtained. Then the data of word vectors are trained, the original corpus is segmented, and the first word vector obtained by the word segmentation result in the previous step is used to automatically annotate the corpus after word segmentation. The annotated data is trained on BILSTM+CRF to obtain candidate word vectors.
[0041] It should be noted that when N-gram is applied to Chinese, it can use the collocation information between adjacent words in the context to achieve automatic conversion to Chinese characters. The segmentation probability model of the conditional random scenario includes but is not limited to the Markov model.
[0042] In some embodiments of the present application, before the first neural network model is used to perform word segmentation on the target sentence and the first word vector set is obtained, the method further includes: receiving an input instruction of the target object and determining the character length in the input instruction, wherein the character length is the length of the byte fragment sequence based on which the target sentence is segmented. Specifically, as described above, the N-gram (a commonly used language model) method is used to scan the character string corresponding to the original corpus (i.e., the target sentence mentioned above) to perform word segmentation on the original corpus, and the sequence length N of the word segmentation can be manually set according to actual needs.
[0043] In some embodiments of the present application, before using the first neural network model to perform word segmentation processing on the target sentence to obtain the first word vector set, the method also includes: detecting the voice instructions of the target object; recognizing the voice instructions to obtain text information corresponding to the voice instructions, and using the text information as the target sentence.
[0044] For example, in an intelligent data question-and-answer platform, when a user's voice query occurs, the voice will be recognized as natural language, and then the named entity recognition method provided in this application will be used for named entity recognition.
[0045] In some embodiments of the present application, a first neural network model is used to recognize named entities in a second word vector set. After obtaining a recognition result, the method further includes: determining response information corresponding to the recognition result, and outputting the response information.
[0046] According to another aspect of the embodiment of the present application, a named entity recognition device is also provided. Figure 4 As shown, it includes: an acquisition module 40, which is used to use the first neural network model to perform word segmentation on the target sentence to obtain a first word vector set; a screening module 42, which is used to filter the words in the first word vector set from the context information of any word vector in the first word vector set to obtain a candidate word vector set; an adding module 44, which is used to add the candidate word vector set to the target dictionary; a word segmentation module 46, which is used to perform word segmentation on the target sentence based on the target dictionary to obtain a second word vector set; a recognition module 48, which is used to use the first neural network model to recognize the named entities in the second word vector set to obtain a recognition result.
[0047] The named entity recognition device also includes: a word vector submodule, which is used to obtain a first word vector set after segmenting the target sentence based on the target dictionary; a recognition submodule, which is used to obtain the weight of any word vector in the second word vector set and any word vector in the first word vector set in the target corpus; and perform named entity recognition on the target sentence based on the weight.
[0048] The screening module 42 includes: a calculation submodule and a filtering submodule; wherein the calculation submodule is used to calculate the mutual information and information entropy between each word in the first word vector set; the filtering submodule is used to filter the words in the first word vector set based at least on the mutual information and information entropy to obtain a candidate word vector set.
[0049] The word vector submodule includes: a receiving unit and a detection unit; wherein the receiving unit is used to receive the input instruction of the target object and determine the character length in the input instruction, wherein the character length is the length of the byte fragment sequence based on which the target sentence is segmented; the detection unit is used to detect the voice instruction of the target object; recognize the voice instruction, obtain text information corresponding to the voice instruction, and use the text information as the target sentence.
[0050] The recognition module includes: a feedback submodule, wherein the feedback submodule is used to determine response information corresponding to the recognition result and output the response information.
[0051] According to another aspect of the embodiments of the present application, a non-volatile storage medium is provided, the non-volatile storage medium including a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the above-mentioned named entity recognition method.
[0052] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including: a memory and a processor; the processor is used to run a program, wherein the above-mentioned named entity recognition method is executed when the program is running.
[0053] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0054] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0055] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0056] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0057] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0058] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0059] The above are only preferred implementations of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for named entity recognition, characterized in that: include: Using a first neural network model to perform word segmentation on the target sentence to obtain a first word vector set, where the first neural network model is a BILSTM+CRF model; Filter the words in the first word vector set based on the context information of any word vector in the first word vector set to obtain a candidate word vector set; Adding the candidate word vector set to the target dictionary as a new word discovery result; Segmenting the target sentence based on the target dictionary to obtain a second word vector set; Using a second neural network model to recognize the named entities in the second word vector set to obtain a recognition result; The method further includes: performing word segmentation processing on the target sentence based on the target dictionary to obtain a first word vector set; The second neural network model is used to identify the named entities in the second word vector set to obtain a recognition result, including: obtaining the weights of any word vector in the second word vector set and any word vector in the first word vector set in the target corpus; and performing named entity recognition on the target sentence based on the weights.
2. The method according to claim 1, characterized in that Filtering the words in the first word vector set based on the context information of any word vector in the first word vector set to obtain a candidate word vector set, including: Calculate the mutual information and information entropy between each word in the first word vector set; The words in the first word vector set are filtered based at least on the mutual information and the information entropy to obtain the candidate word vector set.
3. The method according to claim 1, characterized in that Before performing word segmentation processing on the target sentence using the first neural network model to obtain the first word vector set, the method further includes: An input instruction of a target object is received, and a character length in the input instruction is determined, wherein the character length is a length of a byte segment sequence based on which word segmentation processing is performed on the target sentence.
4. The method according to claim 1, characterized in that: Before performing word segmentation processing on the target sentence using the first neural network model to obtain the first word vector set, the method further includes: Detecting the target object’s voice command; The voice instruction is recognized to obtain text information corresponding to the voice instruction, and the text information is used as the target sentence.
5. The method according to claim 4, characterized in that After the second neural network model is used to identify the named entities in the second word vector set and the identification result is obtained, the method further includes: Response information corresponding to the recognition result is determined, and the response information is output.
6. A named entity recognition device, characterized in that: include: An acquisition module is used to perform word segmentation processing on the target sentence using a first neural network model to obtain a first word vector set, where the first neural network model is a BILSTM+CRF model; A screening module, configured to filter the words in the first word vector set based on the context information of any word vector in the first word vector set to obtain a candidate word vector set; An adding module, used for adding the candidate word vector set as a new word discovery result to a target dictionary; A word segmentation module, used to segment the target sentence based on the target dictionary to obtain a second word vector set; A recognition module, used to recognize the named entities in the second word vector set using a second neural network model to obtain a recognition result; The device also includes: A word vector submodule, configured to perform word segmentation processing on the target sentence based on the target dictionary to obtain a first word vector set; A recognition submodule is used to obtain the weight of any word vector in the second word vector set and any word vector in the first word vector set in the target corpus; and perform named entity recognition on the target sentence based on the weight.
7. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein when the program is executed, the device where the non-volatile storage medium is located is controlled to execute the named entity recognition method according to any one of claims 1 to 5.
8. An electronic device, characterized in that: include: Memory and processor; The processor is used to run a program, wherein the program executes the named entity recognition method according to any one of claims 1 to 5 when running.
Citation Information
Patent Citations
Chinese word segmentation method and device
CN109684645A
Chinese entity identification method based on BERT and Word2Vec vector fusion
CN112632997A