Data extraction method and device, electronic equipment, storage medium and program product
By providing a variety of prompt content and using weak language models for data extraction, the extraction bias and limitations caused by a single prompt content are solved, the accuracy and diversity of data extraction are improved, and computing resources and costs are saved.
Patent Information
- Application Number
- CN202411045831.0
- 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
When using language models for data extraction in the prior art, a single prompt content leads to extraction deviations and limitations, making it difficult to accurately guide the language model, resulting in inaccurate extraction results.
By providing the first prompt content and the second prompt content, including the example template, the target text and the target name, data extraction is performed using a weak language model, multiple extraction results are obtained, and the accuracy of data extraction is improved by combining the diversity of the extraction results.
Through different angles and levels, the extraction bias and limitations caused by a single prompt content are solved, the accuracy and diversity of data extraction are improved, and computing resources and costs are saved.
Smart Images

Figure CN119149660A_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 text data, 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, the method comprising:
[0005] Determine prompt content, the prompt content is used to prompt the extraction of target name data from the target text, the prompt content includes first prompt content and second prompt content, the first prompt content includes an example template, the target text and the target name, and the second prompt content includes the target text and the target name;
[0006] Inputting the prompt content into a first language model to perform a first data extraction, and obtaining a plurality of first extraction results corresponding to the first prompt content and a plurality of second extraction results corresponding to the second prompt content;
[0007] Based on the plurality of first extraction results and the plurality of second extraction results, a first data extraction result is determined.
[0008] It can be seen that in the embodiment of the present application, since the prompt content includes the first prompt content and the second prompt content, different prompt contents can enable the first language model to reveal the characteristics of the data from different angles or levels, thereby solving the problem of extraction deviation and limitation caused by a single prompt content, thereby accurately extracting data from the target text. By obtaining multiple first extraction results and multiple second extraction results, the diversity of the extraction results can be increased, further improving the accuracy of data extraction.
[0009] On the other hand, the present application provides a data extraction device, the data extraction device comprising:
[0010] A determination module, used to determine prompt content, the prompt content is used to prompt the extraction of target name data from the target text, the prompt content includes a first prompt content and a second prompt content, the first prompt content includes an example template, the target text and the target name, and the second prompt content includes the target text and the target name;
[0011] An input module, used for inputting the prompt content into a first language model to perform a first data extraction, and obtaining a plurality of first extraction results corresponding to the first prompt content and a plurality of second extraction results corresponding to the second prompt content;
[0012] The determination module is further used to determine the first data extraction result based on the multiple first extraction results and the multiple second extraction results.
[0013] 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.
[0014] 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.
[0015] 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
[0016] 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.
[0017] Figure 1 It is a flow chart of a data extraction method provided in one embodiment of the present application.
[0018] Figure 2 It is a flowchart of data extraction provided by an embodiment of the present application.
[0019] Figure 3 It is a flowchart of a method for obtaining prompt content provided in one embodiment of the present application.
[0020] Figure 4 This is a schematic diagram of generating the first prompt content provided in an embodiment of the present application.
[0021] Figure 5 It is a schematic diagram of generating the second prompt content provided in an embodiment of the present application.
[0022] Figure 6 It is a flowchart of a method for obtaining an example template provided in an embodiment of the present application.
[0023] Figure 7 It is a structural schematic diagram of a data extraction device provided in one embodiment of the present application.
[0024] Figure 8 It is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0025] 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.
[0026] 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.
[0027] 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.
[0028] The following is an explanation of some of the terms that appear in the embodiments of this application:
[0029] 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.
[0030] 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.
[0031] 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 large 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.
[0032] 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.
[0033] Weak language model / strong language model: There are significant differences in performance and resource requirements between weak and strong language models. The number of parameters of a language model is positively correlated with its reasoning ability. The more model parameters a language model has, the stronger its reasoning ability tends to be. However, this enhanced reasoning ability is also accompanied by higher resource requirements, especially computing resources such as video memory.
[0034] Weak language models refer to those models with a relatively small number of parameters, such as Baichuan-7B and Qwen-7B. These models are more economical in resource consumption, making weak language models more practical in scenarios with limited resources. In contrast, strong language models refer to those models with a large number of parameters, such as Gemini Ultra and GPT-4. With their large parameter scale, strong language models are able to demonstrate strong reasoning capabilities, allowing them to handle more complex and sophisticated tasks. However, this powerful reasoning capability also brings high reasoning costs, and the resource consumption of strong language models is usually several times that of weak language models.
[0035] When selecting a language model, in order to ensure effective use of resources and reasonable cost control, it is necessary to comprehensively consider the model's performance, resource consumption, and the needs of actual application scenarios.
[0036] For example, strong language models (such as Gemini Ultra and GPT-4, etc.), with their large parameter scale and excellent reasoning ability, show unparalleled advantages in handling complex tasks. However, this advantage is often accompanied by high reasoning costs. These models usually require a lot of computing resources and video memory to support their operation, which makes strong language models less practical in scenarios with limited resources. Weak language models (such as Baichuan-7B and Qwen-7B, etc.), although they have a relatively small number of parameters, can still provide sufficient performance in many practical application scenarios. These models are more economical in resource consumption, making weak language models an ideal choice for scenarios with limited resources.
[0037] Related technologies often rely on greedy decoding strategies when using language models for data extraction. The greedy decoding strategy only selects the path with the highest probability at each decoding step, ignoring the changes and impacts that may be brought about by subsequent steps. This short-sighted decision-making method can easily cause the language model to fall into the dilemma of local optimal solutions and fail to effectively explore the global optimal solution, resulting in inaccurate extraction results.
[0038] In addition, the relevant technology only relies on a single prompt template / prompt content for data extraction. Since a single prompt template / prompt content is difficult to accurately guide the language model for data extraction, it is easy to cause extraction bias and limitations, resulting in inaccurate extraction results.
[0039] In order to solve the above technical problems, the embodiments of the present application provide a data extraction method, which can improve 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.
[0040] 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.
[0041] like Figure 1 FIG. 1 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 is applied to electronic devices.
[0042] S11, determining prompt content, the prompt content is used to prompt the extraction of target name data from the target text, and the prompt content includes a first prompt content and a second prompt content.
[0043] In some embodiments of the present application, the prompt content is used to provide contextual information or guidance for the language model so that the language model can better understand the input target text and accurately identify the data of the target name. The first prompt content includes an example template, a target text and a target name, wherein the example template is used to guide the first language model to think, reason and provide a reference for reasoning for the first language model. The first prompt content is equivalent to a small number of sample thinking chains Few-Shot-COT. The second prompt content includes the target text and the target name, and may also include a guide sentence, wherein the guide sentence is used to guide the first language model to think step by step, list key information and answer questions in a logical order. The guide sentence can be customized, and this application does not limit this. For example, the guide sentence can be "Let's thinkstep by step". The second prompt content is equivalent to a zero-sample thinking chain Zero-Shot-COT. The above-mentioned first prompt content and second prompt content are only examples, and this application does not limit the number and type of prompt content.
[0044] The target text is the text data to be extracted. The target text can be any type of text data, and this application does not limit the type of the target text. For example, the target text can be a contract text, legal document, news report, academic paper, web page content, email, chat record, medical report, patent document, product description, user review, etc.
[0045] 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.
[0046] In some embodiments of the present application, the electronic device can receive text data input by the user as prompt content, or the electronic device can read text data in a folder under a preset path as prompt content, or the electronic device can obtain prompt content from a database of a cloud server. The present application does not limit the method for obtaining the prompt content.
[0047] S12, inputting the prompt content into the first language model to perform first data extraction, and obtaining a plurality of first extraction results corresponding to the first prompt content and a plurality of second extraction results corresponding to the second prompt content.
[0048] In at least one embodiment of the present application, the plurality of first extraction results include at least one first category extraction result, and the plurality of second extraction results include at least one second category extraction result. In order to ensure effective use of resources and reasonable control of costs, a language model with relatively few model parameters (weak language model) can be used for data extraction first, so the first language model can be a model with relatively few model parameters, for example, the first language model can be Baichuan-7B or Qwen-7B, etc.
[0049] Exemplarily, the electronic device inputs the prompt content into the first language model to perform a first data extraction, and obtains multiple first extraction results corresponding to the first prompt content, including: determining multiple first reasoning paths corresponding to the first prompt content according to the target name, target text and example template, and determining the multiple first extraction results according to the multiple first reasoning paths.
[0050] Each first reasoning path includes a complete reasoning process of a language model, and each first reasoning path may include a first extraction result. The multiple first extraction results may be extracted from the multiple first reasoning paths through keyword extraction technology.
[0051] Each first reasoning path includes multiple text data in the target text. The multiple text data in each first reasoning path can be obtained by sampling multiple first probability distributions. Each text data in the target text corresponds to a first probability value in each of the first probability distributions. The first probability value can reflect the probability (possibility) of the corresponding text data being selected during the sampling process. The multiple first probability distributions are generated in sequence. The first first probability distribution in the multiple first 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 example template, the target text and the target name. The i-th first probability distribution in the multiple first probability distributions is generated by sampling the text data obtained by sampling the i-1-th first probability distribution, where i is an integer greater than or equal to 2. By sampling each of the first probability distributions, the text data obtained by sampling each of the first probability distributions can be obtained. The multiple text data obtained by sampling the multiple first probability distributions can constitute a first reasoning path. The multiple first probability distributions are sampled multiple times to obtain the multiple first reasoning paths. Since the multiple first probability distributions are generated in sequence, and after each first probability distribution is generated, each first probability distribution is sampled to obtain a text data, the arrangement order between the multiple text data in each first reasoning path can be determined by the generation order of the multiple first probability distributions.
[0052] The type of sampling may be random sampling. The process of randomly sampling each of the first 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 first probability value corresponding to each text data in the target text in each of the first 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.
[0053] Exemplarily, randomly sampling each of the first probability distributions to obtain text data obtained by randomly sampling each of the first probability distributions includes: generating random numbers, sorting the first probability values corresponding to each text data in the target text in each of the first probability distributions, and determining the probability interval of the text data corresponding to each of the first probability values according to the sorted first probability values, wherein among the first probability values arranged from low to high, the probability interval of the text data corresponding to the first first probability value is [0, the first first probability value), and the probability interval of the text data corresponding to each first probability value between the first first probability value and the last first probability value is [the upper limit of the probability interval of the text data corresponding to the previous first probability value of each first probability value, and the sum of the upper limits of the probability interval of the text data corresponding to each first probability value and the previous first probability value), wherein the probability interval of the text data corresponding to the last first probability value is [the upper limit of the probability interval of the text data corresponding to the previous first probability value of the last first 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 first probability distributions. For example, if in a first 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 text data obtained by randomly sampling the first probability distribution.
[0054] The process of determining multiple first reasoning paths includes: performing forward calculations such as nonlinear transformation on the target name, target text and example template 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 the first first probability distribution, performing random sampling on the first first probability distribution to obtain text data obtained by randomly sampling the first first probability distribution, performing forward calculations based on the first hidden vector and the text data obtained by sampling the first first probability distribution to obtain a second hidden vector, performing full connection processing on the second hidden vector to obtain a second 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 the second first probability distribution. By randomly sampling the second first probability distribution, the text data obtained by randomly sampling the second first probability distribution is obtained. By analogy, the above forward calculation-full connection processing-conversion-random sampling process is repeated until the length of the first 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 first probability distributions and the first 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.
[0055] In the process of random sampling of each of the first probability distributions, the shape of each of the first probability distributions can be adjusted using a preset temperature parameter to control the randomness of random sampling. The temperature parameter is a parameter used to adjust the shape of the first probability distribution to control the randomness of 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 first probability distributions can be adjusted using the temperature parameter to obtain an adjusted first probability distribution, thereby achieving the effect of controlling the randomness of random sampling. For example, if the temperature parameter is larger, the shape of the adjusted first probability distribution is flatter, and the randomness of random sampling is higher. Exemplarily, each of the first probability distributions can refer to formula (1). Formula (1) can be adjusted using the temperature parameter T to obtain the adjusted first probability distribution, which can refer to formula (2).
[0056]
[0057]
[0058] Among them, p 1 (y i ) represents the first probability value corresponding to the i-th text data of the target text in each of the first probability distributions, z i represents the original score of the i-th text data in each of the first probability distributions, z j represents the original score of the jth text data in each of the first probability distributions, m represents the number of text data in the target text, and p 2 (y i ) represents the adjusted first probability value corresponding to the i-th text data, and T represents the temperature parameter.
[0059] In some embodiments of the present application, the step of inputting the prompt content into the first language model for second data extraction to obtain multiple second extraction results corresponding to the second prompt content includes: determining multiple second reasoning paths corresponding to the second prompt content based on the target name and the target text, and determining the multiple second extraction results based on the multiple second reasoning paths.
[0060] Each second reasoning path includes a complete reasoning process of a language model, and each second reasoning path may include a second extraction result. The multiple second extraction results may be extracted from the multiple second reasoning paths through keyword extraction technology.
[0061] Each second reasoning path includes multiple text data in the target text. The multiple text data in each second reasoning path can be obtained by sampling multiple second probability distributions. Each text data in the target text corresponds to a second probability value in each second probability distribution. The second probability value can reflect the probability (possibility) of the corresponding text data being selected during the sampling process. The multiple second probability distributions are generated in sequence. The first second probability distribution 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 target text and the target name. If the second prompt content includes a guide sentence, the forward calculation of the target text can be based on the semantic understanding of the guide sentence, the target text and the target name. The i-th second probability distribution in the multiple second probability distributions is generated by sampling the text data obtained by sampling the i-1-th second probability distribution, where i is an integer greater than or equal to 2. By sampling each of the second probability distributions, the text data obtained by sampling each of the second probability distributions can be obtained. The multiple text data obtained by sampling the multiple second probability distributions can constitute a second reasoning path. The multiple second probability distributions are sampled multiple times to obtain the multiple second reasoning paths. Since the multiple second probability distributions are generated in sequence, and after each second probability distribution is generated, each second probability distribution is sampled to obtain a text data, the arrangement order between the multiple text data in each second reasoning path can be determined by the generation order of the multiple second probability distributions.
[0062] The method for sampling each of the second probability distributions can refer to the method for randomly sampling each of the first probability distributions, and the process of determining the multiple second reasoning paths can refer to the process of determining the multiple first reasoning paths described above, which will not be repeated in this application.
[0063] The number of the multiple first extraction results can be determined by the number of first reasoning paths corresponding to the first prompt content, the number of first reasoning paths corresponding to the first prompt content can be determined by the number of sampling times of the first prompt content by the first language model, the number of the multiple second extraction results can be determined by the number of second reasoning paths corresponding to the second prompt content, the number of second reasoning paths corresponding to the second prompt content can be determined by the number of sampling times of the second prompt content by the first language model. The sampling times of the first prompt content and the second prompt content by the first language model can be customized, and this application does not impose any restrictions on this. For example, the sampling times of the first prompt content by the first language model can be 5 times, and the sampling times of the second prompt content by the first prediction model can be 7 times. If the sampling times of the first prompt content by the first language model is 5 times, the number of the multiple first extraction results is 5, and if the sampling times of the second prompt content by the first language model is 7 times, the number of the multiple second extraction results is 7.
[0064] For example, if the target name is "Place of Contract Signing", the target name is "Place of Contract Signing", the first language model samples the first prompt content 5 times and the second prompt content 7 times, then the 5 first extraction results of the target name "Place of Contract Signing" can be "City A", "City A", "City B", "City B", and "City A", and the 7 second extraction results of the target name "Place of Contract Signing" can be "City A", "City A", "City B", "City B", "City A", "City B", and "City B".
[0065] In some embodiments of the present application, when there are multiple target names, each target name has corresponding multiple first extraction results and multiple second extraction results.
[0066] In this embodiment, by randomly sampling multiple first probability distributions and multiple second probability distributions, multiple first extraction results and second extraction results corresponding to the target name can be obtained, thereby increasing the diversity of the extraction results. Random sampling can avoid the problem of inaccurate extraction results caused by selecting only the path with the highest probability (a single reasoning path), thereby improving the accuracy of multiple first extraction results and multiple second extraction results.
[0067] S13, determining a first data extraction result based on the plurality of first extraction results and the plurality of second extraction results.
[0068] In some embodiments of the present application, determining the first data extraction result based on the multiple first extraction results and the multiple second extraction results includes:
[0069] A first data extraction result is determined according to the number of extraction results of each first category, the number of extraction results of each second category, the plurality of first extraction results, and the plurality of second extraction results.
[0070] In some embodiments of the present application, the electronic device may determine whether the first target extraction result matches the second target extraction result.
[0071] Among them, the first target extraction result corresponds to the first target category, at least one first category corresponding to the multiple first extraction results includes the first target category, and the number of extraction results of the first target category is greater than or equal to the first threshold, and the second target extraction result corresponds to the second target category, at least one second category corresponding to the multiple second extraction results includes the second target category, and the number of extraction results of the second target category is greater than or equal to the second threshold. The first threshold can be determined based on the value of the number of the largest number of extraction results in the multiple first extraction results, and the second threshold can be determined based on the value of the number of the largest number of extraction results in the multiple second extraction results. Exemplarily, the first threshold can be the value of the number of the largest number of extraction results in the multiple first extraction results, and the second threshold can be the value of the number of the largest number of extraction results in the multiple second extraction results.
[0072] For example, following the above embodiment, if the five first extraction results of the target name "place where the contract is signed" are "City A", "City A", "City B", "City B", and "City A", the seven second extraction results of the target name "place where the contract is signed" are "City A", "City A", "City B", "City B", "City A", "City B", and "City B. Among the five first extraction results, there are two types of extraction results, "City A" and "City B", of which the number of "City A" is 3 and the number of "City B" is 2, and the number of "City A" is greater than the number of "City B", so it can be determined that the first target extraction result is "City A". By analogy, among the seven second extraction results, there are two types of extraction results, "City A" and "City B", of which the number of "City A" is 3 and the number of "City B" is 4, and the number of "City B" is greater than the number of "City A", so it can be determined that the second target extraction result is "City B".
[0073] In other embodiments, the first threshold and the second threshold may be custom set, which is not limited in this application.
[0074] The first target extraction result matches the second target extraction result, which may be that the first target extraction result is the same as the second target extraction result or the similarity between the first target extraction result and the second target extraction result is greater than or equal to a preset value, etc. The preset value can be customized, and this application does not limit this. For example, the preset value may be 0.9. The first target extraction result does not match the second target extraction result, which may be that the first target extraction result is not the same as the second target extraction result or the similarity between the first target extraction result and the second target extraction result is less than a preset value, etc.
[0075] In this embodiment, by determining the value of the number of the largest number of extraction results in a plurality of first extraction results as the first threshold value, and determining the value of the number of the largest number of extraction results in a plurality of second extraction results as the second threshold value, the largest number of extraction results in a plurality of first extraction results can be selected as the first target extraction result and the largest number of extraction results in a plurality of second extraction results can be selected as the second target extraction result, so that the first target extraction result and the second target extraction result can be representative and accurate. Since the first prompt content includes an example template, it can provide more specific and rich context information, so that the prompt effect of the first prompt content is better than the prompt effect of the second prompt content, so the accuracy and reliability of the first target extraction result are higher than the accuracy and reliability of the second target extraction result. This selection method of selecting the largest number of extraction results as the target extraction result is similar to the method of selecting by majority voting. Since the first target extraction result and the second target extraction result are representative and accurate, by judging whether the first target extraction result matches the second target extraction result, it can be determined whether the first target extraction result with higher reliability is credible / reliable. When the first target extraction result matches the second target extraction result, it can be determined that the first target extraction result is credible / reliable, and when the first target extraction result does not match the second target extraction result, it can be determined that the first target extraction result is uncredible / unreliable.
[0076] In some embodiments of the present application, if the first target extraction result matches the second target extraction result, the electronic device determines that the first target extraction result is the first data extraction result.
[0077] In this embodiment, when it is determined that the first language model is reliable, the first target extraction result is used as the first data extraction result. Since there is no need to input the first prompt content into the second language model (a language model with more model parameters and requiring more computing resources and costs) for the second data extraction, it is not only possible to ensure the accuracy and reliability of the first data extraction result, but also to save computing resources and computing costs.
[0078] In other embodiments of the present application, if the first target extraction result does not match the second target extraction result, the electronic device may input the first prompt content into the second language model to perform a second data extraction to obtain a second data extraction result.
[0079] The number of model parameters of the second language model is greater than the number of model parameters of the first language model. For example, the second language model may be a strong language model such as Gemini Ultra and GPT-4.
[0080] Exemplarily, the electronic device inputs the first prompt content into the second language model for second data extraction, and obtains the second data extraction result including: based on the semantic analysis of the example template, the target name and the target text, locates the position of the target name in the target text, searches for text information related to the target name in the target text according to the position of the target name, and determines the text information related to the target name as context information, and uses natural language processing technology to extract data corresponding to the target name from the context information as the first data extraction result. Among them, the natural language processing technology can be keyword extraction, entity naming recognition, etc., which is not limited in this application.
[0081] In this embodiment, by locating the position of the target name in the target text, and searching the target text for text information related to the target name as context information based on the position of the target name, the problem of confusion in the understanding of the language model due to the similarity between the contents in the target text can be reduced. Since the context information is the intermediate data generated by the language model after recognizing and understanding the target text 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.
[0082] In other embodiments of the present application, the electronic device inputs the first prompt content into the second language model to perform second data extraction, and the method for obtaining the second data extraction result can refer to the above description of the extraction method of the first data extraction result.
[0083] In this embodiment, since the prompt effect of the first prompt content is better than that of the second prompt content, when it is determined that the first language model is unreliable, the first prompt content is input into the second language model for second data extraction, which can ensure the accuracy of the second data extraction result.
[0084] 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, the first prompt content and the second prompt content are respectively input into the first language model, wherein K1 first reasoning paths corresponding to the first prompt content and K2 second reasoning paths corresponding to the second prompt content are generated, K1 first extraction results can be determined according to the K1 first reasoning paths, and K2 second extraction results can be determined according to the K2 second reasoning paths, and the first target extraction result is determined from the K1 first extraction results by majority voting, and the second target extraction result is determined from the K2 second extraction results by majority voting, and it is judged whether the first target extraction result matches the second target extraction result. If the first target extraction result matches the second target extraction result, the first target extraction result is used as the first data extraction result. If the first target extraction result does not match the second target extraction result, the first prompt content is input into the second language model to obtain the second data extraction result.
[0085] In the data extraction method provided in the embodiment of the present application, the prompt content is input into the first language model, and the target text in the first prompt content and the second prompt content can be extracted based on the data name. Since the prompt content includes the first prompt content and the second prompt content, different prompt contents can enable the first language model to reveal the characteristics of the data from different angles or levels, so that the problem of extraction deviation and limitation caused by a single prompt content can be solved, so that the target text can be accurately extracted. By obtaining multiple first extraction results and multiple second extraction results, the diversity of the extraction results can be increased. Since the first prompt content includes an example template, the prompt effect of the first prompt content is better than the prompt effect of the second prompt content, and the accuracy and reliability of the multiple first extraction results are higher than the accuracy and reliability of the multiple second extraction results. By judging whether the first target extraction result matches the second target extraction result, it can be determined whether the first target extraction result with higher reliability is reliable. When the first target extraction result matches the second target extraction result, it is determined that the first target extraction result is reliable, and the first target extraction result is used as the first data extraction result, without inputting the first prompt content into the second language model for second data extraction. Since the second language model has more model parameters, it needs to consume more computing resources and computing power costs, so it can save computing power costs. When the first target extraction result does not match the second target extraction result, it is determined that the first target extraction result is unreliable, and the first prompt content with better prompt effect is input into the second language model with more model parameters, which can ensure the accuracy of the first data extraction result.
[0086] In at least one embodiment of the present application, Figure 3 FIG. 1 is a flowchart of a method for obtaining prompt content provided by an embodiment of the present application, comprising the following steps:
[0087] S111, obtaining a prompt template, where the prompt template includes a first prompt template and a second prompt template.
[0088] In some embodiments of the present application, the method for obtaining the prompt template can refer to the method for obtaining the prompt content, and the present application will not repeat the description. The second prompt template can include a guide sentence. For example, the guide sentence in the second prompt template can be "Let's think step by step".
[0089] Each target name may correspond to multiple text examples, and the multiple text examples may be obtained from an example database, and the example template is one or more text examples similar to the target text in the multiple text examples. When the number of text examples corresponding to the target name is small, in order to ensure that the example template can be selected, the text examples corresponding to the target name may be expanded. For example, the electronic device may obtain an expanded text example by replacing the corresponding words in the text example with synonyms / synonyms, and / or the electronic device may obtain an expanded text example by deleting meaningless words such as stop words in the text example, thereby increasing the number of text examples corresponding to the target name. The above expansion method is for example only and is not limited to this in actual applications.
[0090] The first prompt template and the second prompt template both include multiple information columns. The multiple information columns in the first prompt template correspond one-to-one with the target name, target text and example template, and the multiple information columns in the second prompt template correspond one-to-one with the target name and target text.
[0091] For example, if the target text is a contract text and there are N sample templates, the information columns of the target name, the contract text and the N sample templates in the first prompt template are as follows:
[0092] "You are now a contract review expert, and your task is to extract the following information from the text: {target name}.
[0093] Example template:
[0094] ””'
[0095] Sample Template 1
[0096] Sample Template 2
[0097] …
[0098] Sample Template N
[0099] ””'
[0100] Please output the results in the following format:
[0101] -{target name}-:{target name}
[0102] If no relevant attributes can be extracted, use the Unknown answer.
[0103] Text: {Contract text}".
[0104] For example, if the target text is a contract text, the information columns of the target name and contract text in the second prompt template are as follows:
[0105] "You are now a contract review expert. Your task is to extract the following information from the text: {target name}. Let's think step by step
[0106] Please output the results in the following format:
[0107] -{target name}-:{target name}
[0108] If no relevant attributes can be extracted, use the Unknown answer.
[0109] Text: {Contract text}".
[0110] S112, determining first prompt content based on the example template, the target text, the target name and the first prompt template.
[0111] In at least one embodiment of the present application, the electronic device may combine the target name, the example template, the example template, and the first prompt template to obtain the first prompt content. For example, the electronic device may fill the target name, the target text, and the example template into the corresponding information fields in the first prompt template to obtain the first prompt content.
[0112] For example, Figure 4 , which is a schematic diagram of generating the first prompt content provided by an embodiment of the present application. Figure 4 In the example, the target name, the example template, the target text and the first prompt template are combined to obtain the first prompt content.
[0113] S113, determining the second prompt content based on the target text, the target name and the second prompt template.
[0114] In some embodiments of the present application, the electronic device may combine the target name, the target text and the second prompt template to obtain the second prompt content. For example, the electronic device may fill the target name and the target text into the corresponding information column in the second prompt template to obtain the second prompt content.
[0115] For example, Figure 5 FIG. 1 is a schematic diagram of generating the second prompt content provided by an embodiment of the present application. Figure 5 In the example, the target name, the target text and the second prompt template are combined to obtain the second prompt content.
[0116] In at least one embodiment of the present application, the target name corresponds to multiple text examples, such as Figure 6 FIG. 1 is a flowchart of a method for obtaining an example template provided in an embodiment of the present application, comprising the following steps:
[0117] S1111, vectorize the target text to obtain a first embedding vector corresponding to the target text, and vectorize each text example to obtain a second embedding vector corresponding to each text example.
[0118] In some embodiments of the present application, the present application does not limit the target text and the vectorization method for each text example. For example, the electronic device can use the bge-chinese-base model to vectorize the target text and each text example, wherein the bge-chinese-base model can use word embedding technology to convert the target text and each text example into a corresponding first embedding vector and a second embedding vector, respectively, wherein the method of vectorizing the target text and each text example using word embedding technology can refer to the method of mapping each word in the target text and each text example to a real vector in a high-dimensional space in the related art, and this application will not describe it in detail.
[0119] S1112: Calculate the similarity between the first embedding vector and each second embedding vector.
[0120] 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 first embedding vector and each second embedding vector, and determine the similarity between the first embedding vector and the corresponding second embedding vector according to the distance. The distance can be Euclidean distance, Mahalanobis distance, Manhattan distance, Chebyshev distance, etc. The smaller the distance between the first embedding vector and the second embedding vector, the greater the similarity between the first embedding vector and the second embedding vector.
[0121] In this embodiment, the similarity between the first embedding vector of the target text and the second embedding vector corresponding to each text example is calculated, so as to select a text example similar to the target text as an example template.
[0122] S1113, determining an example template from the multiple text examples according to the similarity.
[0123] In some embodiments of the present application, the similarities may be arranged according to a preset order, for example, in a descending order. The electronic device may select a preset number of text examples corresponding to the top similarities from the similarities arranged from high to low as example templates. The preset number may be customizable, and the present application does not limit this. For example, the preset number may be 1, 3, or 5.
[0124] In this embodiment, by selecting a text example similar to the target text as an example template, the accuracy of data extraction can be improved.
[0125] See also Figure 7 , Figure 7 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 7 As shown, the data extraction device 70 can be operated on an electronic device having a data extraction function, and the device 70 includes:
[0126] Determination module 701 is used to determine prompt content, which is used to prompt the extraction of target name data from the target text. The prompt content includes first prompt content and second prompt content. The first prompt content includes an example template, target text and target name, and the second prompt content includes target text and target name.
[0127] In some embodiments of the present application, the determination module 701 is also used to obtain a prompt template, the prompt template includes a first prompt template and a second prompt template, and determines the first prompt content based on the example template, the target text, the target name and the first prompt template, and determines the second prompt content based on the target text, the target name and the second prompt template.
[0128] In some embodiments of the present application, the determination module 701 is also used to vectorize the target text to obtain a first embedding vector corresponding to the target text, and to vectorize each text example to obtain a second embedding vector corresponding to each text example, calculate the similarity between the first embedding vector and each second embedding vector, and determine an example template from multiple text examples based on the similarity.
[0129] The input module 702 is used to input the prompt content into the first language model to perform a first data extraction, and obtain a plurality of first extraction results corresponding to the first prompt content and a plurality of second extraction results corresponding to the second prompt content.
[0130] In some embodiments of the present application, the input module 702 is also used to determine multiple first reasoning paths corresponding to the first prompt content based on the target name, target text and example template, and determine multiple first extraction results based on the multiple first reasoning paths.
[0131] In some embodiments of the present application, each first reasoning path includes multiple text data in the target text, the multiple text data have a corresponding arrangement order, and the multiple text data of each first reasoning path include a first extraction result.
[0132] The determination module 701 is further configured to determine a first data extraction result based on the plurality of first extraction results and the plurality of second extraction results.
[0133] In some embodiments of the present application, the multiple first extraction results include at least one first category of extraction results, and the multiple second extraction results include at least one second category of extraction results. The determination module 701 is also used to determine the first data extraction result based on the number of each first category of extraction results, the number of each second category of extraction results, the multiple first extraction results, and the multiple second extraction results.
[0134] In some embodiments of the present application, the determination module 701 is also used to determine that the first target extraction result is the first data extraction result if the first target extraction result matches the second target extraction result; the first target extraction result corresponds to a first target category, at least one first category includes the first target category, and the number of extraction results of the first target category is greater than or equal to a first threshold; the second target extraction result corresponds to a second target category, at least one second category includes the second target category, and the number of extraction results of the second target category is greater than or equal to a second threshold.
[0135] In some embodiments of the present application, the determination module 701 is also used to input the first prompt content into the second language model for second data extraction to obtain a second data extraction result if the first target extraction result does not match the second target extraction result; the number of model parameters of the second language model is greater than the number of model parameters of the first language model.
[0136] See also Figure 8 , Figure 8 It is a structural schematic diagram of an electronic device provided by an embodiment of the present application.
[0137] exist Figure 8 In the embodiment, the electronic device 80 includes but is not limited to: a radio frequency unit 801, a network module 802, an audio output unit 803, an input unit 804, a sensor 805, a display unit 806, a user input unit 807, an interface unit 808, a memory 809, a processor 810, and a power supply 811. Those skilled in the art can understand that Figure 8 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.
[0138] Among them, the processor 810 is used to: determine prompt content, the prompt content is used to prompt the extraction of target name data from the target text, the prompt content includes first prompt content and second prompt content, the first prompt content includes an example template, the target text and the target name, and the second prompt content includes the target text and the target name; input the prompt content into a first language model to perform a first data extraction, and obtain multiple first extraction results corresponding to the first prompt content, and multiple second extraction results corresponding to the second prompt content; determine the first data extraction result based on the multiple first extraction results and the multiple second extraction results.
[0139] The embodiment of the present application also has the same Figure 1-Figure 6 The same beneficial technical effects as those of the illustrated embodiments are not described in detail here.
[0140] It should be understood that in the embodiment of the present application, the radio frequency unit 801 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 810 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 801 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 801 can also communicate with the network and other devices through a wireless communication system.
[0141] The electronic device provides users with wireless broadband Internet access through the network module 802, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0142] The audio output unit 803 can convert the audio data received by the RF unit 801 or the network module 802 or stored in the memory 809 into an audio signal and output it as sound. Moreover, the audio output unit 803 can also provide audio output related to a specific function performed by the electronic device 80 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 803 includes a speaker, a buzzer, a receiver, etc.
[0143] The input unit 804 is used to receive audio or video signals. The input unit 804 may include a graphics processor (GPU) 8041 and a microphone 8042, and the graphics processor 8041 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 806. The image frame processed by the graphics processor 8041 can be stored in the memory 809 (or other storage medium) or sent via the radio frequency unit 801 or the network module 802. The microphone 8042 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 801 in the case of a telephone call mode.
[0144] The electronic device 80 also includes at least one sensor 805, 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 8061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 8061 and / or the backlight when the electronic device 80 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 805 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.
[0145] The display unit 806 is used to display information input by the user or information provided to the user. The display unit 806 may include a display panel 8061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0146] The user input unit 807 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 807 includes a touch panel 8071 and other input devices 8072. The touch panel 8071, 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 8071 or near the touch panel 8071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 8071 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 810, receives the command sent by the processor 810 and executes it. In addition, the touch panel 8071 can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 8071, the user input unit 807 may also include other input devices 8072. Specifically, other input devices 8072 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 will not be described in detail here.
[0147] Furthermore, the touch panel 8071 may be overlaid on the display panel 8061. When the touch panel 8071 detects a touch operation on or near it, it transmits the information to the processor 810 to determine the type of the touch event. Then, the processor 810 provides corresponding visual output on the display panel 8061 according to the type of the touch event. Figure 8 In the figure, the touch panel 8071 and the display panel 8061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 8071 and the display panel 8061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0148] The interface unit 808 is an interface for connecting an external device to the electronic device 80. 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 808 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 80 or may be used to transmit data between the electronic device 80 and an external device.
[0149] The memory 809 can be used to store software programs and various data. The memory 809 can mainly include a program storage area and a data storage area, wherein the program storage area can store at least one application program 8091 required for a function (such as a sound playback function, an image playback function, etc.), an operating system 8092, etc.; the data storage area can store data created according to the use of the electronic device 80 (such as audio data, a phone book, etc.), etc. In addition, the memory 809 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.
[0150] The processor 810 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device 80. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 809, and calling data stored in the memory 809, so as to monitor the electronic device as a whole. The processor 810 may include one or more processing units; preferably, the processor 810 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 810.
[0151] The electronic device 80 may also include a power source 811 (such as a battery) for supplying power to each component. Preferably, the power source 811 may be logically connected to the processor 810 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0152] Preferably, an embodiment of the present application also provides an electronic device, including a processor 810, a memory 809, and a computer program stored in the memory 809 and executable on the processor 810. When the computer program is executed by the processor 810, each process of the above-mentioned data extraction method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0153] 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 80. In other embodiments of the present application, the electronic device 8 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.
[0154] 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.
[0155] The embodiment of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the electronic device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the electronic device executes the data extraction method described in the embodiment of the present application.
[0156] 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.
[0157] 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.
[0158] 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 prompt content, the prompt content is used to prompt the extraction of target name data from the target text, the prompt content includes first prompt content and second prompt content, the first prompt content includes an example template, the target text and the target name, and the second prompt content includes the target text and the target name; Inputting the prompt content into a first language model to perform a first data extraction, and obtaining a plurality of first extraction results corresponding to the first prompt content and a plurality of second extraction results corresponding to the second prompt content; Based on the plurality of first extraction results and the plurality of second extraction results, a first data extraction result is determined.
2. The data extraction method according to claim 1, characterized in that: The plurality of first extraction results include at least one extraction result of a first category, and the plurality of second extraction results include at least one extraction result of a second category; The step of determining a first data extraction result based on the plurality of first extraction results and the plurality of second extraction results comprises: A first data extraction result is determined according to the number of extraction results of each of the first categories, the number of extraction results of each of the second categories, the plurality of first extraction results, and the plurality of second extraction results.
3. The data extraction method according to claim 2, characterized in that: Determining the first data extraction result according to the number of each extraction result of the first category, the number of each extraction result of the second category, the plurality of first extraction results, and the plurality of second extraction results includes: If the first target extraction result matches the second target extraction result, the first target extraction result is determined to be the first data extraction result; the first target extraction result corresponds to a first target category, the at least one first category includes the first target category, and the number of extraction results of the first target category is greater than or equal to a first threshold, and the second target extraction result corresponds to a second target category, the at least one second category includes the second target category, and the number of extraction results of the second target category is greater than or equal to a second threshold.
4. The data extraction method according to claim 3, characterized in that: The method further comprises: If the first target extraction result does not match the second target extraction result, the first prompt content is input into a second language model for second data extraction to obtain the second data extraction result; the number of model parameters of the second language model is greater than the number of model parameters of the first language model.
5. The data extraction method according to claim 1, characterized in that: The determining of prompt content includes: Acquire a prompt template, where the prompt template includes a first prompt template and a second prompt template; Determine the first prompt content based on the example template, the target text, the target name and the first prompt template; The second prompt content is determined based on the target text, the target name and the second prompt template.
6. The data extraction method according to claim 5, characterized in that: The target name corresponds to a plurality of text examples, and the method further comprises: Performing vectorization processing on the target text to obtain a first embedding vector corresponding to the target text, and performing vectorization processing on each text example to obtain a second embedding vector corresponding to each text example; Calculating a similarity between the first embedding vector and each second embedding vector; The example template is determined from the plurality of text examples according to the similarity.
7. The data extraction method according to claim 1, characterized in that: The step of inputting the prompt content into a first language model to perform first data extraction to obtain a plurality of first extraction results corresponding to the first prompt content includes: Determining, according to the target name, the target text, and the example template, a plurality of first reasoning paths corresponding to the first prompt content; The plurality of first extraction results are determined according to the plurality of first reasoning paths.
8. The data extraction method according to claim 7, characterized in that: Each of the first 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 first reasoning paths includes one first extraction result.
9. A data extraction device, characterized in that: The data extraction device comprises: A determination module, used to determine prompt content, the prompt content is used to prompt the extraction of target name data from the target text, the prompt content includes a first prompt content and a second prompt content, the first prompt content includes an example template, the target text and the target name, and the second prompt content includes the target text and the target name; An input module, used for inputting the prompt content into a first language model to perform a first data extraction, and obtaining a plurality of first extraction results corresponding to the first prompt content and a plurality of second extraction results corresponding to the second prompt content; The determination module is further used to determine the first data extraction result based on the multiple first extraction results and the multiple second extraction results.
10. 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, wherein the processor implements the data extraction method according to any one of claims 1 to 8 when executing the computer program.
11. 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 8 is implemented.
12. 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 8 is implemented.
Citation Information
Patent Citations
Information extraction method, and method and device for training question and answer processing model
CN116662496A
Emotion analysis method and device and big language model training method and device
CN117436438A
Text extraction method and device and electronic equipment
CN117634449A
Zero sample data knowledge extraction method and device based on large-scale language model
CN117764158A
