Named entity recognition method based on context learning
By constructing entity definition templates for domain knowledge and thinking chain technology, combined with the few-sample learning example of K closest algorithm, the insufficient performance of large language models in named entity recognition is solved, and more efficient extraction performance and domain adaptability are achieved.
Patent Information
- Application Number
- CN202411843634.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-11-21
- Filing Date
- 2024-12-14
- Publication Date
- 2025-03-28
AI Technical Summary
Existing named entity recognition methods are difficult to quickly adapt to new fields, and methods based on large language models ignore task differences, resulting in poor performance.
By constructing entity definitions based on domain knowledge, using thinking chain technology to build entity extraction templates, and combining K nearest algorithm to build examples of learning with few samples, naming entity recognition training based on large language models is performed.
It effectively improves the extraction performance of large language models, improves the universality of the methods, and can quickly adapt to named entity recognition tasks in different fields.
Smart Images

Figure CN119721040A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a named entity recognition method based on context learning. Background Art
[0002] Named entity recognition is often an important component in text processing workflows for information extraction and semantic understanding. The applicability of these methods to many real-world problems is hampered by their reliance on fixed entity definitions and large amounts of in-domain training data, which are specific to specific named entity methods and relevant populations. Unfortunately, the rules about what constitutes a relevant entity vary widely across use cases, a fact reflected in the diversity of academic datasets. Ultimately, these different rules stem from the differences in the envisioned use cases. For example, should we classify "general relativity" as an entity? A media company tasked with extracting information from political articles might not specify laws of physics as a relevant entity class, but a scientific journal might. Given the diversity of use cases, we cannot expect a universal named entity recognition system. However, we may hope to make named entity recognition systems that are flexible and can adapt to new contexts with minimal human effort.
[0003] Another way to effectively complete the named entity recognition task in a new domain and environment is to collect domain corpus, annotate data, build models, and train models. This is a named entity recognition method based on supervised learning. The disadvantage of this type of method is that it requires a large amount of training corpus, which is often difficult to obtain in some environments. At the same time, data labeling of a large amount of corpus is a labor-intensive task that consumes a lot of time and requires the support of domain experts.
[0004] Large language models have shown impressive contextual learning capabilities: with just a few task-specific examples as demonstrations, large language models are able to generate results for new test inputs. Under the framework of contextual learning, large language models have achieved promising results in various natural language processing tasks including machine translation and question answering.
[0005] However, the performance of large language models on named entity recognition tasks is still much lower than that of supervised learning models. This is because there is an inherent gap between the two tasks: named entity recognition is essentially a sequence labeling task, in which the model needs to assign entity type labels to each token in the sentence, while large language models are considered to be completed text generation tasks, and there is an essential difference between these two tasks. Therefore, when applying large language models to solve named entity recognition tasks, the gap between semantic labeling tasks and text generation models leads to poor performance.
[0006] According to the existing research situation, the current named entity recognition methods have the following problems:
[0007] 1. Current methods cannot adapt to new domains quickly, either because of the different domain knowledge about entities in each domain or because of labor-intensive data processing;
[0008] 2. The current named entity method based on large language models ignores the essential difference between the tasks performed by large models and named entity recognition tasks, resulting in performance loss. Summary of the invention
[0009] The purpose of the present invention is to provide a named entity recognition method based on context learning to address the technical problems pointed out in the above-mentioned prior art, which can effectively improve the extraction performance of large language models.
[0010] To achieve the above object, the present invention provides a method for named entity recognition based on context learning, which comprises the following steps:
[0011] S1: Construct entity definitions based on domain knowledge;
[0012] S2: Construct entity extraction template based on thought chain technology;
[0013] S3: Named Entity Recognition Based on Large Language Model;
[0014] S4: Self-verification of entity extraction results based on large language models.
[0015] The definition of entities is constructed based on domain knowledge. It is characterized by constructing a definition for the entities to be extracted based on domain knowledge, so that the large language model can understand the entities to be extracted. The definition module consists of natural language descriptions that constitute and do not constitute entities. For different entity categories in the domain, appropriate entity definitions are constructed.
[0016] The entity extraction template is constructed based on the thought chain technology, which is characterized by comprising the following steps:
[0017] S21: Entity extraction task description: This part needs to tell the large language model the specific tasks to be completed and the content that needs to be paid attention to;
[0018] S22: For each input of each entity category in the training data, reconstruct the output example using the thought chain-based technique;
[0019] S23: Example of constructing few-shot learning based on the K nearest neighbor algorithm.
[0020] Constructing output examples based on the thought chain technology is characterized in that, for the training input examples, output examples need to be constructed. First, the entity boundary needs to be determined according to the entity category, then it is determined whether it is an entity, and finally the reason for it is or is not given. Such output examples can simulate the reasoning path of the large language model to recognize entities.
[0021] An example of constructing a few-shot learning based on a K nearest neighbor algorithm, characterized in that it includes the following steps:
[0022] S231: extracting entities from the data in the training set based on the fine-tuned named entity recognition tool, representing them in vector form, and storing them in the database;
[0023] S232: For a given input sequence, the K nearest neighbor algorithm is used to select the semantically closest candidate entities in the database, that is, firstly, the same fine-tuned named entity recognition tool is used to perform entity recognition on the input sequence, and then all the extracted N candidate entities are iterated to find the K nearest neighbor values of each candidate entity from the database, thereby obtaining K×N retrieval entities.
[0024] S233: Select the top k entities from the K×N retrieved entities and use their related sentences as examples.
[0025] The method as claimed in claim 1, the named entity recognition based on the large language model is characterized in that, for each input sentence, examples with similar semantics are selected from the database using the K nearest neighbor algorithm, and the entity definition and the example are combined into the final few-sample learning example, which is input into the large prediction model for entity recognition.
[0026] The entity extraction result based on the large language model is self-verified, which is characterized by the fact that the large oracle model has a hallucination problem, and even if there are input and output examples, recognition errors may occur, including the following steps:
[0027] S41: Entity extraction result self-verification task description: This part needs to tell the large language model what task needs to be completed;
[0028] S42: Example selection based on K nearest neighbor algorithm: First, entity-level representations of all training data are extracted based on the fine-tuned named entity recognition model. Secondly, the same named entity recognition model is used to encode the entities that have been extracted in the query statement. Finally, k examples are selected from the data store as few-shot demonstrations using the representation of the query term. If the retrieved entity belongs to the queried entity type, the answer is "yes", otherwise it is no.
[0029] Compared with the prior art, the context-based learning named entity recognition method provided by the present invention has the following beneficial effects:
[0030] 1) The present invention constructs an entity extraction template based on the thinking chain technology, and constructs an instance of few-sample learning based on the K nearest neighbor algorithm, and then performs named entity recognition training based on a large language model, thereby effectively improving the extraction performance of the large language model;
[0031] 2) The present invention can be applied to different fields, thus improving its universality. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 Flowchart of the named entity recognition method based on context learning;
[0033] Figure 2 A flowchart showing an example of building a few-shot learning algorithm based on the K-nearest neighbor algorithm. DETAILED DESCRIPTION
[0034] The following will clearly and completely describe the technical solutions of various embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0035] like Figure 1 As shown, the present invention provides a method for named entity recognition based on context learning, comprising the following steps:
[0036] S1: Construct entity definitions based on domain knowledge;
[0037] S2: Construct entity extraction template based on thought chain technology;
[0038] S3: Named Entity Recognition Based on Large Language Model;
[0039] S4: Self-verification of entity extraction results based on large language models.
[0040] In step S1, a definition is constructed for the entity to be extracted based on the domain knowledge, so that the large language model can understand the entity to be extracted. The definition module consists of natural language descriptions that constitute and do not constitute entities. For different entity categories in the field, appropriate entity definitions are constructed.
[0041] Step S2 includes the following steps:
[0042] S21: Entity extraction task description: This part needs to tell the large language model the specific tasks to be completed and the content that needs to be paid attention to;
[0043] S22: For each input of each entity category in the training data, reconstruct the output example using the thought chain-based technique;
[0044] S23: Example of constructing few-shot learning based on the K nearest neighbor algorithm.
[0045] In step S22, for the training input examples, output examples need to be constructed. First, the entity boundary needs to be determined according to the entity category, then it is determined whether it is an entity, and finally the reason for it is or is not given. Such output examples can simulate the reasoning path of the large language model to recognize entities.
[0046] In step S23, an example of few-sample learning is constructed based on the K nearest neighbor algorithm, such as Figure 2 As shown, the following steps are included:
[0047] S231: extracting entities from the data in the training set based on the fine-tuned named entity recognition tool, representing them in vector form, and storing them in the database;
[0048] S232: For a given input sequence, the K nearest neighbor algorithm is used to select the semantically closest candidate entities in the database, that is, firstly, the same fine-tuned named entity recognition tool is used to perform entity recognition on the input sequence, and then all the extracted N candidate entities are iterated to find the K nearest neighbor values of each candidate entity from the database, thereby obtaining K×N retrieval entities.
[0049] S233: Select the top k entities from the K × N retrieved entities and use their related sentences as examples.
[0050] In step S23, named entity recognition is performed based on a large language model. For each input sentence, examples with similar semantics are selected from the database using the K nearest neighbor algorithm. The entity definition and examples are combined into the final few-sample learning example, which is input into the large prediction model for entity recognition.
[0051] In step S4, the large prediction model has a hallucination problem, and even if there are input and output examples, recognition errors may occur, including the following steps:
[0052] S41: Entity extraction result self-verification task description: This part needs to tell the large language model what task needs to be completed;
[0053] S42: Example selection based on K nearest neighbor algorithm: First, entity-level representations of all training data are extracted based on the fine-tuned named entity recognition model. Secondly, the same named entity recognition model is used to encode the entities that have been extracted in the query statement. Finally, k examples are selected from the data store as few-shot demonstrations using the representation of the query term. If the retrieved entity belongs to the queried entity type, the answer is "yes", otherwise it is no.
[0054] Those skilled in the art will appreciate that the embodiments herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.
Claims
1. A named entity recognition method based on context learning, characterized in that: The following steps are involved: S1: Construct entity definitions based on domain knowledge; S2: Construct entity extraction template based on thought chain technology; S3: Named Entity Recognition Based on Large Language Model; S4: Self-verification of entity extraction results based on large language models.
2. The method according to claim 1, characterized in that Based on domain knowledge, a definition is constructed for the entities that need to be extracted, so that the large language model can understand the entities to be extracted. The definition module consists of natural language descriptions that constitute and do not constitute entities; for different entity categories in the domain, appropriate entity definitions are constructed.
3. The method according to claim 1, characterized in that Step S2 includes the following steps: S21: Entity extraction task description: This part needs to tell the large language model the specific tasks to be completed and the content that needs to be paid attention to; S22: For each input of each entity category in the training data, reconstruct the output example using the thought chain-based technique; S23: Example of constructing few-shot learning based on the K nearest neighbor algorithm.
4. The method according to claim 3, characterized in that For the training input examples, we need to construct output examples. First, we need to determine the entity boundary based on the entity category, then determine whether it is an entity, and finally give the reason for it being an entity or not. Such output examples can simulate the reasoning path of a large language model to recognize entities.
5. The method according to claim 3, characterized in that Step S23 includes the following steps: S231: extracting entities from the data in the training set based on the fine-tuned named entity recognition tool, representing them in vector form, and storing them in the database; S232: For a given input sequence, the K nearest neighbor algorithm is used to select the semantically closest candidate entities in the database, that is, firstly, the same fine-tuned named entity recognition tool is used to perform entity recognition on the input sequence, and then all the extracted N candidate entities are iterated to find the K nearest neighbor values of each candidate entity from the database, thereby obtaining K×N retrieval entities. S233: Select the top k entities from the K×N retrieved entities and use their related sentences as examples.
6. The method according to claim 1, characterized in that In step S3, for each input sentence, examples with similar semantics are selected from the database using the K nearest neighbor algorithm, and the entity definition and examples are combined into the final few-shot learning example, which is input into the large prediction model for entity recognition.
7. The method according to claim 1, characterized in that Step S4 includes the following steps: S41: Entity extraction result self-verification task description: This part needs to tell the large language model what task needs to be completed; S42: Select examples based on the K nearest neighbor algorithm: First, extract entity-level representations of all training data based on the fine-tuned named entity recognition model. Second, use the same named entity recognition model to encode the entities that have been extracted in the query statement. Finally, use the representation of the query term to select k examples from the data store as few-shot demonstrations. If the retrieved entity belongs to the queried entity type, the answer is "yes", otherwise it is no.
Citation Information
Cited By
Poem entity extraction model training method, poem entity extraction method and poem entity extraction equipment
CN120277219A