Data extraction method and device, electronic equipment, storage medium and program product
By using context information and correction information during the data extraction process to correct the recognition and understanding of the language model, the problem of inaccurate judgment of the accuracy of data extraction results in the prior art is solved, and the accuracy of data extraction is improved.
Patent Information
- Application Number
- CN202411045843.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-12-17
AI Technical Summary
In the process of data extraction, it is difficult to accurately understand the actual identification and understanding of the input data by the language model, which leads to inaccurate judgment of the accuracy of the data extraction results, especially in the absence of deviations and noise in the training data, model structure limitations and inference processes. Under uncertainty in this article, it may lead to "model hallucinations".
By determining the first prompt content, input it into the language model for processing, obtaining the context information and data extraction results, and by comparing the context information with the target text, it determines its accuracy; if there is an error, generate correction information and generate the second prompt content, Further input into the language model for processing to improve the accuracy of data extraction results.
The correction of language model recognition and understanding ability is achieved, the accuracy of data extraction results is improved, and the accuracy of data extraction effects is ensured.
Smart Images

Figure CN119149661A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a data extraction method, device, electronic device, storage medium and program product. Background Art
[0002] With the rapid development of natural language processing technology, language models (such as the GPT series) have become an important tool in data extraction tasks. Language models can understand and generate human language by learning a large amount of target text, thereby realizing the extraction of various text information. Summary of the invention
[0003] Embodiments of the present application provide a data extraction method, device, electronic device, storage medium, and program product.
[0004] On the one hand, an embodiment of the present application provides a data extraction method, which includes: determining a first prompt content, the first prompt content is used to prompt to extract data of a target name from a target text, the first prompt content includes the target text and the target name, inputting the first prompt content into a language model for a first processing, obtaining context information of the target name and a first data extraction result, determining whether there are errors in the context information and the first data extraction result based on the context information and the target text, if it is determined that there are errors in the context information and / or the first data extraction result, generating a second prompt content based on the first prompt content, the context information and preset correction information, the correction information is used to prompt that the context information and / or the first data extraction result are wrong, and inputting the second prompt content into the language model for a second processing to obtain a second data extraction result.
[0005] In the data extraction method of the present embodiment, the context information is the intermediate data generated after the language model recognizes and understands the target text, so the context information can reflect the actual recognition and understanding of the target text by the language model. The first data extraction result is the key information or data fragment extracted by the language model from the context information, so by comparing the context information with the target text, it can be determined whether the actual recognition and understanding of the target text by the language model is biased or wrong, so that it can be accurately determined whether the context information is wrong. Since the first data extraction result is generated based on the context information, when it is determined that the context information has an error, it can be determined that the first data extraction result also has an error, and the correction information can be used to prompt that the context information and the first data extraction result have an error. When it is determined that the context information and / or the first data extraction result are wrong, the correction information can be used to prompt that the first data extraction result has an error. Therefore, based on the first prompt content, the context information and the correction information, the second prompt content is generated, and the second prompt content is input into the language model for the second processing, which can realize the correction of the recognition and understanding ability of the language model for the target text, thereby improving the accuracy of the second data extraction result.
[0006] On the other hand, the present application provides a data extraction device, which includes: a determination module, used to determine a first prompt content, the first prompt content is used to prompt to extract data of a target name from a target text, the first prompt content includes the target text and the target name, an input module, used to input the first prompt content into a language model for a first processing to obtain context information of the target name and a first data extraction result, the determination module is also used to determine whether there are errors in the context information and the first data extraction result based on the context information and the target text, a generation module, used to generate a second prompt content based on the first prompt content, the context information and preset correction information if it is determined that there are errors in the context information and / or the first data extraction result, the correction information is used to prompt that the context information and / or the first data extraction result are wrong, and the input module is used to input the second prompt content into the language model for a second processing to obtain a second data extraction result.
[0007] On the other hand, the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the data extraction method provided above when executing the computer program.
[0008] On the other hand, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the data extraction method provided above is implemented.
[0009] On the other hand, the present application provides a computer program product, including a computer program, which implements the data extraction method provided above when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0011] Figure 1 It is a flow chart of a data extraction method provided in one embodiment of the present application.
[0012] Figure 2 It is a flowchart of data extraction provided by an embodiment of the present application.
[0013] Figure 3 It is a flowchart of a method for determining a first data extraction result provided in one embodiment of the present application.
[0014] Figure 4 It is a flowchart of a method for determining context information provided by an embodiment of the present application.
[0015] Figure 5 It is a flowchart of a method for determining the first data extraction result provided in some other embodiments of the present application.
[0016] Figure 6 It is a structural schematic diagram of a data extraction device provided in one embodiment of the present application.
[0017] Figure 7 It is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are 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 are within the scope of protection of this application.
[0019] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art in the technical field in this application. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. It should be understood that, unless otherwise specified in this application, "at least one" refers to one or more. "Multiple" refers to two or more than two. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, a, b and c seven situations.
[0021] The following is an explanation of some of the terms that appear in the embodiments of this application:
[0022] Language model (LLM): refers to a natural language processing model (NLP) with a large number of parameters. Language models are often trained with a large amount of computing resources and training data, so language models can handle various complex natural language tasks, including but not limited to: language understanding, generation, translation, etc.
[0023] Prompt learning: Prompt learning guides the language model to generate response content by providing specific prompt information / prompt content to the language model. The prompt information / prompt content can be in various forms such as text, image, audio, etc. This application does not limit the type of prompt information / prompt content. The prompt information / prompt content can be used to help the model understand the user's needs and generate corresponding text.
[0024] Zero-Shot Chain-of-Thought (Zero-Shot-COT): Zero-Shot-COT guides the language model to decompose a complex problem into multiple simpler sub-problems by adding guiding sentences like "Let's think step by step" to the prompt content, thereby enhancing the reasoning ability of the language model. This method not only simplifies the guidance process, but also does not require additional example data, thereby reducing the complexity of data collection and processing.
[0025] Few-Shot Chain-of-Thought (Few-Shot-COT): Few-Shot-COT is an extension of Zero-Shot COT. Few-Shot Chain-of-Thought uses a few samples containing problem decomposition examples (example templates) to guide the language model to learn how to decompose complex problems into multiple simpler sub-problems for solving. In the example, each complex problem is presented in detail as a series of sub-problems to be solved step by step, providing a clear guidance framework for the model. In this way, the language model is able to learn the strategy of decomposing complex problems into sub-problems and apply this strategy in subsequent problem solving, thereby improving its reasoning ability. Compared with Zero-Shot COT, Few-Shot-COT provides the model with more intuitive and easy-to-understand learning materials by providing specific examples.
[0026] When extracting data, due to the bias and noise in the training data, the limitations of the model structure, and the uncertainty in the reasoning process, the language model may not be able to correctly identify or understand the input data, and thus output data extraction results that are not in line with reality and logic. This phenomenon is usually called "model hallucination."
[0027] Related technologies often match data extraction results with input data through algorithms (such as Knuth-Morris-Pratt) to determine whether the data extraction results exist in the input data, thereby determining whether the data extraction results are wrong. However, this method cannot understand the actual recognition and understanding of the input data by the language model. Only through literal matching, it is impossible to capture the deep semantics and contextual logic in the input data, resulting in inaccurate judgment of the accuracy of the data extraction results. For example, the name of Party B in the input data is Company A, and the name of Party B's collection account is Company B. When the name of Party B's collection account is extracted, the data extraction result is Company A. At this time, the data extraction result Company A matches the input data. If the method of matching the data extraction result with the input data in the related technology is used, it will be determined that the data extraction result Company A is correct, but in fact the data extraction result Company A is wrong. It can be seen that when there is similar content in the input data and / or the language model's actual recognition and understanding of the input data is not comprehensive and accurate, it may lead to errors in the judgment of the accuracy of the data extraction results.
[0028] If we cannot understand how the language model actually recognizes and understands the input data, it will be difficult to accurately judge the accuracy of the data extraction results, thus affecting the data extraction effect.
[0029] In order to solve the above technical problems, the embodiments of the present application provide a data extraction method, which can ensure the accuracy of data extraction. For ease of understanding, the technical solutions provided by the embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0030] The present application will describe the technical solution of the present application in detail through specific embodiments below. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0031] like Figure 1 As shown, it is a flow chart of a data extraction method provided by an embodiment of the present application. According to different requirements, the order of each step in the flow chart can be adjusted according to actual requirements, and some steps can be omitted. The data extraction method can be applied to one or more electronic devices. For example, Figure 7 An electronic device 70 is shown.
[0032] S11, determining a first prompt content, the first prompt content is used to prompt data of extracting a target name from a target text, and the first prompt content includes a target text and a target name.
[0033] In some embodiments of the present application, the target text is the text data to be extracted, and the target text can be any type of text data, and the present application does not limit the type of the target text. For example, the target text can be a contract text, a legal document, a news report, an academic paper, a web page content, an email, a chat record, a medical report, a patent document, a product description, a user comment, etc.
[0034] The target name is the name or type of data to be extracted from the target text, and the number of target names can be one or more. Exemplarily, if the target text is a contract text, the target name can be the type, name, and other information of the data to be extracted from the contract text, for example, the target name can be "Contract Signing Time", "Contract Signing Location", "Latest Delivery Time", "Contract Total Price" and / or "Invoice Type", etc. If the target text is a legal document, the target name can be the type, name, and other information of the data to be extracted from the legal document, for example, the target name can be "Case Name", "Case Number", "Court Name", "Judgment Result", "Plaintiff" and / or "Defendant", etc.
[0035] In some embodiments of the present application, the first prompt content can provide contextual information or guidance for the language model so that the language model can better understand the input target text, thereby accurately identifying the data of the target name. The first prompt content can be in the form of Few-Shot-COT, including the target text, one or more example templates and the target name, or the first prompt content can also be in the form of Zero-Shot-COT, including a guide sentence, target text and target name. The guide sentence can be customized, and the present application does not limit this. For example, the guide sentence can be "Let's think step by step". The above examples of the first prompt content are only examples, and the present application does not limit the number and type of the first prompt content.
[0036] In some embodiments of the present application, the electronic device can obtain the target text, the target name, the example template, and the prompt template. The prompt template includes multiple information columns, and the multiple information columns correspond one by one to the target text, the target name, and the example template. The electronic device fills the target text, the target name, and the example template into the corresponding information columns in the prompt template to obtain the first prompt content.
[0037] In other embodiments of the present application, the electronic device can obtain a guiding sentence, a target text, a target name, and a prompt template. The prompt template includes one or more data extraction tasks. The data extraction task includes a prompt language model to extract data of the target name from the target text. The prompt template includes multiple information columns. The multiple information columns correspond one-to-one to the target text, the target name, and the guiding sentence. The electronic device fills the guiding sentence, the target name, and the target text into the corresponding information columns in the prompt template to obtain the first prompt content.
[0038] The present application does not limit the method for obtaining the target text, target name, sample template, prompt template, and guide sentence. For example, the electronic device can read the target text, target name, sample template, prompt template, and guide sentence from a folder under a preset path, or the electronic device can obtain the target text, target name, sample template, prompt template, and guide sentence from a database of a cloud server.
[0039] The above introduction to the method for obtaining the first prompt content is only an example, and the present application does not limit the method for obtaining the first prompt content. For example, the electronic device can also receive the target text input by the user as the first prompt content, or the electronic device can read the target text in the folder under the preset path as the first prompt content, or the electronic device can obtain the first prompt content from the database of the cloud server. Among them, the preset path can be customized, and the present application does not limit this.
[0040] For example, if the target text is a contract text and there are N sample templates, the information columns of the target name, contract text and N sample templates in the prompt template are as follows:
[0041] "You are now a contract review expert. You need to perform the following tasks step by step according to the contract text:
[0042] Task 1: Please answer the question "{target name}" by quoting the original text. Please ensure that your answer is directly quoted from the original text without any modification or interpretation.
[0043] Task 2: Based on the notification information extracted in Task 1, answer the following question: {target name}.
[0044] Example template:
[0045] ””'
[0046] Example 1
[0047] Example 2
[0048] …
[0049] Example N
[0050] ””'
[0051] Please output the results in the following format:
[0052] Task 1 answer: xxx
[0053] Task 2 answer:
[0054] -{target name}-:{target name}
[0055] If no relevant attributes can be extracted, use the "Unknown" answer.
[0056] Text: {Contract text}".
[0057] For example, if the target text is a contract text and the introductory sentence is "Let's think step by step", the information columns of the target name, contract text and introductory sentence "Let's think step by step" in the second prompt template are as follows:
[0058] "You are now a contract review expert. You need to perform the following tasks step by step according to the contract text:
[0059] Task 1: Please answer the question "{target name}" by quoting the original text. Please ensure that your answer is directly quoted from the original text without any modification or interpretation.
[0060] Task 2: Based on the notification information extracted in Task 1, answer the following questions: {target name}. Let's think step by step.
[0061] Please output the results in the following format:
[0062] -{target name}-:{target name}
[0063] If no relevant attributes can be extracted, use the Unknown answer.
[0064] Text: {Contract text}".
[0065] S12, inputting the first prompt content into the language model for first processing to obtain context information of the target name and a first data extraction result.
[0066] In at least one embodiment of the present application, the present application does not limit the type of language model. For example, the language model can be GPT4, ChatGLM, Qwen-14B, Baichuan-7B, Qwen-7B and other models.
[0067] In some embodiments of the present application, the electronic device inputs the first prompt content into the language model for a first processing to obtain context information of the target name and a first data extraction result, including: locating the position of the target name in the target text based on a semantic analysis of the target name and the target text, searching the target text for text information related to the target name based on the position of the target name, and determining the text information related to the target name as context information, and using natural language processing technology to extract data corresponding to the target name from the context information as the first data extraction result.
[0068] Among them, natural language processing technology can be keyword extraction, entity naming recognition, etc., and this application does not impose any restrictions on this.
[0069] In this embodiment, the location of the target name in the target text is located, and the text information related to the target name in the target text is searched as context information according to the location of the target name, which can reduce the confusion of the language model due to the similarity between the contents in the target text. Since the context information is the intermediate data generated by the language model after the target text is recognized and understood based on the target name, the context information can reflect the actual recognition and understanding of the content related to the target name in the target text by the language model.
[0070] In other embodiments of the present application, the electronic device inputs the first prompt content into the language model for first processing, and the method for obtaining the context information of the target name and the first data extraction result can refer to the description of the method for generating the second data extraction result in step S15 below.
[0071] S13: Determine whether there are errors in the context information and the first data extraction result according to the context information and the target text.
[0072] In some embodiments of the present application, the electronic device can determine whether there is a deviation or error in the actual recognition and understanding of the target text by the language model by comparing the context information with the target text, so as to accurately determine whether there is an error in the context information. Since the first data extraction result is generated based on the context information, if it is determined that there is an error in the context information, it can be determined that there is also an error in the first data extraction result. When it is determined that the context information is correct, it can be determined whether there is an error in the first data extraction result based on the text segment in the target text that includes the first data extraction result.
[0073] In some embodiments of the present application, if it is determined that the context information is correct and the first data extraction result has errors or if it is determined that both the context information and the first data extraction result have errors, steps S14 - S15 are executed.
[0074] In this embodiment, by comparing the context information with the target text, it is possible to determine whether the actual recognition and understanding of the target text by the language model is biased or wrong, so that it is possible to accurately determine whether the context information is wrong. Since the first data extraction result is extracted from the context information, it is possible to preliminarily determine whether the first data extraction result is wrong by judging the result of the context information.
[0075] S14, generating second prompt content based on the first prompt content, context information and preset correction information.
[0076] In some embodiments of the present application, the correction information is used to indicate that the context information and / or the first data extraction result are wrong. When it is determined that the context information is wrong, the correction information can be used to indicate that the target text does not include the context information or does not include part of the context information, and / or indicates that the data extraction result corresponding to the target name in the target text is not the first data extraction result, thereby achieving the technical effect of indicating that the context information and / or the first data extraction result are wrong.
[0077] The correction information can be customized, and this application does not limit this. For example, if the target text is a contract text, the correction information can be "It is known that the contract text does not include XXXX, please answer again." Among them, XXXX can be all the information in the context information, or it can be part of the information in the context information.
[0078] Exemplarily, if the target text is a contract text, and it is determined that the context information and the first data extraction result have errors, the second prompt content may be:
[0079] "You are now a contract review expert. You need to perform the following tasks step by step according to the contract text:
[0080] Task 1: Please quote the original text to answer the question "{target name}". Please make sure that your answer directly quotes the original text without any modification or explanation. It is known that the contract text does not include {context information}, and the data extraction result corresponding to {target name} in the contract text is not {first data extraction result}.
[0081] Task 2: Based on the notification information extracted in Task 1, please re-answer the following question: {target name}.
[0082] Example template:
[0083] ””'
[0084] Example 1
[0085] Example 2
[0086] …
[0087] Example N
[0088] ””'
[0089] Please output the results in the following format:
[0090] Task 1 answer: xxx
[0091] Task 2 answer:
[0092] -{target name}-:{target name}
[0093] If no relevant attributes can be extracted, use the "Unknown" answer.
[0094] Text: {Contract text}".
[0095] In this embodiment, the correction information in the second prompt content can indicate that there are errors in the context information and / or errors in the first data extraction result, thereby enabling correction of the language model's recognition and understanding capabilities for the target text.
[0096] S15, inputting the second prompt content into the language model for second processing to obtain a second data extraction result.
[0097] In some embodiments of the present application, since the second prompt content is generated by the first prompt content, the second prompt content includes a target name, a target text, and correction information. The electronic device inputs the second prompt content into the language model for second processing, and obtains a second data extraction result including: determining multiple reasoning paths corresponding to the second prompt content according to the target name, the target text, and the correction information, and determining multiple second data extraction results according to the multiple reasoning paths.
[0098] Each of the inference paths includes a complete inference process of the language model, and each inference path may include a second data extraction result. Multiple second data extraction results may be extracted from the multiple inference paths through keyword extraction technology. The language model for extracting the second prompt content may be the same as or different from the language model for extracting the first prompt content, and this application does not limit this.
[0099] Each reasoning path includes multiple text data in the target text. The multiple text data in each reasoning path can be obtained by sampling multiple probability distributions. Each text data in the target text corresponds to a probability value in each of the probability distributions, and the probability value can reflect the probability (possibility) of the corresponding text data being selected during the sampling process. The multiple probability distributions are generated in sequence. The first probability distribution in the multiple probability distributions can be obtained by forward calculation of the target text, wherein the forward calculation of the target text can be based on the semantic understanding of the correction information, the target text and the target name. If the second prompt content also includes an example template or a guide sentence, the forward calculation of the target text can be based on the semantic understanding of the example template or the guide sentence, the correction information, the target text and the target name. The i-th probability distribution in the multiple probability distributions is generated by sampling the text data obtained by sampling the i-1th probability distribution, where i is an integer greater than or equal to 2. By sampling each of the probability distributions, the text data obtained by sampling each of the probability distributions can be obtained. The multiple text data obtained by sampling the multiple probability distributions can constitute an reasoning path. The multiple probability distributions are sampled multiple times to obtain the multiple reasoning paths. Since the multiple probability distributions are generated in sequence, and after each probability distribution is generated, each probability distribution is sampled to obtain a text data, the arrangement order between the multiple text data in each reasoning path can be determined by the generation order of the multiple probability distributions.
[0100] The type of sampling may be random sampling. The process of randomly sampling each of the probability distributions may be a process of generating a random number, and determining the text data corresponding to the random number from all the text data in the target text according to the probability value corresponding to each text data in the target text in each of the probability distributions, wherein the present application does not limit the method for generating random numbers. For example, a random function may be used to generate random numbers.
[0101] Exemplarily, randomly sampling each of the probability distributions to obtain text data obtained by randomly sampling each of the probability distributions includes: generating random numbers, sorting the probability values corresponding to each text data in the target text in each of the probability distributions, and determining the probability interval of the text data corresponding to each probability value according to each sorted probability value, wherein, among the probability values arranged from low to high, the probability interval of the text data corresponding to the first probability value is [0, first probability value), and the probability interval of the text data corresponding to each probability value between the first probability value and the last probability value is [the upper limit of the probability interval of the text data corresponding to the previous probability value of each probability value, and the sum of the upper limits of the probability interval of the text data corresponding to each probability value and the previous probability value), wherein the probability interval of the text data corresponding to the last probability value is [the upper limit of the probability interval of the text data corresponding to the previous probability value of the last probability value, 1], and the text data corresponding to the probability interval in which the random number is located is used as the text data obtained by randomly sampling each of the probability distributions.
[0102] For example, if in a probability distribution, the probability corresponding to text data A is 0.1, the probability corresponding to text data B is 0.2, and the probability corresponding to text data C is 0.7, then the probability interval corresponding to text data A is [0, 0.1), the probability interval corresponding to text data B is [0.1, 0.3), where 0.3 = 0.1 + 0.2, and the probability interval corresponding to text data C is [0.3, 1]. If the random number is 0.4, then the probability interval where the random number is 0.4 is the probability interval corresponding to text data C is [0.3, 1], and text data C can be used as data obtained by random sampling of the probability distribution.
[0103] The process of determining multiple reasoning paths includes: performing forward calculations such as nonlinear transformation on the target name, target text and correction information to obtain a first hidden vector, performing full connection processing on the first hidden vector to obtain a first score vector (logits), the first score vector includes the original score of each text data in the target text, using a normalization function to convert the first hidden vector into a first probability distribution, performing random sampling on the first probability distribution to obtain text data obtained by randomly sampling the first probability distribution, performing forward calculation based on the text data obtained by sampling the first probability distribution and the first hidden vector to obtain a second hidden vector, performing full connection processing on the second hidden vector to obtain the first hidden vector. Two score vectors (logits), the second score vector includes the original score of each text data in the target text, and the normalization function is used to convert the second hidden vector into a second probability distribution. By randomly sampling the second probability distribution, the text data obtained by randomly sampling the second probability distribution is obtained. By analogy, the above forward calculation-full connection processing-conversion-random sampling process is repeated until the length of the reasoning path composed of multiple text data obtained by random sampling reaches the preset length value or the sampled text data is the termination symbol, and the above forward calculation-full connection processing-conversion-random sampling process is stopped. Multiple probability distributions and the reasoning path corresponding to one random sampling can be obtained. The normalization function can be softmax, sigmoid and other functions. The preset length value and termination symbol can be customized. The termination symbol can be <eos>, [EOS], [SEP], etc., and this application does not limit this. The above-mentioned conditions for stopping the execution of the process of forward calculation-full connection processing-conversion-random sampling are only examples and are not limited to this in actual applications.
[0104] In the process of random sampling of each of the probability distributions, the shape of each of the probability distributions can be adjusted using a preset temperature parameter to control the randomness of the random sampling. The temperature parameter is a parameter used to adjust the shape of the probability distribution to control the randomness of the random sampling. The temperature parameter can be customized, and this application does not limit this. For example, the temperature parameter can be 0.8. Each of the probability distributions can be adjusted using the temperature parameter to obtain an adjusted probability distribution, thereby achieving the effect of controlling the randomness of the random sampling. For example, if the temperature parameter is larger, the shape of the adjusted probability distribution is flatter, and the randomness of the random sampling is higher. Exemplarily, each of the probability distributions can refer to formula (1).
[0105] By adjusting formula (1) using the temperature parameter T, the adjusted probability distribution can be obtained by referring to formula (2).
[0106]
[0107]
[0108] Among them, p1(y i ) represents the probability value corresponding to the i-th text data of the target text in each of the probability distributions, z i represents the original score of the i-th text data in each of the probability distributions, z j represents the original score of the jth text data in each of the probability distributions, m represents the number of text data in the target text, p2(y i ) represents the adjusted probability value corresponding to the i-th text data, and T represents the temperature parameter.
[0109] The number of random samplings can be customized, and this application does not limit this. For example, the number of random samplings can be 5 times or 7 times. The number of multiple second data extraction results can be determined by the number of random samplings. For example, if the number of random samplings is 5 times, the number of multiple second data extraction results is 5, and if the number of random samplings is 7 times, the number of multiple second data extraction results is 7.
[0110] In some embodiments of the present application, if there are multiple target names, each target name has multiple corresponding second data extraction results. For example, if the target name is "Contract Signing Location", and the number of random sampling of the target name "Contract Signing Location" is 5 times, then the target name "Contract Signing Location" has 5 corresponding second data extraction results, and the 5 second data extraction results can be "City A", "City A", "City B", "City B", "City A".
[0111] In some embodiments of the present application, the plurality of second data extraction results include extraction results of at least one category. In order to improve the accuracy of data extraction, the target data extraction result corresponding to the target name can be determined from the plurality of second data extraction results according to the number of extraction results of each category in the plurality of second data extraction results. Exemplarily, the largest number of data extraction results can be selected from the plurality of second data extraction results as the target data extraction result of the target name. For example, following the above embodiment, if the five second data extraction results of the target name "Contract Signing Location" can be "City A", "City A", "City B", "City B", "City A", among the five second data extraction results, there are two types of data extraction results of "City A" and "City B", among which the number of "City A" is 3, the number of "City B" is 2, and the number of "City A" is more than the number of "City B", so it can be determined that the target data extraction result of the target name is "City A".
[0112] In this embodiment, since each reasoning path includes the complete reasoning process of the language model from the target name to the answer / reasoning result, the corresponding second data extraction result can be accurately extracted from the target text through each reasoning path. By generating multiple reasoning paths to determine multiple second data extraction results, the diversity of the data extraction results can be increased, and the problem of inaccurate data extraction results caused by only selecting the path with the highest probability (a single reasoning path) during decoding can be avoided, thereby improving the accuracy and representativeness of multiple second data extraction results. By selecting the second data extraction results with the largest number (similar to "majority voting") as the target data extraction result, the accuracy of the data extraction results can be ensured.
[0113] In other embodiments of the present application, if the number of each category of data extraction results in multiple second data extraction results is the same, the second prompt content can be input into the language model for second processing until there are different numbers of multiple categories of data extraction results in the updated multiple second data extraction results.
[0114] For example, Figure 2 FIG. 1 is a flow chart of data extraction provided by an embodiment of the present application. Figure 2 In the method, a first prompt content including a target name and a target text is input into a language model for a first processing to obtain context information and a first data extraction result, and whether the context information and the first data extraction result have errors is determined based on the target text and the context information. If it is determined that the context information and / or the first data extraction result have errors, a second prompt content is generated based on the correction information, the context information and the first prompt content, and the second prompt content is input into the language model for a second processing to obtain multiple second data extraction results, and a target data extraction result is selected from the multiple second data extraction results by majority voting.
[0115] In the data extraction method of the present embodiment, the context information is the intermediate data generated after the language model recognizes and understands the target text, so the context information can reflect the actual recognition and understanding of the target text by the language model. The first data extraction result is the key information or data fragment extracted by the language model from the context information, so by comparing the context information with the target text, it can be determined whether the actual recognition and understanding of the target text by the language model is biased or wrong, so that it can be accurately determined whether the context information is wrong. Since the first data extraction result is generated based on the context information, when it is determined that the context information has an error, it can be determined that the first data extraction result also has an error, and the correction information can be used to prompt that the context information and the first data extraction result have an error. When it is determined that the context information and / or the first data extraction result are wrong, the correction information can be used to prompt that the first data extraction result has an error. Therefore, based on the first prompt content, the context information and the correction information, the second prompt content is generated, and the second prompt content is input into the language model for the second processing, which can realize the correction of the recognition and understanding ability of the language model for the target text, thereby improving the accuracy of the second data extraction result. Determining the target data extraction result based on the accurate second data extraction result can ensure the accuracy of the data extraction result.
[0116] In at least one embodiment of the present application, Figure 3 FIG. 1 is a flowchart of a method for determining a first data extraction result provided by an embodiment of the present application, comprising the following steps:
[0117] S131, segment the target text to obtain multiple text segments.
[0118] In some embodiments of the present application, the electronic device can segment the target text using various methods, and the present application does not limit the segmentation method. For example, the electronic device can segment the target text according to the line break separator, and each line in the target text is a text segment, thereby obtaining multiple text segments.
[0119] In this embodiment, a plurality of text segments are obtained by segmenting the target text, so as to determine the text segment where the first data extraction result is located and the text segment most similar to the context information.
[0120] S132: judging whether there is any error in the context information according to the similarity between the context information and each of the text segments.
[0121] In some embodiments of the present application, the context information has a similarity with each text fragment, so multiple text fragments can obtain multiple similarities. The electronic device can determine the target similarity based on the multiple similarities and compare the target with a preset threshold to determine whether there is an error in the context information.
[0122] In this embodiment, when it is determined that the context information is erroneous, step S133 is executed, or when it is determined that the context information is correct, step S134 is executed.
[0123] S133, determining that there is an error in the first data extraction result.
[0124] In this embodiment, since the first data extraction result is extracted from the context information, if it is determined that the context information is erroneous, the first data extraction result extracted from the erroneous context information is likely to be erroneous, and therefore it can be determined that the first data extraction result is erroneous.
[0125] S134, determining whether there is an error in the first data extraction result according to the similarity and the text segment including the first data extraction result.
[0126] In some embodiments of the present application, even if the context information is correct, when there are multiple similar pieces of information in the context information, the language model may be confused during identification and extraction, resulting in an error in the first data extraction result. For example, if the target text is a contract text, and the target name is "Party A's invoicing information address", and there are data corresponding to both "Party A's contact address" and "Party A's invoicing information address" in the contract text, the language model will be confused and use the data corresponding to "Party A's contact address" in the contract text as the first data extraction result, resulting in an error in the first data extraction result.
[0127] Based on the above problems, the text segment corresponding to the largest similarity among multiple similarities and the text segment where the first data extraction result is located can be determined. By comparing whether the text segment corresponding to the largest similarity is the same as the text segment where the first data extraction result is located, it can be further determined whether there is an error in the first data extraction result.
[0128] In this embodiment, when it is determined that the context information is correct, the accuracy of the judgment of the first data extraction result can be ensured by comparing the text segment corresponding to the maximum similarity with the text segment where the first data extraction result is located.
[0129] In at least one embodiment of the present application, Figure 4 FIG. 1 is a flowchart of a method for determining context information provided by an embodiment of the present application, comprising the following steps:
[0130] S1321, vectorize the context information and each of the text segments to obtain a context vector corresponding to the context information and a text vector corresponding to each of the text segments.
[0131] In some embodiments of the present application, the present application does not limit the context information and the vectorization method for each text segment. For example, the electronic device can use a general embedding model (BGE-Chinese-Base) or a general text embedding (General Text Embedding, GTE) model and other pre-trained vector models to vectorize the context information and each text segment. Among them, the general embedding model can use word embedding technology to convert the context information and each text segment into corresponding context vectors and text vectors, respectively, wherein the method of using word embedding technology to vectorize the context information and each text segment can refer to the method of mapping the context information and each word in each text segment to a real vector in a high-dimensional space in the related art, and this application will not describe it in detail.
[0132] S1322, determining the similarity between the context vector and each of the text vectors to obtain multiple similarities.
[0133] In some embodiments of the present application, the present application does not limit the method for calculating the similarity. For example, the electronic device can calculate the distance between the context vector and each text vector, and determine the similarity between the context vector and the corresponding text vector based on the distance. Among them, the distance can be Euclidean distance, Mahalanobis distance, Manhattan distance, Chebyshev distance, etc. The smaller the distance between the context vector and the text vector, the greater the similarity between the context vector and the text vector.
[0134] In this embodiment, the similarity between the context vector of the context information and the text vector corresponding to each text segment is calculated so as to select a target similarity from multiple similarities below.
[0135] S1323: Determine whether the context information has any error according to the multiple similarities.
[0136] In some embodiments of the present application, a target similarity can be selected from multiple similarities, and the target similarity can be compared with a preset threshold value to determine whether the context information is wrong. Among them, the target similarity can be the largest similarity or the smallest similarity selected from multiple similarities. Alternatively, the target similarity can be obtained by calculating multiple similarities. For example, the electronic device can obtain the target similarity by performing a weighted operation on multiple similarities. The weight of the weighted operation can be customized, and this application does not limit this. The preset threshold can be customized, and this application does not limit this. For example, the preset threshold can be 0.75.
[0137] In some embodiments of the present application, if the target similarity is greater than a preset threshold, the electronic device determines that the context information is correct, or if the target similarity is less than or equal to the preset threshold, the electronic device determines that there is an error in the context information.
[0138] In this embodiment, when the target similarity is greater than the preset threshold, it means that the similarity between the context information and the target text is high, and the language model's actual recognition and understanding of the target text is accurate, so it can be determined that the context information is correct. When the target similarity is less than or equal to the preset threshold, it means that the similarity between the context information and the target text is low, and the language model's actual recognition and understanding of the target text has deviations or errors, so it can be determined that the context information has errors.
[0139] In some embodiments of the present application, even if the context information is correct, the first data extraction result may be wrong when there are multiple similar information in the context information. Figure 5 FIG. 1 is a flowchart of a method for determining a first data extraction result provided in some other embodiments of the present application, comprising the following steps:
[0140] S1341, determining whether the text segment including the first data extraction result is a text segment corresponding to the target similarity.
[0141] In this embodiment, if the text segment including the first data extraction result is a text segment corresponding to the target similarity, step S1342 is executed; or, if the text segment including the first data extraction result is not a text segment corresponding to the target similarity, step S1343 is executed.
[0142] S1342, determine whether the first data extraction result is correct.
[0143] In this embodiment, if the text segment of the first data extraction result is the text segment corresponding to the target similarity, it means that the first data extraction result is extracted by the language model from the text segment most similar to the context information. When extracting data from the context information, the language model does not have any understanding confusion problems. Therefore, it is determined that the first data extraction result is correct, which can ensure the accuracy of the judgment of the first data extraction result.
[0144] S1343, determining that there is an error in the first data extraction result.
[0145] In this embodiment, if the text segment of the first data extraction result is not the text segment corresponding to the target similarity, it means that the first data extraction result is extracted by the language model from the text segment most similar to the context information. When extracting data from the context information, the language model has a high probability of confusion in understanding. Therefore, it is determined that there is an error in the first data extraction result, which can ensure the accuracy of the judgment of the first data extraction result.
[0146] Please refer to Figure 6 , Figure 6 1 is a schematic diagram of the structure of a data extraction device provided in an embodiment of the present application, which can implement the details of the data extraction method in the above embodiment and achieve the same effect. Figure 6 As shown, the data extraction device 60 can be operated on an electronic device having a data extraction function, and the device 60 includes:
[0147] The determination module 601 is used to determine the first prompt content, where the first prompt content is used to prompt the data extraction result of extracting the target name from the target text, and the first prompt content includes the target text and the target name.
[0148] The input module 602 is used to input the first prompt content into the language model for first processing to obtain context information of the target name and a first data extraction result.
[0149] The determination module 601 is further used to determine whether there are errors in the context information and the first data extraction result according to the context information and the target text.
[0150] In some embodiments of the present application, the determination module 601 is also used to segment the target text to obtain multiple text segments, and determine whether the context information has errors based on the similarity between the context information and each of the text segments; if it is determined that the context information has errors, it is determined that the first data extraction result has errors; if it is determined that the context information is correct, it is determined whether the first data extraction result has errors based on the similarity and the text segments including the first data extraction result.
[0151] In some embodiments of the present application, the determination module 601 is also used to perform vectorization processing on the context information and each of the text fragments, obtain a context vector corresponding to the context information and a text vector corresponding to each of the text fragments, determine the similarity between the context vector and each text vector, obtain multiple similarities, and determine whether there is an error in the context information based on the multiple similarities.
[0152] In some embodiments of the present application, the determination module 601 is also used to determine that the first data extraction result is correct if the text segment including the first data extraction result is a text segment corresponding to the target similarity, and the target similarity is the maximum similarity among the multiple similarities; if the text segment including the first data extraction result is not a text segment corresponding to the target similarity, determine that there is an error in the first data extraction result.
[0153] A generating module 603 is used to generate a second prompt content based on the first prompt content, the context information and preset correction information if it is determined that the context information and / or the first data extraction result has an error, wherein the correction information is used to indicate that the context information and / or the first data extraction result has an error;
[0154] The input module 602 is used to input the second prompt content into the language model for second processing to obtain a second data extraction result.
[0155] In some embodiments of the present application, the second prompt content includes a target name, a target text, and correction information. The input module 602 is also used to determine multiple reasoning paths corresponding to the second prompt content based on the target name, the target text, and the correction information, and determine multiple second data extraction results based on the multiple reasoning paths.
[0156] In some embodiments of the present application, each of the reasoning paths includes multiple text data in the target text, the multiple text data have a corresponding arrangement order, and the multiple text data of each of the reasoning paths include one second data extraction result.
[0157] In some embodiments of the present application, the multiple second data extraction results include extraction results of at least one category, and the input module 602 is also used to determine the target data extraction result corresponding to the target name from the multiple second data extraction results based on the number of extraction results of each category in the multiple second data extraction results.
[0158] The determination module 601 is further configured to determine a data extraction result according to the second data extraction result.
[0159] See also Figure 7 , Figure 7 It is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application.
[0160] exist Figure 7 In the embodiment, the electronic device 70 includes but is not limited to: a radio frequency unit 701, a network module 702, an audio output unit 703, an input unit 704, a sensor 705, a display unit 706, a user input unit 707, an interface unit 708, a memory 709, a processor 710, and a power supply 711. Those skilled in the art can understand that Figure 7 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present application, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a server, a wearable device, and a pedometer.
[0161] Among them, the processor 710 is used to: determine a first prompt content, the first prompt content is used to prompt the extraction of target name data from the target text, and the first prompt content includes the target text and the target name; input the first prompt content into the language model for a first processing to obtain context information of the target name and a first data extraction result; determine whether there are errors in the context information and the first data extraction result based on the context information and the target text; if it is determined that there are errors in the context information and / or the first data extraction result, generate a second prompt content based on the first prompt content, the context information and preset correction information, and the correction information is used to prompt that the context information and / or the first data extraction result are wrong; input the second prompt content into the language model for a second processing to obtain a second data extraction result.
[0162] The embodiment of the present application also has the same Figure 1-Figure 5 The same beneficial technical effects as those of the illustrated embodiments are not described in detail here.
[0163] It should be understood that in the embodiment of the present application, the radio frequency unit 701 can be used for receiving and sending signals during information transmission or calls. Specifically, after receiving downlink data from the base station, it is sent to the processor 710 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 701 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 701 can also communicate with the network and other devices through a wireless communication system.
[0164] The electronic device provides users with wireless broadband Internet access through the network module 702, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0165] The audio output unit 703 can convert the audio data received by the RF unit 701 or the network module 702 or stored in the memory 709 into an audio signal and output it as sound. Moreover, the audio output unit 703 can also provide audio output related to a specific function performed by the electronic device 70 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 703 includes a speaker, a buzzer, a receiver, etc.
[0166] The input unit 704 is used to receive audio or video signals. The input unit 704 may include a graphics processor (GPU) 7041 and a microphone 7042, and the graphics processor 7041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 706. The image frame processed by the graphics processor 7041 can be stored in the memory 709 (or other storage medium) or sent via the radio frequency unit 701 or the network module 702. The microphone 7042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 701 in the case of a telephone call mode.
[0167] The electronic device 70 also includes at least one sensor 705, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 7061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 7061 and / or the backlight when the electronic device 70 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 705 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0168] The display unit 706 is used to display information input by the user or information provided to the user. The display unit 706 may include a display panel 7061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0169] The user input unit 707 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 707 includes a touch panel 7071 and other input devices 7072. The touch panel 7071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 7071 or near the touch panel 7071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 7071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact point coordinates, and then sends it to the processor 710, receives the command sent by the processor 710 and executes it. In addition, the touch panel 7071 can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 7071, the user input unit 707 may also include other input devices 7072. Specifically, other input devices 7072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail here.
[0170] Furthermore, the touch panel 7071 may be overlaid on the display panel 7061. When the touch panel 7071 detects a touch operation on or near it, it transmits the information to the processor 710 to determine the type of the touch event. Then, the processor 710 provides a corresponding visual output on the display panel 7061 according to the type of the touch event. Figure 7 In the figure, the touch panel 7071 and the display panel 7061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 7071 and the display panel 7061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0171] The interface unit 708 is an interface for connecting an external device to the electronic device 70. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 708 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 70 or may be used to transmit data between the electronic device 70 and an external device.
[0172] The memory 709 can be used to store software programs and various data. The memory 709 can mainly include a program storage area and a data storage area, wherein the program storage area can store at least one application 7091 required for a function (such as a sound playback function, an image playback function, etc.), an operating system 7092, etc.; the data storage area can store data created according to the use of the electronic device 70 (such as audio data, a phone book, etc.), etc. In addition, the memory 709 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0173] The processor 710 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device 70. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 709, and calling data stored in the memory 709, so as to monitor the electronic device as a whole. The processor 710 may include one or more processing units; preferably, the processor 710 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 710.
[0174] The electronic device 70 may also include a power supply 711 (such as a battery) for supplying power to each component. Preferably, the power supply 711 may be logically connected to the processor 710 via a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0175] Preferably, an embodiment of the present application also provides an electronic device, including a memory 709 and a processor 710, a computer program stored in the memory 709 and executable on the processor 710, and the computer program, when executed by the processor 710, implements the various processes of the above-mentioned data extraction method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0176] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 70. In other embodiments of the present application, the electronic device 7 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0177] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned data extraction method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0178] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the data extraction method described above in the embodiment of the present application.
[0179] It should be noted that, in this article, the term "includes", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0180] 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 application, 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 a terminal (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 application.
[0181] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.< / eos>
Claims
1. A data extraction method, characterized in that: The method comprises: Determine a first prompt content, the first prompt content is used to prompt to extract data of a target name from a target text, the first prompt content includes the target text and the target name; Inputting the first prompt content into a language model for first processing to obtain context information of the target name and a first data extraction result; Determining whether there are errors in the context information and the first data extraction result according to the context information and the target text; If it is determined that the context information and / or the first data extraction result has an error, generating a second prompt content based on the first prompt content, the context information and preset correction information, wherein the correction information is used to prompt that the context information and / or the first data extraction result has an error; The second prompt content is input into the language model for second processing to obtain a second data extraction result.
2. The data extraction method according to claim 1, characterized in that: The determining, according to the context information and the target text, whether there are errors in the context information and the first data extraction result comprises: Segmenting the target text to obtain multiple text segments; Determining whether the context information has an error based on the similarity between the context information and each of the text segments; If it is determined that the context information has an error, determining that the first data extraction result has an error; If it is determined that the context information is correct, it is determined whether the first data extraction result has an error based on the similarity and the text segment including the first data extraction result.
3. The data extraction method according to claim 2, characterized in that: The determining, according to the similarity between the context information and each of the text segments, whether the context information has an error comprises: Performing vectorization processing on the context information and each of the text segments to obtain a context vector corresponding to the context information and a text vector corresponding to each of the text segments; Determine the similarity between the context vector and each of the text vectors to obtain multiple similarities; It is determined whether the context information has any error according to the multiple similarities.
4. The data extraction method according to claim 3, characterized in that: The determining whether the first data extraction result has an error according to the similarity and the text segment including the first data extraction result comprises: If the text segment including the first data extraction result is a text segment corresponding to the target similarity, determining that the first data extraction result is correct, and the target similarity is the maximum similarity among the multiple similarities; If the text segment including the first data extraction result is not the text segment corresponding to the target similarity, it is determined that there is an error in the first data extraction result.
5. The data extraction method according to claim 1, characterized in that: The second prompt content includes the target name, the target text and the correction information; the second prompt content is input into the language model for second processing to obtain the second data extraction result, including: Determining, according to the target name, the target text, and the correction information, a plurality of reasoning paths corresponding to the second prompt content; A plurality of second data extraction results are determined according to the plurality of reasoning paths.
6. The data extraction method according to claim 5, characterized in that: Each of the reasoning paths includes a plurality of text data in the target text, the plurality of text data have a corresponding arrangement order, and the plurality of text data in each of the reasoning paths includes one second data extraction result.
7. A data extraction device, characterized in that: The data extraction device comprises: A determination module, used for determining a first prompt content, wherein the first prompt content is used for prompting to extract data of a target name from a target text, and the first prompt content includes the target text and the target name; An input module, used for inputting the first prompt content into a language model for first processing to obtain context information of the target name and a first data extraction result; The determination module is further used to determine whether there are errors in the context information and the first data extraction result according to the context information and the target text; a generating module, configured to generate, if it is determined that the context information and / or the first data extraction result has an error, a second prompt content based on the first prompt content, the context information and preset correction information, wherein the correction information is used to indicate that the context information and / or the first data extraction result has an error; The input module is used to input the second prompt content into the language model for second processing to obtain a second data extraction result.
8. An electronic device, characterized in that: The electronic device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the data extraction method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data extraction method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the data extraction method according to any one of claims 1 to 6 is implemented.
