Two-segment named entity recognition method, device and equipment and medium
Through the two-stage named entity recognition method, the large language model is used for named entity recognition and entity verification, which solves the problems of large data annotation volume and poor generalization ability in traditional methods, and achieves efficient and accurate named entity recognition and adapts to finance Diversified needs of scenarios.
Patent Information
- Application Number
- CN202411469768.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-02-11
AI Technical Summary
Traditional named entity recognition methods require a large amount of manually labeled data, and the model generalization ability is limited, making it difficult to efficiently and accurately meet the diverse named entity recognition needs in financial scenarios.
Using the two-stage named entity recognition method, by obtaining the original text, the first text containing the recognition task prompt text is constructed, and a large language model is input for named entity recognition; then, based on the recognition results and the original text, the verification task prompt text is constructed. The second text, further physical verification.
It greatly reduces the demand for labeled data, improves the efficiency and accuracy of naming entity recognition, enhances the reliability of identification results, and has good generalization capabilities to adapt to entity recognition tasks under different scenarios or requirements.
Smart Images

Figure CN119416785A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of artificial intelligence technology and financial technology, and in particular to a two-stage named entity recognition method, device, equipment and medium. Background Art
[0002] Named entity recognition is a key task in natural language processing, which aims to identify key information in text and classify it into a set of predefined categories. The application scenarios and requirements of named entity recognition tasks in the financial field are quite diverse. For example, in market analysis scenarios, named entity recognition is used to extract key information from financial news, reports and transaction records, such as company names, stock codes, transaction amounts, etc.; or in insurance customer service scenarios, named entity recognition is used to understand and process customer queries, and provide faster and more accurate services based on the entity information in the query. This scenario usually also involves professional domain knowledge related to various types of insurance.
[0003] Traditional named entity recognition methods usually require a large amount of manually annotated data to train the model, which means that a lot of time and human resources are needed to collect and annotate data, and different annotators may have different understandings and standards of entity boundaries and types, which leads to deviations and inconsistencies in annotations and affects recognition accuracy. At the same time, the generalization ability of the model after training is limited. When dealing with entity recognition tasks with different requirements, it is necessary to re-collect and annotate data, retrain or fine-tune the model, which increases the workload and time cost. It is difficult to efficiently and accurately meet the diverse named entity recognition needs in financial scenarios. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the purpose of the present invention is to provide a two-stage named entity recognition method, device, equipment and medium that can be applied to financial technology or other related fields. Its main purpose is to improve the efficiency and accuracy of named entity recognition and meet the diverse named entity recognition needs in financial scenarios.
[0005] The technical solution of the present invention is as follows:
[0006] A first aspect of the present invention provides a two-stage named entity recognition method, comprising:
[0007] Get the original text to be recognized;
[0008] A first text is constructed according to the original text, wherein the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform a named entity recognition task on the original text;
[0009] Inputting the first text into the large language model to obtain a named entity recognition result of the original text;
[0010] A second text is constructed according to the named entity recognition result and the original text, wherein the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text;
[0011] The second text is input into the large language model to obtain a corresponding verification result.
[0012] A second aspect of the present invention provides a two-stage named entity recognition device, comprising:
[0013] An acquisition module, used for acquiring the original text to be recognized;
[0014] A first construction module is used to construct a first text according to the original text, wherein the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform a named entity recognition task on the original text;
[0015] A recognition module, used for inputting the first text into the large language model to obtain a named entity recognition result of the original text;
[0016] A second construction module is used to construct a second text according to the named entity recognition result and the original text, wherein the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text;
[0017] The entity verification module is used to input the second text into the large language model to obtain a corresponding verification result.
[0018] A third aspect of the present invention provides a computer device, comprising at least one processor; and
[0019] a memory communicatively connected to the at least one processor; wherein,
[0020] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the above-mentioned two-segment named entity recognition method.
[0021] A fourth aspect of the present invention provides a non-volatile computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by one or more processors, the one or more processors can execute the above-mentioned two-stage named entity recognition method.
[0022] Beneficial effects: The present invention discloses a two-stage named entity recognition method, device, equipment and medium. Compared with the prior art, the embodiment of the present invention obtains the original text to be recognized; constructs a first text according to the original text, the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform the named entity recognition task on the original text; inputs the first text into the large language model to obtain the named entity recognition result of the original text; constructs a second text according to the named entity recognition result and the original text, the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text; inputs the second text into the large language model to obtain the corresponding verification result. Two-stage named entity recognition based on the large language model greatly reduces the demand for labeled data and improves recognition efficiency, and the accuracy and reliability of the recognition result can be further improved through the entity verification mechanism. At the same time, the recognition method based on the large language model has good generalization ability, can adapt to entity recognition tasks under different scenarios or requirements, and improves the adaptability of named entity recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the scheme in the present invention, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0024] Figure 1 A schematic diagram of an application environment of the two-stage named entity recognition method provided by an embodiment of the present invention;
[0025] Figure 2 A flow chart of a two-stage named entity recognition method provided by an embodiment of the present invention;
[0026] Figure 3 A flow chart of step S202 in the two-stage named entity recognition method provided by an embodiment of the present invention;
[0027] Figure 4 A flow chart of step S204 in the two-stage named entity recognition method provided by an embodiment of the present invention;
[0028] Figure 5 A schematic diagram of functional modules of a two-stage named entity recognition device provided by an embodiment of the present invention;
[0029] Figure 6 A schematic diagram of the hardware structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail below. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. The embodiments of the present invention are described below in conjunction with the accompanying drawings.
[0031] The two-stage named entity recognition method provided by the embodiment of the present invention can be applied to Figure 1 In the application environment of FIG. 1 , it includes a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104 and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0032] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (only as examples).
[0033] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0034] The server 105 may be a server that provides various services, such as a background server that provides support for the content browsed by the user using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (for example only). The background server may analyze and process the received data such as the user request, and feed back the processing results (such as web pages, information, or data obtained or generated according to the user request) to the terminal device. The server 105 may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server 105 may also be a server for a distributed system, or a server combined with a blockchain.
[0035] It should be noted that the two-segment named entity recognition method provided in the embodiment of the present application can generally be executed by the first terminal device 101, the second terminal device 102 or the third terminal device 103. Accordingly, the two-segment named entity recognition apparatus provided in the embodiment of the present invention can also be set in the first terminal device 101, the second terminal device 102 or the third terminal device 103. Alternatively, the two-segment named entity recognition method provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the two-segment named entity recognition apparatus provided in the embodiment of the present invention can generally be set in the server 105.
[0036] It should be understood that the numbers of the above terminal devices, networks and servers are only illustrative. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0037] like Figure 2 As shown, the two-stage named entity recognition method provided by the embodiment of the present invention specifically includes the following steps:
[0038] S201: Obtain original text to be recognized.
[0039] In this embodiment, when performing named entity recognition in the financial field, texts in different recognition scenarios can be used as original texts to be recognized. These original texts contain named entities that need to be recognized. Named entities generally refer to entities with specific meanings or strong referentiality in the text. In the financial field, they usually include names of people, places, names of organizations, dates and times, financial products, etc. For example, the original text in the data analysis scenario can be financial news, financial reports, transaction records, etc.; the original text in the intelligent customer service scenario can be chat records between customer service and customers, etc.; the original text in the financial product recommendation scenario can be product introduction text, etc., so as to adapt to entity recognition tasks in different scenarios or needs.
[0040] S202. Construct a first text according to the original text, wherein the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt a large language model to perform a named entity recognition task on the original text.
[0041] In this embodiment, the large language model is a deep learning model trained with a large amount of text data, which can generate natural language text or understand the meaning of language text. They can handle a variety of natural language tasks, such as text classification, question answering, dialogue, etc. When implementing named entity recognition, the recognition task prompt text is added to the original text to construct the first text, and the recognition task prompt text is used to prompt the large language model to perform the named entity recognition task on the original text.
[0042] For example, when the original text is a news report about a company's financial report: "A Group's net profit increased by 12% in 2023, and the company's stock price rose after the financial report was released." Based on the original text, add clear recognition task prompt text, for example: "Please identify the company name, year, event and other entities in the following financial news reports, and mark their types." The first text constructed in this way can be: "A Group's net profit increased by 12% in 2023, and the company's stock price rose after the financial report was released. Please identify the company name, year, event and other entities, and mark their types." That is, context prompts are constructed through the original text and the recognition task prompt text to guide the large language model to understand the specific needs of the current task, so that the large language model can learn in context how to identify entities in the text in the current field or scenario, so that there is no need to manually annotate a large amount of data, and only a very small amount of data needs to be annotated in the recognition task prompt text to achieve entity extraction.
[0043] Preferably, in addition to the original text and the recognition task prompt text, corresponding examples can also be given in the first text, so that when performing named entity recognition in new fields or new scenarios, it will help the large language model to better understand the entity information in the original text and improve the ability to extract entities.
[0044] For example, the first text may include the following three parts of text:
[0045] (1) Recognition task prompt text: "I am an excellent linguist. The task is to extract person, place, organization, and time entities from a given sentence. Person entities include real people, fictional characters, historical figures, etc. Place entities include cities, countries, streets, buildings, etc. Organization entities include companies, government agencies, schools, groups, etc. Time entities include years, months, days, seasons, etc. The output entity content must be extracted from the original text and the original text content cannot be modified. If there is no entity of this category, the output is "None" and no other redundant explanation content is output; if a category has multiple different entities, they are separated by commas."
[0046] (2) Context Example E: “Here are some examples of entity extraction:
[0047] Input: The two-day 1994 XX Annual Meeting ended today at Location B.
[0048] Output:
[0049] Characters: None
[0050] Location: Site B
[0051] Organization: None
[0052] Time: 1994
[0053] Input: How will the popular models of Company C perform in 2023?
[0054] Output:
[0055] Characters: None
[0056] Location: None
[0057] Organization: C Enterprise
[0058] Time: 2023".
[0059] (3) Input text I. If the original text entered by the user is text, then I is “Input: {text}
[0060] Output:"
[0061] The final first text, i.e., the context prompt, is T+E+I. Moreover, for new entity types, the text describing the entity type can be added or modified in the task description T without retraining the model or annotating a large amount of new data.
[0062] S203: Input the first text into the large language model to obtain a named entity recognition result of the original text.
[0063] In this embodiment, the constructed first text is input into a pre-trained large language model for named entity recognition. The large language model has acquired better language comprehension ability through pre-training, and can realize entity recognition in various scenarios under rich context information, that is, the model can output the named entity recognition results of the original text, identify the entity categories and specific entities in the original text, thereby reducing dependence on a large amount of annotated data and realizing efficient and low-cost named entity recognition.
[0064] For example, if the first text "Group A's net profit increased by 12% in 2023, and the company's stock price rose after the financial report was released. Please identify entities such as company name, year, event, and label their types." is input into the large language model, the model may output the following named entity recognition results:
[0065] A Group [ORG]
[0066] 2023[DATE]
[0067] Net profit growth[EVENT]
[0068] Earnings Report Release [EVENT]
[0069] S204. Constructing a second text according to the named entity recognition result and the original text, wherein the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text.
[0070] In this embodiment, since the large language model has a hallucination problem, that is, it may output content that seems reasonable but is incorrect, after the named entity recognition is performed by the large language model in the previous stage, the named entity recognition result output by the large language model is also verified by constructing a second text. That is, a verification task prompt text is added on the basis of the named entity recognition result and the original text, so as to construct the second text, and the verification task prompt text is used to prompt the large language model to perform the entity verification task on the named entity recognition result based on the original text.
[0071] For example, when the named entity recognition result output by the model is: "A Group [ORG]; 2023 [DATE]; Net profit growth [EVENT]; Financial report release [EVENT]", combined with the original text text: "A Group's net profit increased by 12% in 2023, and the company's stock price rose after the financial report was released." and the verification task prompt text such as "Please verify whether the following entities [entity 1]-category 1, [entity 2]-category 2... are correctly mentioned in the original text, and give the verification results", the constructed second text can be: "Please verify whether the following entities are correctly mentioned in [text]: A Group [ORG], 2023 [DATE], net profit growth [EVENT], financial report release [EVENT], and give the verification results". That is, contextual prompts are constructed through the original text, the named entity recognition results and the verification task prompt text to guide the large language model to understand the specific requirements of the current task, and let the large language model verify the recognition results of the previous stage under the above and below prompts to ensure the accuracy and reliability of the recognition results.
[0072] S205: Input the second text into the large language model to obtain a corresponding verification result.
[0073] In this embodiment, the constructed second text is input into the large language model, and the model will verify the entity according to the provided entity recognition result and context information. For example, for the second text constructed in the above example, "Please verify whether the following entities are correctly mentioned in [text]: A Group [ORG], 2023 [DATE], net profit growth [EVENT], financial report release [EVENT], and give the verification results.", the model may output the following verification results:
[0074] A Group [ORG] - Correct (identified as an organizational entity)
[0075] 2023[DATE] - Correct (recognized as a date entity)
[0076] Net Profit Increase [EVENT] - Correct (identified as an event entity)
[0077] Earnings Release [EVENT] - False (the original text refers to "stock price rises after earnings release", "earnings release" may be incorrectly identified as a separate event)
[0078] By further performing entity verification on the named entity recognition results of the previous stage to ensure the accuracy and relevance of the recognized entities in the original text, errors in entity recognition can be discovered and corrected, thereby providing more reliable entity information.
[0079] In the above embodiment, the present invention discloses a two-stage named entity recognition method, which is obtained by obtaining the original text to be recognized; constructing a first text based on the original text, the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform the named entity recognition task on the original text; inputting the first text into the large language model to obtain the named entity recognition result of the original text; constructing a second text based on the named entity recognition result and the original text, the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text; inputting the second text into the large language model to obtain the corresponding verification result. The two-stage named entity recognition based on the large language model greatly reduces the demand for labeled data and improves the recognition efficiency, and the accuracy and reliability of the recognition result can be further improved through the entity verification mechanism. At the same time, the recognition method based on the large language model has good generalization ability, which can adapt to entity recognition tasks under different scenarios or requirements, and improve the adaptability of named entity recognition.
[0080] In this embodiment, Figure 3 As shown, step S202 includes:
[0081] S301, extracting elements from the original text to obtain subtexts of preset elements in the original text, where the preset elements include scene elements, domain elements, and theme elements;
[0082] S302, matching and calling a recognition prompt template from a preset template library according to the subtext of the preset element;
[0083] S303, adding the subtext of the preset element to a specified position in the recognition prompt template to obtain the recognition task prompt text;
[0084] S304: Concatenate the recognition task prompt text with the original text to construct the first text.
[0085] In this embodiment, several elements are pre-defined, including scene elements, domain elements and theme elements. When constructing the first text, the original text is first subjected to string segmentation, regular expression, keyword search, etc. to extract sub-texts of preset elements therein, for example, the scene element is extracted as news analysis, the domain element is extracted as financial field, and the theme element is extracted as xx financial conference.
[0086] The extracted subtext of the preset element is matched and called from the preset template library to the corresponding recognition prompt template, that is, a preset template library containing multiple templates is built in advance, and each template is associated with a specific scene, field or theme. For example, if the scene is "medical", there may be templates related to diseases, treatments and doctors to better meet the needs of elements such as different scenes or fields. The extracted subtext is added to the specified position in the matched recognition prompt template, which is usually a preset placeholder or slot in the template. For example, the matched recognition prompt template is: "Please identify the company name, year, event and other entities in [theme element] under [scene element] of [field element], and mark their types." After filling in the subtext, the recognition task prompt text can be obtained: "Please identify the company name, year, event and other entities in the following xx financial conference in the news analysis scenario in the financial field, and mark their types.".
[0087] The generated recognition task prompt text is concatenated with the original text to construct the first text. That is, the constructed first text not only contains the original information, but also contains clear recognition task instructions, so that the large language model can perform the named entity recognition task more accurately and improve the efficiency and accuracy of the entire process.
[0088] In one embodiment, the matching and calling the recognition prompt template from a preset template library according to the subtext of the preset element includes:
[0089] Performing vectorization processing on the subtext of the preset element to generate corresponding semantic features;
[0090] The semantic features of the preset elements are matched with the templates in the preset module library according to the preset matching strategy, and the matching recognition prompt template is confirmed and called.
[0091] In this embodiment, when matching and calling the recognition prompt template, the subtext of the preset element is converted into a numerical vector representation, which can capture the semantic features of the subtext, so that accurate matching and comparison can be performed in the vector space. According to the semantic features obtained by vectorization, each template in the preset template library is matched, for example, the cosine similarity or other similarity measurement between the semantic features and each template is calculated, and the matching is performed according to the preset matching strategy to confirm which template is most suitable for the current subtext, thereby improving the accuracy and relevance of the recognition task. The specific matching strategy can be, for example, nearest neighbor matching, that is, selecting the template that is most similar to the semantic representation of the preset element; or classification matching, inputting the semantic representation of the preset element into the classification model, and selecting the corresponding template according to the classification result; or rule matching, according to the type or attribute of the preset element, using predefined rules to select the template, etc. Once the best matching template is determined, the best matching template is called to construct the recognition task prompt text, ensuring that the recognition prompt template is closely related to the content and context of the original text, thereby improving the accuracy and efficiency of subsequent tasks.
[0092] In one embodiment, before concatenating the recognition task prompt text with the original text to construct the first text, the method further includes:
[0093] Retrieving and acquiring related background information from a preset data source according to the subtext of the subject element;
[0094] The recognition task prompt text is fused and updated according to the background information to generate a final recognition task prompt text.
[0095] In this embodiment, before the recognition task prompt text is spliced with the original text, relevant background information is retrieved based on the sub-text of the subject element, and the prompt text is updated using this information. For example, when the subject element "xx financial conference" is obtained in financial news, relevant background information is retrieved from preset data sources such as databases, knowledge graphs, or Internet resources, such as records of previous sessions of the financial conference, meeting agendas, information about important speakers, etc., and the retrieved background information is integrated into the recognition task prompt text. For example, if the retrieved background information includes the key focus areas of the conference, such as "blockchain technology", "application of artificial intelligence in finance", etc., this information can be added to the prompt text to ensure that the recognition task prompt text can more clearly guide the large language model to focus on entities and information related to "xx financial conference". For example, the initially generated recognition task prompt text is: "Please identify the following xx financial conference company names, years, events and other entities in the news analysis scenario in the financial field, and label their types." After integrating the background information, the final recognition task prompt text can be: "The upcoming xx financial conference will focus on the application of blockchain technology and artificial intelligence in finance. Please identify the company names, years, events and other entities in the xx financial conference in the news analysis scenario in the financial field, and label their types.", thereby improving the relevance and accuracy of named entity recognition.
[0096] In one embodiment, Figure 4 As shown, step S204 includes:
[0097] S401, parsing the named entity recognition result to obtain all currently recognized named entities and the type of each named entity;
[0098] S402, adding all the currently recognized named entities and the type of each named entity to a specified position in a preset verification prompt template to obtain the verification task prompt text;
[0099] S403: Concatenate the verification task prompt text with the original text to construct the second text.
[0100] In this embodiment, when constructing the second text, the named entity recognition results are first parsed to obtain all currently recognized named entities and the type of each named entity, such as names of people, places, and organizations, so as to obtain a clear list of entities and their types, laying the foundation for constructing the verification task prompt text. The parsed named entities and the type of each named entity are added to the specified position in the preset verification prompt template to obtain the verification task prompt text. The verification prompt template can be fixed or selected from multiple templates, which is not limited in this embodiment.
[0101] The generated verification task prompt text is concatenated with the original text to construct a second text. The second text provides a complete verification task for the large language model, including the original text and clear verification guidance, so that the model can perform entity verification more accurately. For example, if the named entity recognition result output of the large language model = "TYPE_A:entity_1,entity_2; TYPE_B:entity_3", the constructed second text can be: "I am an excellent linguist. The task is to verify the entity. In the text, is entity_1 an entity of type TYPE_A? Please answer 'yes' or 'no'", so that the model can perform the entity verification task more accurately. The entity verification mechanism can further improve the accuracy and reliability of the recognition results, verify the contextual consistency of the entity, and the matching with the domain knowledge, thereby improving the robustness of the model and reducing the cases of misidentification and missed recognition.
[0102] In one embodiment, after parsing the named entity recognition result to obtain all currently recognized named entities and the type of each named entity, the method further includes:
[0103] Confirm whether all currently recognized named entities are in the original text;
[0104] When at least one named entity is not in the original text, it is confirmed that there is an error in the named entity recognition result.
[0105] In this embodiment, after parsing the named entity recognition results, a preliminary verification can be performed through intuitive matching, that is, to confirm whether all currently recognized named entities are in the original text. As long as there is a named entity that is not in the original text, it is confirmed that the current entity recognition result is wrong. There is no need to perform subsequent tasks such as generating a second text and letting the large language model perform entity verification. The corresponding verification results are directly output to save computing resources and improve processing efficiency.
[0106] In one embodiment, after inputting the second text into the large language model and obtaining a corresponding verification result, the method further includes:
[0107] When the verification result is that the recognition is correct, output and display the named entity recognition result;
[0108] When the verification result is a recognition error, the named entity recognition result is added to a set to be reviewed and a review reminder message is output.
[0109] In this embodiment, when the large language model completes the entity verification task and determines that the entity recognition is correct, the named entity recognition result is output and displayed to the user or system interface in a visual manner, so that the user can intuitively obtain the entities and types recognized by the model, so as to facilitate further data processing or analysis tasks. When the verification result shows that the entity recognition is incorrect, these entities and their types are recorded as incorrect recognitions, and the incorrectly recognized entities are added to the set to be reviewed and the review reminder information is output to notify the relevant personnel that there are entity recognition results to be reviewed, and the overall accuracy of entity recognition is improved through manual or automatic review. Ensure that high-accuracy entity recognition results are output and displayed, and that the incorrectly recognized results are properly processed and reminded, thereby maintaining the quality and efficiency of the named entity recognition processing.
[0110] It should be noted that there is not necessarily a certain order between the above-mentioned steps. A person skilled in the art can understand, based on the description of the embodiments of the present invention, that in different embodiments, the above-mentioned steps may have different execution orders, that is, they may be executed in parallel, may be executed interchangeably, and so on.
[0111] Further references Figure 5 , as a response to the above Figure 2 The present invention provides an embodiment of a two-stage named entity recognition device, and the device embodiment is Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0112] like Figure 5 As shown, the two-stage named entity recognition device 50 described in this embodiment includes:
[0113] An acquisition module 501 is used to acquire the original text to be recognized;
[0114] A first construction module 502 is used to construct a first text according to the original text, wherein the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform a named entity recognition task on the original text;
[0115] A recognition module 503, configured to input the first text into the large language model to obtain a named entity recognition result of the original text;
[0116] A second construction module 504 is used to construct a second text according to the named entity recognition result and the original text, wherein the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text;
[0117] The entity verification module 505 is used to input the second text into the large language model to obtain a corresponding verification result.
[0118] The module referred to in the present invention refers to a series of computer program instruction segments that can perform specific functions, which is more suitable for describing the two-stage named entity recognition execution process than a program. For the specific implementation of each module, please refer to the corresponding method embodiment above, which will not be repeated here.
[0119] In one embodiment, the first building module 502 includes:
[0120] An element extraction unit, used to extract elements from the original text to obtain subtexts of preset elements in the original text, wherein the preset elements include scene elements, domain elements and theme elements;
[0121] A template matching unit, used for matching and calling a recognition prompt template from a preset template library according to the subtext of the preset element;
[0122] A first prompt unit, used for adding the subtext of the preset element to a specified position in the recognition prompt template to obtain the recognition task prompt text;
[0123] The first construction unit is used to concatenate the recognition task prompt text with the original text to construct the first text.
[0124] In one embodiment, the template matching unit includes:
[0125] A vectorization unit, used for performing vectorization processing on the subtext of the preset element to generate corresponding semantic features;
[0126] The matching and calling unit is used to match the semantic features of the preset element with each template in the preset module library according to a preset matching strategy, and confirm and call the matching recognition prompt template.
[0127] In one embodiment, the first building module 502 further includes:
[0128] A related retrieval unit, used to retrieve and obtain related background information from a preset data source according to the subtext of the subject element;
[0129] The fusion updating unit is used to fuse and update the recognition task prompt text according to the background information to generate a final recognition task prompt text.
[0130] In one embodiment, the second building module 504 includes:
[0131] A parsing unit, used to parse the named entity recognition result to obtain all currently recognized named entities and the type of each named entity;
[0132] A second prompt unit, used for adding all the currently recognized named entities and the type of each named entity to a specified position in a preset verification prompt template to obtain the verification task prompt text;
[0133] The second construction unit is used to concatenate the verification task prompt text with the original text to construct the second text.
[0134] In one embodiment, the device 50 further comprises:
[0135] A confirmation unit, used to confirm whether all currently recognized named entities are in the original text;
[0136] An error output unit is used to confirm that there is an error in the named entity recognition result when at least one named entity is not in the original text.
[0137] In one embodiment, the device 50 further comprises:
[0138] A first processing module, configured to output and display the named entity recognition result when the verification result is that the recognition is correct;
[0139] The second processing module is used to add the named entity recognition result to the to-be-reviewed set and output a review reminder message when the verification result is a recognition error.
[0140] In the above embodiment, the present invention discloses a two-stage named entity recognition device, which obtains the original text to be recognized; constructs a first text based on the original text, the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform a named entity recognition task on the original text; inputs the first text into the large language model to obtain a named entity recognition result of the original text; constructs a second text based on the named entity recognition result and the original text, the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text; inputs the second text into the large language model to obtain a corresponding verification result. Two-stage named entity recognition based on the large language model greatly reduces the demand for labeled data and improves recognition efficiency, and the accuracy and reliability of the recognition result can be further improved through the entity verification mechanism. At the same time, the recognition method based on the large language model has good generalization ability, which can adapt to entity recognition tasks under different scenarios or requirements, and improve the adaptability of named entity recognition.
[0141] Another embodiment of the present invention provides a computer device, such as Figure 6 As shown, the computer device 60 includes:
[0142] One or more processors 601 and memory 602, Figure 6 A processor 601 is used as an example for the description. The processor 601 and the memory 602 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0143] Processor 601 is used to complete various control logics of computer device 60, and it can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component or any combination of these components. In addition, processor 601 can also be any traditional processor, microprocessor or state machine. Processor 601 can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a DSP and / or any other such configuration.
[0144] The memory 602 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions corresponding to the two-stage named entity recognition method in the embodiment of the present invention. The processor 601 executes various functional applications and data processing of the computer device 60 by running the non-volatile software programs, instructions and units stored in the memory 602, that is, the two-stage named entity recognition method in the above method embodiment is implemented.
[0145] The memory 602 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created according to the use of the computer device 60, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 602 may optionally include a memory remotely arranged relative to the processor 601, and these remote memories may be connected to the computer device 60 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. One or more units are stored in the memory 602, and when executed by one or more processors 601, the steps of the two-segment named entity recognition method in any of the above-mentioned method embodiments are executed.
[0146] In the above embodiment, the present invention discloses a computer device, which obtains the original text to be recognized; constructs a first text according to the original text, the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform a named entity recognition task on the original text; inputs the first text into the large language model to obtain a named entity recognition result of the original text; constructs a second text according to the named entity recognition result and the original text, the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text; inputs the second text into the large language model to obtain a corresponding verification result. The two-stage named entity recognition based on the large language model greatly reduces the demand for annotated data and improves recognition efficiency, and the accuracy and reliability of the recognition result can be further improved through the entity verification mechanism. At the same time, the recognition method based on the large language model has good generalization ability, which can adapt to entity recognition tasks under different scenarios or requirements, and improve the adaptability of named entity recognition.
[0147] An embodiment of the present invention provides a non-volatile computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by one or more processors, the steps of the two-segment named entity recognition method in any of the above method embodiments are executed.
[0148] In the above embodiment, the present invention discloses a non-volatile computer-readable storage medium, which obtains the original text to be recognized; constructs a first text according to the original text, the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform a named entity recognition task on the original text; inputs the first text into the large language model to obtain the named entity recognition result of the original text; constructs a second text according to the named entity recognition result and the original text, the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text; inputs the second text into the large language model to obtain the corresponding verification result. The two-stage named entity recognition based on the large language model greatly reduces the demand for annotated data and improves the recognition efficiency, and the accuracy and reliability of the recognition result can be further improved through the entity verification mechanism. At the same time, the recognition method based on the large language model has good generalization ability, which can adapt to entity recognition tasks under different scenarios or requirements, and improve the adaptability of named entity recognition.
[0149] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0150] The present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0151] In summary, the present invention discloses a two-stage named entity recognition method, device, equipment and medium, the method includes: obtaining the original text to be recognized; constructing a first text according to the original text, the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform the named entity recognition task on the original text; inputting the first text into the large language model to obtain the named entity recognition result of the original text; constructing a second text according to the named entity recognition result and the original text, the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text; inputting the second text into the large language model to obtain the corresponding verification result. The two-stage named entity recognition based on the large language model greatly reduces the demand for annotated data and improves the recognition efficiency, and the accuracy and reliability of the recognition result can be further improved through the entity verification mechanism. At the same time, the recognition method based on the large language model has good generalization ability, which can adapt to entity recognition tasks under different scenarios or requirements, and improve the adaptability of named entity recognition.
[0152] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium, and the computer program can include the processes of the above-mentioned method embodiments when executed. The storage medium can be a memory, a disk, a floppy disk, a flash memory, an optical storage device, etc.
[0153] It should be noted that if any software tools or components other than those of the Company appear in the embodiments of the present application, they are merely used for illustration and do not represent actual use. It should be understood that the application of the present invention is not limited to the above examples, and that those skilled in the art can make improvements or changes based on the above description, and all such improvements and changes shall fall within the scope of protection of the claims attached to the present invention.
Claims
1. A two-stage named entity recognition method, characterized in that: include: Get the original text to be recognized; A first text is constructed according to the original text, wherein the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform a named entity recognition task on the original text; Inputting the first text into the large language model to obtain a named entity recognition result of the original text; A second text is constructed according to the named entity recognition result and the original text, wherein the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text; The second text is input into the large language model to obtain a corresponding verification result.
2. The two-stage named entity recognition method according to claim 1, characterized in that: The step of constructing a first text according to the original text includes: Extracting elements from the original text to obtain subtexts of preset elements in the original text, wherein the preset elements include scene elements, domain elements, and theme elements; Matching and calling a recognition prompt template from a preset template library according to the subtext of the preset element; Adding the subtext of the preset element to a specified position in the recognition prompt template to obtain the recognition task prompt text; The recognition task prompt text is concatenated with the original text to construct the first text.
3. The two-stage named entity recognition method according to claim 2, characterized in that: The matching and calling the recognition prompt template from a preset template library according to the subtext of the preset element includes: Performing vectorization processing on the subtext of the preset element to generate corresponding semantic features; The semantic features of the preset elements are matched with the templates in the preset module library according to the preset matching strategy, and the matching recognition prompt template is confirmed and called.
4. The two-stage named entity recognition method according to claim 2, characterized in that: Before concatenating the recognition task prompt text with the original text to construct the first text, the method further includes: Retrieving and acquiring related background information from a preset data source according to the subtext of the subject element; The recognition task prompt text is fused and updated according to the background information to generate a final recognition task prompt text.
5. The two-stage named entity recognition method according to claim 1, characterized in that: The step of constructing a second text according to the named entity recognition result and the original text includes: Parsing the named entity recognition result to obtain all currently recognized named entities and the type of each named entity; Adding all the currently recognized named entities and the type of each named entity to a specified position in a preset verification prompt template to obtain the verification task prompt text; The verification task prompt text is concatenated with the original text to construct the second text.
6. The two-stage named entity recognition method according to claim 5, characterized in that: After parsing the named entity recognition result to obtain all currently recognized named entities and the type of each named entity, the method further includes: Confirm whether all currently recognized named entities are in the original text; When at least one named entity is not in the original text, it is confirmed that there is an error in the named entity recognition result.
7. The two-stage named entity recognition method according to claim 1, characterized in that: After inputting the second text into the large language model and obtaining a corresponding verification result, the method further includes: When the verification result is that the recognition is correct, output and display the named entity recognition result; When the verification result is a recognition error, the named entity recognition result is added to a set to be reviewed and a review reminder message is output.
8. A two-stage named entity recognition device, characterized in that: include: An acquisition module, used for acquiring the original text to be recognized; A first construction module is used to construct a first text according to the original text, wherein the first text includes a recognition task prompt text, and the recognition task prompt text is used to prompt the large language model to perform a named entity recognition task on the original text; A recognition module, used for inputting the first text into the large language model to obtain a named entity recognition result of the original text; A second construction module is used to construct a second text according to the named entity recognition result and the original text, wherein the second text includes a verification task prompt text, and the verification task prompt text is used to prompt the large language model to perform an entity verification task on the named entity recognition result based on the original text; The entity verification module is used to input the second text into the large language model to obtain a corresponding verification result.
9. A computer device, characterized in that: comprising at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the two-segment named entity recognition method described in any one of claims 1-7.
10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer-executable instructions, which, when executed by one or more processors, enable the one or more processors to execute the two-segment named entity recognition method described in any one of claims 1-7.
Citation Information
Cited By
Entity identification method and device for nutritional and healthy food field
CN120706427A