Text processing method and related product
By utilizing multiple thought chains and consistency scores of the language model in natural language processing to generate prompt words and fuse the processing results, the problem of insufficient accuracy and diversity of execution results in the existing technology is solved, and a more accurate and rich implementation is achieved. text processing effect.
Patent Information
- Application Number
- CN202410811230.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-11
AI Technical Summary
When existing natural language processing technology uses language models to perform text processing tasks, it is difficult to improve the accuracy and diversity of execution results, and it is difficult to integrate the results of different thinking chains.
By obtaining the text to be processed, the language model is used to perform target tasks according to multiple thinking chains, generate consistency scores and clustering results, synthesize prompt words, and guide the language model to fuse different processing results to generate the final execution result.
It improves the accuracy and diversity of execution results of text processing tasks, uses the content of different thinking chains to fuse, and enhances the richness and consistency of the results.
Smart Images

Figure CN118760751A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a text processing method and related products. Background Art
[0002] With the development of natural language processing technology, language models with natural language processing capabilities have emerged. Since language models have natural language processing capabilities, they can be used to perform natural language processing tasks on texts to meet the needs of natural language processing. Therefore, how to use language models to perform natural language processing tasks on texts is of great significance. Summary of the invention
[0003] The present application provides a text processing method and related products to improve the accuracy of execution results obtained by executing a target task using a language model, wherein the related products include a text processing device, an electronic device, a computer-readable storage medium and a computer program product.
[0004] In a first aspect, a text processing method is provided, the method comprising:
[0005] Get the text to be processed;
[0006] Using a language model to perform a target task on the text to be processed according to n different chains of thought, to obtain n first processing results, wherein the target task is a natural language processing task, and n is an integer greater than 1;
[0007] Based on the n first processing results and the target task, generating a prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the n first processing results;
[0008] Under the guidance of the prompt word, the language model is used to fuse the contents of the n first processing results to obtain the execution result of the target task.
[0009] In combination with any implementation manner of the present application, the generating of prompt words based on the n first processing results and the target task includes:
[0010] Based on the n first processing results, determine n first consistency scores of the n first processing results, where the first consistency scores correspond to the first processing results one by one, and the first consistency scores represent the consistency between the first processing result and the n first processing results;
[0011] Determine that the first processing results corresponding to the largest k of the n first consistency scores among the n first processing results are k consistent results, where k is a positive integer less than n;
[0012] Based on the k consistent results and the target task, generating the prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the k consistent results;
[0013] Under the guidance of the prompt word, the language model is used to fuse the contents of the n first processing results to obtain the execution result of the target task, including:
[0014] Under the guidance of the prompt word, the language model is used to fuse the contents of the k consistent results to obtain the execution result.
[0015] In combination with any implementation manner of the present application, the n first processing results include a second processing result, the n first consistency scores include a second consistency score, and the second consistency score is the first consistency score of the second processing result;
[0016] The determining, based on the n first processing results, n first consistency scores of the n first processing results comprises:
[0017] Determine a first similarity between the second processing result and the first processing results other than the second processing result among the n first processing results, and obtain (n-1) first similarities;
[0018] The second consistency score is obtained based on the sum of the (n-1) first similarities.
[0019] In combination with any implementation manner of the present application, the generating the prompt word based on the k consistent results and the target task includes:
[0020] Clustering the k consistent results to obtain m result sets, where m is a positive integer less than k, and the result set is a set of the consistent results;
[0021] Based on the m result sets, m first clustering results are obtained, where the first clustering results correspond one-to-one to the result sets;
[0022] Based on the m first clustering results and the target task, generating the prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the m first clustering results;
[0023] Under the guidance of the prompt word, the language model is used to fuse the contents of the k consistent results to obtain the execution result, including:
[0024] Under the guidance of the prompt word, the language model is used to fuse the contents of the m first clustering results to obtain the execution result.
[0025] In combination with any implementation manner of the present application, the obtaining of m first clustering results based on the m result sets includes:
[0026] For any one of the m result sets, determine the consistent result closest to the center of the set from the set as the first clustering result, and obtain the m first clustering results.
[0027] In combination with any implementation manner of the present application, under the guidance of the prompt word, using the language model to fuse the contents of the m first clustering results to obtain the execution result includes:
[0028] Under the guidance of the prompt word, the language model fuses common contents with semantic matching in the m first clustering results to obtain the execution result.
[0029] In combination with any embodiment of the present application, the m is greater than 1, the m first clustering results include a second clustering result and a third clustering result, the second clustering result includes the first paragraph, and the third clustering result includes the second paragraph;
[0030] The language model integrates the common contents in the m clustering results to obtain the execution result, including:
[0031] The language model determines a first position of the first paragraph in the second clustering result;
[0032] Determining, by the language model, a second position of the second paragraph in the third clustering result;
[0033] Determining, by the language model, a second similarity between the first position and the second position;
[0034] The language model determines a third similarity between the semantics of the first paragraph and the semantics of the second paragraph;
[0035] The language model fuses the first paragraph and the second paragraph when a weighted sum of the second similarity and the third similarity is greater than or equal to a threshold to obtain the execution result.
[0036] In combination with any implementation manner of the present application, the target task is to extract a summary of the text.
[0037] In a second aspect, a text processing device is provided, the text processing device comprising:
[0038] An acquisition unit, used for acquiring the text to be processed;
[0039] A processing unit, configured to use a language model to perform a target task on the text to be processed according to n different chains of thought to obtain n first processing results, wherein the target task is a natural language processing task, and n is an integer greater than 1;
[0040] a generating unit, configured to generate a prompt word based on the n first processing results and the target task, wherein the prompt word is used to guide the language model to perform the target task based on the n first processing results;
[0041] The processing unit is used to obtain the execution result of the target task by fusing the contents of the n first processing results using the language model under the guidance of the prompt word.
[0042] In combination with any implementation manner of the present application, the generating unit is specifically used for:
[0043] Based on the n first processing results, determine n first consistency scores of the n first processing results, where the first consistency scores correspond to the first processing results one by one, and the first consistency scores represent the consistency between the first processing result and the n first processing results;
[0044] Determine that the first processing results corresponding to the largest k of the n first consistency scores among the n first processing results are k consistent results, where k is a positive integer less than n;
[0045] Based on the k consistent results and the target task, generating the prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the k consistent results;
[0046] The processing unit is specifically used for:
[0047] Under the guidance of the prompt word, the language model is used to fuse the contents of the k consistent results to obtain the execution result.
[0048] In combination with any implementation manner of the present application, the n first processing results include a second processing result, the n first consistency scores include a second consistency score, and the second consistency score is the first consistency score of the second processing result;
[0049] The generating unit is specifically used for:
[0050] Determine a first similarity between the second processing result and the first processing results other than the second processing result among the n first processing results, and obtain (n-1) first similarities;
[0051] The second consistency score is obtained based on the sum of the (n-1) first similarities.
[0052] In combination with any implementation manner of the present application, the generating unit is specifically used for:
[0053] Clustering the k consistent results to obtain m result sets, where m is a positive integer less than k, and the result set is a set of the consistent results;
[0054] Based on the m result sets, m first clustering results are obtained, where the first clustering results correspond one-to-one to the result sets;
[0055] Based on the m first clustering results and the target task, generating the prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the m first clustering results;
[0056] The processing unit is specifically used for:
[0057] Under the guidance of the prompt word, the language model is used to fuse the contents of the m first clustering results to obtain the execution result.
[0058] In combination with any implementation manner of the present application, the generating unit is specifically used for:
[0059] For any one of the m result sets, determine the consistent result closest to the center of the set from the set as the first clustering result, and obtain the m first clustering results.
[0060] In conjunction with any implementation manner of the present application, the processing unit is specifically used to:
[0061] Under the guidance of the prompt word, the language model fuses common contents with semantic matching in the m first clustering results to obtain the execution result.
[0062] In combination with any embodiment of the present application, the m is greater than 1, the m first clustering results include a second clustering result and a third clustering result, the second clustering result includes the first paragraph, and the third clustering result includes the second paragraph;
[0063] The processing unit is specifically used for:
[0064] Determining a first position of the first paragraph in the second clustering result using the language model;
[0065] Determining a second position of the second paragraph in the third clustering result by using the language model;
[0066] Determining a second similarity between the first position and the second position using the language model;
[0067] Determining a third similarity between the semantics of the first paragraph and the semantics of the second paragraph using the language model;
[0068] The first paragraph and the second paragraph are merged by using the language model when a weighted sum of the second similarity and the third similarity is greater than or equal to a threshold, to obtain the execution result.
[0069] In combination with any implementation manner of the present application, the target task is to extract a summary of the text.
[0070] According to a third aspect, an electronic device is provided, comprising: a processor and a memory, wherein the memory is used to store computer program code, wherein the computer program code comprises computer instructions, and when the processor executes the computer instructions, the electronic device executes the first aspect and any one of its embodiments described above.
[0071] In a fourth aspect, another electronic device is provided, comprising: a processor, a sending device, an input device, an output device and a memory, wherein the memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device executes the first aspect and any one of its embodiments.
[0072] In a fifth aspect, a computer-readable storage medium is provided, in which a computer program is stored. The computer program includes program instructions. When the program instructions are executed by a processor, the processor is caused to execute the first aspect and any one of its embodiments.
[0073] In a sixth aspect, a computer program product is provided, wherein the computer program product comprises a computer program or instructions, and when the computer program or instructions are run on a computer, the computer is enabled to execute the above-mentioned first aspect and any embodiment thereof.
[0074] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application.
[0075] In the present application, after obtaining the text to be processed, the text processing device uses a language model to perform a target task on the text to be processed according to n different chains of thought, and obtains n first processing results. Prompt words are generated based on the n first processing results and the target task. Under the guidance of the prompt words, the execution result of the target task can be obtained by fusing the contents of the n first processing results using a language model. Since different first processing results are obtained based on different chains of thought, the language model obtains the execution result of the target task by fusing the contents of the n first processing results, which can not only realize the use of different chains of thought to obtain the execution result, but also compared with selecting one from the n first processing results as the execution result, the text processing device uses the contents of different first execution results to obtain the execution result, thereby improving the accuracy of the execution result, and also enables the execution result to include the contents of different first execution results, thereby enriching the diversity of the content in the execution result. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.
[0077] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.
[0078] Figure 1 A flowchart of a text processing method provided in an embodiment of the present application;
[0079] Figure 2 A specific flow chart of another text processing method provided in an embodiment of the present application;
[0080] Figure 3 A schematic diagram for comparing a selection based self-consistency (SBS) method and a fine-grained self-consistency (FSC) method for free format generation tasks provided in an embodiment of the present application;
[0081] Figure 4 A schematic diagram of a FSC process provided in an embodiment of the present application;
[0082] Figure 5 A flowchart of another text processing method provided in an embodiment of the present application;
[0083] Figure 6 A structural diagram of a text processing device provided in an embodiment of the present application;
[0084] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0085] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0086] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0087] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0088] The execution subject of the embodiment of the present application is a text processing device, wherein the text processing device can be any electronic device that can execute the technical solution disclosed in the embodiment of the method of the present application. Optionally, the text processing device can be one of the following: a computer, a server.
[0089] It should be understood that the method embodiment of the present application can also be implemented by a processor executing a computer program code. The following describes the embodiment of the present application in conjunction with the drawings in the embodiment of the present application. Figure 1 , Figure 1 A flowchart of a text processing method provided in an embodiment of the present application.
[0090] 101. Get the text to be processed.
[0091] In the embodiment of the present application, the text to be processed may be any text, and the content of the text to be processed may be any content. For example, the text to be processed is a note, another example, the text to be processed is a text describing a problem, another example, the text to be processed is a conversation record, and another example, the content of the text to be processed is a computer program code. Optionally, the number of texts to be processed is 1 or more.
[0092] In a method of obtaining a text to be processed, a text processing device receives the text to be processed input by a user through an input component. The input component includes at least one of the following: a keyboard, a mouse, a touch screen, a touch pad, and an audio input device.
[0093] In another method of obtaining the text to be processed, the text processing device receives the text to be processed sent by the terminal. The terminal includes at least one of the following: a mobile phone, a computer, a tablet computer, and a server.
[0094] 102. Utilize the language model to perform the target task on the above text to be processed according to n different chains of thinking, and obtain n first processing results.
[0095] In the embodiment of the present application, the language model to be evaluated is a natural language model, that is, the language model to be evaluated has the ability of natural language processing (NLP). Optionally, the language model to be evaluated is a large language model (LLM). m is greater than or equal to 2, that is, the number of language models to be evaluated is 2 or more.
[0096] In an embodiment of the present application, the language model has the ability of natural language processing. In a possible implementation method, the language model is obtained by training text training data, wherein the text training data includes one or more of masked text and non-masked text. Masked text is text including mask. When the text training data includes masked text, the language model is trained using the text training data, so that the language model can predict the content blocked by the mask in the masked text to obtain a first prediction result, and then the loss of the language model is determined based on the difference between the first prediction result and the true value (ground truth, GT) of the mask. The parameters of the language model are updated based on the loss until the loss of the language model converges, and the training of the language model can be completed. Non-masked text is text that does not include mask. When the text training data does not include non-masked text, the language model is trained using text training data, so that the language model can use non-masked text to perform natural language processing tasks, thereby improving the natural language processing ability of the language model, wherein the natural language processing tasks include: summarizing the summary of the text, determining the order of sentences, and determining the answer to the question based on the text.
[0097] Optionally, the above language model is a large language model (LLM), where LLM refers to a deep learning model trained with a large amount of text data, which can generate natural language text or understand the meaning of language text. Large language models can handle a variety of natural language tasks, such as text classification, question answering, dialogue, generating text summaries, and generating code.
[0098] In the embodiment of the present application, the target task is a natural language processing task. Optionally, the target task is one of the following: evaluating the quality of the content in the text, extracting a summary of the text, answering questions, and extracting keywords from the text. The evaluation result obtained by evaluating the quality of the content in the text can be used to measure the attractiveness of the text to the reader. For example, if the text is a note, the quality of the content in the note can be evaluated based on the popularity of the content in the note, the matching degree with the content of interest to the reader, the richness of the content in the note, and the fluency of the content in the note. The evaluation result can be used to measure the attractiveness of the note to the reader.
[0099] In the embodiment of the present application, the thinking chain is a prompting strategy, which is used to instruct the language model to perform the target task in a step-by-step thinking manner. The language model performs the target task according to the thinking chain, and the target task will be divided into s steps for execution, where s is an integer greater than 1. By adjusting the temperature parameter (temperature parameter, TP) of the language model, the diversity of the thinking chain can be controlled, and then the diversity of the execution results of the target task obtained by the language model based on the thinking chain can be controlled. Specifically, TP is positively correlated with the diversity of the thinking chain. When TP is 0, the language model is executed according to the same thinking chain when executing n target tasks, and the n first processing results obtained by executing n target tasks are the same. When TP is greater than 0, the language model can be executed according to different thinking chains when executing n target tasks, and at least two different first processing results exist in the n first processing results obtained by executing n target tasks, and the larger the TP, the smaller the number of the same first processing results in the n first processing results. In step 102, in order to make the n first processing results different, the TP of the language model is greater than 0, and optionally, TP is 0.8.
[0100] 103. Generate a prompt word based on the n first processing results and the target task.
[0101] In the embodiment of the present application, the prompt word (promt) is used to guide the language model to perform the target task based on the n first processing results. The text processing device can generate a prompt word based on the n first processing results and the above-mentioned target task, so that the prompt word includes the n first processing results, the target task, and a description of guiding the language model to perform the target task based on the n first processing results.
[0102] For example, the n first processing results include: first processing result s1, first processing result s2, first processing result s3. The target task is to answer question a, and the first processing result is the answer generated by the language model for question a. The prompt words include: The following answers have been generated for question a: first processing result s1, first processing result s2, first processing result s3. Please determine the final answer to question a based on the above answers.
[0103] For another example, the n first processing results include: first processing result s1, first processing result s2, first processing result s3. The target task is to extract the summary of document b, and the first processing result is the summary generated by the language model for document b. The prompt words include: the following summaries have been generated for document b: first processing result s1, first processing result s2, first processing result s3. Please determine the final summary of document b based on the above summaries.
[0104] Optionally, the prompt word includes requirements that need to be met by the answer generated by performing the target task based on the n first processing results. In one possible implementation, the requirements include: performing the target task based on the common content in the n first processing results. For example, the n first processing results include the first processing result s1 and the first processing result s2, wherein the content a in the first processing result s1 and the content b in the first processing result s2 are common content, then the language model needs to perform the target task based on content a and content b. In another possible implementation, the requirements include: the number of words in the execution result of the target task needs to be less than a preset number. In another possible implementation, the requirements include: marking the source of the content in the execution result of the target task. For example, the n first processing results include the first processing result s1 and the first processing result s2, wherein the first processing result s1 includes content a. If the processing result of the target task includes content b, wherein content b is obtained based on content a, then the source of content b can be marked as content a in the first processing result s1.
[0105] Since the language model has natural language processing capabilities, the language model can use the natural language processing capabilities to determine the common content in the first processing results, which can improve the accuracy of the common content. For example, the language model can determine whether the content in different first processing results is common content by comparing the semantic matching of the content in different first processing results.
[0106] 104. Under the guidance of the prompt words, the language model is used to fuse the contents of the n first processing results to obtain the execution result of the target task.
[0107] In the embodiment of the present application, after generating the prompt word, the text processing device can obtain the execution result of the target task by fusing the contents of the n first processing results under the guidance of the prompt word. By fusing the contents of the n first processing results, it is possible to use the contents of different first processing results to execute the target task and obtain the execution result. In this way, the execution result includes the contents from different first processing results.
[0108] For example, the target task is to answer the following question: What types of cars can be divided into? The n first processing results include the first processing result a and the first processing result b, where the first processing result a means that cars can be divided into cars that burn gasoline and cars that burn diesel. The first processing result b means that cars can be divided into cars that burn gasoline and cars that are powered by electric vehicles. The language model fuses the content in the first processing result a with the content in the first processing result b, and the execution result obtained is: cars can be divided into cars that burn gasoline, cars that burn diesel, and cars that are powered by electric vehicles.
[0109] In one possible implementation, the evaluation device, under the guidance of the prompt word, uses a language model to fuse the common contents with semantic matching in the n first processing results to obtain the execution result of the target task. In the embodiment of the present application, the common contents are two or more contents with semantic matching. For example, content a is: members of Zhang San's team, and no one in the team has better grades than Zhang San. The content of content b is: the members of the team are Zhang San, Li Si, and Wang Wu, among which Zhang San's grades are better than Li Si's grades, and Li Si's grades are better than Wang Wu's grades. The semantics of content a and the semantics of content b both express that Zhang San has the best grades in the team, that is, the semantics of content a and the semantics of content b are matched. Therefore, content a and content b are common content.
[0110] Optionally, the common content of semantic matching comes from different first processing results, so that when the language model uses the common content to obtain the execution result of the target task, the language model can use the content in different first processing results to obtain the execution result of the target task, thereby making more effective use of the content in the n first processing results to obtain the execution result, thereby improving the accuracy of the execution result. For example, the n first processing results include a first processing result s1 and a first processing result s2, wherein the first processing result s1 includes paragraph a, and the first processing result s2 includes paragraph b, and paragraph a and paragraph b have common content. The language model obtains the execution result of the target task by fusing paragraph a and paragraph b, and can obtain the execution result of the target task by using paragraphs in different first processing results.
[0111] Optionally, using a language model to fuse the common contents with semantic matching in the n first processing results to obtain the execution result of the target task means using a language model to extract the common contents with semantic matching in the n first processing results, and obtaining the execution result of the target task based on the common semantics of the common contents. For example, the n first processing results include the first processing result s1 and the first processing result s2, wherein the first processing result s1 includes paragraph a, and the first processing result s2 includes paragraph b. The content of paragraph a is: members of Zhang San's team, no one in the team has better grades than Zhang San. The content of paragraph b is: members of the team are Zhang San, Li Si, and Wang Wu, wherein Zhang San's grades are better than Li Si's grades, and Li Si's grades are better than Wang Wu's grades. Since the semantics of the content in paragraph a and the semantics of the content in paragraph b both express that Zhang San has the best grades in the team, paragraph a and paragraph b have common content, and the common semantics of paragraph a and paragraph b is that Zhang San has the best grades in the team. The language model extracts paragraph a and paragraph b. Based on the common semantics of paragraph a and paragraph b, the execution result of the target task is obtained. At this time, the execution result includes the semantics that Zhang San has the best performance in the team.
[0112] In this implementation, since the language model has natural language processing capabilities, the language model can use the natural language processing capabilities to determine the common content in the n first processing results, thereby improving the accuracy of the common content.
[0113] In another possible implementation, the language model divides each first processing result into at least two segments of first segmented text. Determine the correlation between the first segmented text belonging to different first processing results. Optionally, the correlation between the first segmented text is the Spearman's rank correlation coefficient between the first segmented text. Optionally, the correlation between the first segmented text is the Pearson correlation coefficient between the first segmented text. When the correlation between the two segments of first segmented text is greater than or equal to a correlation threshold, one of the two segments of first segmented text is selected as the first candidate text, and at least one segment of first candidate text can be obtained. The language model generates the execution result of the target task based on at least one segment of first candidate text.
[0114] In this implementation, if the correlation between the two first segmented texts is greater than or equal to the correlation threshold, it means that the same content appears in different first processing results, which means that the confidence of the content of the two first segmented texts is high. At this time, at least one first candidate text is obtained by selecting one of the two first segmented texts as the first candidate text. Then, the execution result of the target task is generated based on at least one first candidate text, which can improve the accuracy of the execution result. In this way, it is possible to use the content in different first processing results to execute the target task and obtain the execution result.
[0115] Optionally, when the number of first candidate characters is greater than 1, at least one first candidate character comes from at least two different first processing results, for example, the n first processing results include a first processing result s1 and a first processing result s2, and at least one first candidate character includes: a first candidate character a, a first candidate character b, and a first candidate character c, wherein the first candidate character a and the first candidate character b are the contents in the first processing result s1, and the first candidate character c is the content in the first processing result s2. When at least one first candidate character comes from at least two different first processing results, an execution result is obtained based on at least one first candidate character, and the execution result of the target task can be obtained by using the contents in at least two different first processing results, thereby improving the accuracy of the execution result.
[0116] In another possible implementation, the language model divides each first processing result into at least two segments of first segmented text. All first segmented text are clustered to obtain at least one first cluster set, wherein the first cluster set is a set of first segmented text, the correlation between first segmented text in the same first cluster set is greater than or equal to the correlation threshold, and the correlation between first segmented text in different first cluster sets is less than the correlation threshold. For each first cluster set, a segment of first segmented text is randomly selected as the second candidate text to obtain at least one segment of second candidate text. The language model generates the execution result of the target task based on at least one segment of second candidate text.
[0117] In this implementation, the first segmented characters with high correlation are divided into the same first cluster set by clustering, thereby achieving the division of the contents of the n first processing results into at least one first cluster set. At this time, for each first cluster set, a segment of the first segmented characters is selected as the second candidate characters, and at least one segment of the second candidate characters is obtained. Then, the execution result of the target task is generated based on at least one segment of the second candidate characters, so that the execution result can be obtained by executing the target task using the contents of different first processing results.
[0118] Optionally, when the number of second candidate characters is greater than 1, at least one second candidate character comes from at least two different first processing results. When at least one second candidate character comes from at least two different first processing results, obtaining an execution result based on at least one second candidate character can achieve obtaining the execution result of the target task by utilizing the contents of at least two different first processing results, thereby improving the accuracy of the execution result.
[0119] Optionally, in step 104, the TP of the language model is 0. Because the smaller the TP, the higher the accuracy of the result output by the language model, when the language model is at TP=0, the execution result is obtained, which can improve the accuracy of the execution result.
[0120] In an embodiment of the present application, after obtaining the text to be processed, the text processing device uses a language model to perform a target task on the text to be processed according to n different chains of thought, and obtains n first processing results. A prompt word is generated based on the n first processing results and the target task. Under the guidance of the prompt word, the execution result of the target task can be obtained by fusing the contents of the n first processing results using a language model. Since different first processing results are obtained based on different chains of thought, the language model obtains the execution result of the target task by fusing the contents of the n first processing results, which can not only realize the use of different chains of thought to obtain the execution result, but also compared to selecting one from the n first processing results as the execution result, the text processing device uses the contents of different first execution results to obtain the execution result, thereby improving the accuracy of the execution result, and also enables the execution result to include the contents of different first execution results, thereby enriching the diversity of the content in the execution result.
[0121] See also Figure 2 , Figure 2 This is a specific flow chart of another text processing method provided in an embodiment of the present application. Figure 2 As shown, after obtaining n first processing results output by the language model, prompt words are generated based on the n first processing results, and the prompt words include the n first processing results, the target task performed by the language model, and a description of guiding the language model to perform the target task based on the n first processing results. Figure 2 The prompt words shown include the first processing result s1 and the first processing result s2. The target task is to answer the question. The description of guiding the language model to perform the target task based on the n first processing results is: please integrate and generate the final answer based on the common content in the above answers. Under the guidance of the prompt words, the language model integrates and generates the execution result based on the common content in the above answers. Optionally, under the guidance of the prompt words, the language model obtains the execution result by fusing the common content in the answers.
[0122] As an optional implementation, the text processing device performs the following steps during the process of executing step 103:
[0123] 201. Based on the n first processing results, determine n first consistency scores of the n first processing results.
[0124] In an embodiment of the present application, the consistency score is used to measure and evaluate the consistency between different processing results, wherein the consistency score includes the above-mentioned first consistency score and the second consistency score to be mentioned below. The first consistency score corresponds to the first processing result one-to-one, and the first consistency score characterizes the consistency of any first processing result with other (n-1) first processing results. For example, the n first processing results include: first processing result s1, first processing result s2, and first processing result s3. According to the consistency of the first processing result s1 with the first processing result s2 and the first processing result s3, the first consistency score of the first processing result s1 is obtained. According to the consistency of the first processing result s2 with the first processing result s1 and the first processing result s3, the first consistency score of the first processing result s2 is obtained. According to the consistency of the first processing result s3 with the first processing result s2 and the first processing result s1, the first consistency score of the first processing result s3 is obtained.
[0125] In one possible implementation, the n first processing results include a second processing result, wherein the second processing result is any one of the n first processing results. The n first consistency scores include a second consistency score, wherein the second consistency score is the first consistency score of the second processing result. The text processing device obtains the second consistency score by performing the following steps: determining a first similarity between the second processing result and a first processing result other than the second processing result among the n first processing results, and obtaining (n-1) first similarities. Based on the sum of the (n-1) first similarities, a second consistency score is obtained.
[0126] Optionally, the text processing device obtains the average value of (n-1) first similarities based on the sum of (n-1) first similarities as the second consistency score. For example, the n first processing results include: the second processing result, the first processing result s1, and the first processing result s2. If the first similarity x1 between the second processing result and the first processing result s1, and the first similarity x2 between the second processing result and the first processing result s2, then the second consistency score of the second processing result is the average value of x1 and x2. Optionally, the text processing device determines the sum of (n-1) first similarities as the second consistency score.
[0127] Optionally, the second consistency score is calculated by the following formula:
[0128]
[0129] Among them, SC Sim (S i ) is the second consistency score. i is the second processing result. j is the jth first processing result among the n first processing results, j≠i means Si With S j are two different processing results among the n first processing results. Sim(S j ,S i ) indicates the determination of S i and S j Similarity between, optional, Sim(S j ,S i ) is obtained based on the recall-oriented understudy for gisting evaluation (ROUGE). It indicates that the sum is calculated for j=1 to j=n, where n is the number of the first processing results.
[0130] In another possible implementation, the text processing device obtains the second consistency score by performing the following steps: determining a first correlation between the second processing result and a first processing result other than the second processing result among the n first processing results, obtaining (n-1) first correlations, and obtaining the second consistency score based on the sum of the (n-1) first correlations.
[0131] It should be understood that the second processing result is a description object selected for the purpose of briefly describing the technical solution, and should not be understood as determining only one of the n first consistency scores through the above implementation. In practical applications, any one of the n first consistency scores can be determined through the above implementation.
[0132] 202. Determine the first processing results among the n first processing results that correspond to the largest k of the n first consistency scores as k consistent results.
[0133] If the standard answer of the processing result of the target task is referred to as the standard answer, then each of the n different chains of thinking is intended to guide the language model to obtain a processing result close to the standard answer. However, the first processing result obtained by the language model under the guidance of different chains of thinking is different, so the accuracy of different first processing results in the n first processing results is different, where the accuracy of the first processing result is relative to the standard answer. Because each chain of thinking is intended to guide the language model to obtain a processing result close to the standard answer, each of the n first processing results is close to the standard answer. Therefore, the higher the accuracy of a first processing result among the n first processing results, the closer the first processing result is to the standard answer, and accordingly, the closer the other first processing results are to the first processing result, that is, the higher the consistency of the other first processing results with the first processing result. On the contrary, the lower the accuracy of a first processing result among the n first processing results, the farther the first processing result is from the standard answer, and accordingly, the farther the other first processing results are from the first processing result, that is, the lower the consistency between the other first processing results and the first processing result. For example, the first processing result output by the language model for the target task may be: I don't know, and the accuracy of this first processing result is obviously low.
[0134] Because the first consistency score of the first processing result represents the consistency of the first processing result with other first processing results, the higher the first consistency score of the first processing result, the higher the accuracy of the first processing result. Therefore, the text processing device determines the first processing results corresponding to the largest k of the n first consistency scores among the n first processing results as k consistent results, and can select the k first processing results with the highest accuracy from the n first processing results as k consistent results, where k is an integer less than n.
[0135] For example, the n first processing results include the first processing result s1, the first processing result s2, and the first processing result s3, and the n first consistency scores include the first consistency score a, the first consistency score b, and the first consistency score c, wherein the first consistency score a is the first consistency score of the first processing result s1, the first consistency score b is the first consistency score of the first processing result s2, and the first consistency score c is the first consistency score of the first processing result s3. If the first consistency score a is greater than the first consistency score b, and the first consistency score b is greater than the first consistency score c, k=2. Then the two largest ones of the n first consistency scores are the first consistency score a and the first consistency score b. Since the first processing result corresponding to the first consistency score a is the first processing result s1, and the first processing result corresponding to the first consistency score b is the first processing result s2, the k consistent results include the first processing result s1 and the first processing result s2.
[0136] 203. Based on the k consistent results and the target task, generate the prompt word.
[0137] In this step, the prompt word is used to guide the language model to perform the target task based on the k consistent results. The text processing device can generate a prompt word based on the k consistent results and the above-mentioned target task, so that the prompt word includes the k consistent results, the target task, and a description of guiding the language model to perform the target task based on the k consistent results.
[0138] For example, k consistent results include: consistent result s1, consistent result s2. The target task is to answer question a, and the consistent result is the answer generated by the language model for question a. The prompt words include: The following answers have been generated for question a: consistent result s1, consistent result s2. Please determine the final answer to question a based on the above answers.
[0139] The text processing device performs the following steps during the process of executing step 104:
[0140] 204. Under the guidance of the prompt word, the language model is used to fuse the contents of the k consistent results to obtain the execution result.
[0141] In this step, after generating the prompt word, the text processing device uses the prompt word to perform the target task, merges the contents of the k consistent results, and uses the merged answer as the execution result. By merging the contents of the k consistent results, it is possible to use the contents of different consistent results to perform the target task and obtain the execution result. In this way, the execution result includes the contents from different consistent results.
[0142] In one possible implementation, the evaluation device, under the guidance of the prompt word, uses the language model to fuse the common content of semantic matching in the k consistent results to obtain the execution result of the target task. The implementation method of fusing the common content can be found in the description of step 104, which will not be repeated here.
[0143] In another possible implementation, the language model divides each consistent result into at least two segments of second segmented text. The correlation between the second segmented text belonging to different consistent results is determined. Optionally, the correlation between the second segmented text is the Spearman rank correlation coefficient between the second segmented text. Optionally, the correlation between the second segmented text is the Pearson correlation coefficient between the second segmented text. When the correlation between the two segments of second segmented text is greater than or equal to a correlation threshold, one of the two segments of second segmented text is selected as the third candidate text, and at least one segment of third candidate text can be obtained. The language model generates the execution result of the target task based on the at least one segment of third candidate text.
[0144] In this implementation, if the correlation between the two second segmented texts is greater than or equal to the correlation threshold, it means that the same content appears in different consistent results, which means that the confidence of the content of the two second segmented texts is high. At this time, at least one third candidate text is obtained by selecting one of the two second segmented texts as the third candidate text. Then, the execution result of the target task is generated based on at least one third candidate text, which can improve the accuracy of the execution result. In this way, it is possible to use the content in different consistent results to execute the target task and obtain the execution result.
[0145] In another possible implementation, the language model divides each consistent result into at least two segments of second segmented text. All second segmented text are clustered to obtain at least one second cluster set, wherein the second cluster set is a set of second segmented text, the correlation between the second segmented text in the same second cluster set is greater than or equal to the correlation threshold, and the correlation between the second segmented text in different second cluster sets is less than the correlation threshold. For each second cluster set, a segment of second segmented text is randomly selected as the fourth candidate text to obtain at least one segment of fourth candidate text. The language model generates the execution result of the target task based on at least one segment of fourth candidate text.
[0146] In this implementation, the second segmented characters with high correlation are divided into the same second cluster set by clustering, thereby achieving the division of the contents of the n consistent results into at least one second cluster set. At this time, for each second cluster set, a second segmented character is selected as the fourth candidate character, and at least one fourth candidate character is obtained. Then, the execution result of the target task is generated based on at least one fourth candidate character, so that the execution result can be obtained by executing the target task using the contents of different consistent results.
[0147] In this embodiment, the text processing device determines n first consistency scores of the n first processing results based on the n first processing results. The first processing results corresponding to the largest k of the n first consistency scores are determined as k consistent results. Then, based on the k consistent results and the target task, a prompt word is generated, which can improve the accuracy of the content in the prompt word. Under the guidance of the prompt word, the k consistent results are fused using a language model to obtain an execution result, which can improve the accuracy of the execution result.
[0148] As an optional implementation, the text processing device performs the following steps during the process of executing step 203:
[0149] 301. Cluster the k consistent results to obtain m result sets.
[0150] In the embodiment of the present application, m is a positive integer less than k, and the result set is a set of consistent results. The text processing device divides the k consistent results into m categories according to the degree of semantic matching by executing step 301, wherein one category is one result set. The semantic matching degree of consistent results in the same result set is high, and the semantic matching degree of consistent results in different result sets is low. Optionally, if the semantic matching degree of two consistent results is greater than or equal to the semantic threshold, it means that the semantic matching degree of the two consistent results is high, and if the semantic matching degree of the two consistent results is less than the semantic threshold, it means that the semantic matching degree of the two consistent results is low.
[0151] Optionally, the text processing device clusters the k consistent results by the following methods to obtain m result sets: K-means clustering, aggregate clustering, and mean shift algorithm.
[0152] 302. Based on the above m result sets, obtain m first clustering results.
[0153] In an embodiment of the present application, the first clustering result corresponds to the result set one-to-one. Specifically, the text processing device obtains a first clustering result based on one result set, and obtains m first clustering results based on m result sets. In one possible implementation, for any one of the m result sets, the consistent result closest to the center of the set is determined from the set as the first clustering result, and m first clustering results are obtained. Optionally, the text processing device obtains the center of the result set by calculating the average value of the consistent results in the result set. In another possible implementation, for any one of the m result sets, the center of the set is determined as the first clustering result, and m first clustering results are obtained. In yet another possible implementation, for any one of the m result sets, the consistent result closest to the centroid of the set is determined from the set as the first clustering result, and m first clustering results are obtained.
[0154] 303. Generate the prompt word based on the m first clustering results and the target task.
[0155] In the embodiment of the present application, the prompt word is used to guide the language model to perform the target task based on the m first clustering results;
[0156] In this step, the prompt word is used to guide the language model to perform the target task based on the m first clustering results. The text processing device can generate a prompt word based on the m first clustering results and the target task, so that the prompt word includes the m first clustering results, the target task, and a description of guiding the language model to perform the target task based on the m first clustering results.
[0157] For example, the m first clustering results include: first clustering result s1, first clustering result s2. The target task is to answer question a, and the first clustering result is the answer generated by the language model for question a. The prompt words include: The following answers have been generated for question a: first clustering result s1, first clustering result s2. Please determine the final answer to question a based on the above answers.
[0158] After obtaining the prompt word by executing step 303, the text processing device performs the following steps in the process of executing step 204:
[0159] 304. Under the guidance of the prompt word, the language model is used to fuse the contents of the m first clustering results to obtain the execution result.
[0160] In this step, after generating the prompt word, the text processing device uses the prompt word to perform the target task, fuses the contents of the m first clustering results, and uses the fused answer as the execution result. By fusing the contents of the m first clustering results, it is possible to use the contents of different first clustering results to perform the target task and obtain the execution result. In this way, the execution result includes the contents from different first clustering results.
[0161] In one possible implementation, the evaluation device, under the guidance of the prompt word, uses the language model to fuse the common contents of the m first clustering results with semantic matching to obtain the execution result of the target task. The implementation method of fusing the common contents can be found in the description of step 104, which will not be repeated here.
[0162] In another possible implementation, the language model divides each first clustering result into at least two third segmented texts. The correlation between the third segmented texts belonging to different first clustering results is determined. Optionally, the correlation between the third segmented texts is the Spearman rank correlation coefficient between the third segmented texts. Optionally, the correlation between the third segmented texts is the Pearson correlation coefficient between the third segmented texts. When the correlation between the two third segmented texts is greater than or equal to the correlation threshold, one of the two third segmented texts is selected as the fifth candidate text, and at least one fifth candidate text can be obtained. The language model generates the execution result of the target task based on the at least one fifth candidate text.
[0163] In this implementation, if the correlation between the two third segmented texts is greater than or equal to the correlation threshold, it means that the same content appears in different first clustering results, which means that the confidence of the content of the two third segmented texts is high. At this time, at least one fifth candidate text is obtained by selecting one of the two third segmented texts as the fifth candidate text. Then, the execution result of the target task is generated based on at least one fifth candidate text, which can improve the accuracy of the execution result. In this way, it is possible to use the content in different first clustering results to execute the target task and obtain the execution result.
[0164] In another possible implementation, the language model divides each first clustering result into at least two third segmented texts. All third segmented texts are clustered to obtain at least one third cluster set, wherein the third cluster set is a set of third segmented texts, the correlation between the third segmented texts in the same third cluster set is greater than or equal to the correlation threshold, and the correlation between the third segmented texts in different third cluster sets is less than the correlation threshold. For each third cluster set, a segment of the third segmented text is randomly selected as the sixth candidate text to obtain at least one segment of the sixth candidate text. The language model generates the execution result of the target task based on at least one segment of the sixth candidate text.
[0165] In this implementation, the third segmented characters with high correlation are divided into the same third cluster set by clustering, thereby achieving the division of the contents of the n first cluster results into at least one third cluster set. At this time, for each third cluster set, a segment of the third segmented characters is randomly selected as the sixth candidate character, and at least one segment of the sixth candidate character is obtained. Then, the execution result of the target task is generated based on at least one segment of the sixth candidate character, so that the execution result can be obtained by using the contents of different first cluster results to execute the target task.
[0166] In this embodiment, the text processing device clusters k consistent results to obtain m result sets. Based on the m result sets, m first clustering results are obtained. Based on the m first clustering results and the target task, prompt words are generated, and the number of results output by the language model can be reduced from k to k, thereby reducing the amount of data required to be processed by the subsequent language model. Under the guidance of the prompt words, the language model is used to fuse the m first clustering results to obtain an execution result, which can improve the accuracy of the execution result.
[0167] As an optional implementation, m is greater than 1, and the m first clustering results include the second clustering result and the third clustering result, wherein the second clustering result and the third clustering result are any two of the m first clustering results. The second clustering result includes the first paragraph, and the third clustering result includes the second paragraph.
[0168] The language model performs the following steps in the process of fusing the common content in the m clustering results and obtaining the execution result:
[0169] 401. The language model determines a first position of the first paragraph in the second clustering result.
[0170] In the embodiment of the present application, the first position is the position of the first paragraph in the second clustering result. Since the results output by the language model are all text, the second clustering result is text. The position of the first paragraph in the second clustering result is the position of the first paragraph in the text. In a possible implementation, the first position is the position of the first line of the first paragraph in the second clustering result. For example, the first line of the first paragraph is the 5th line in the second clustering result, then the first position is the 5th line.
[0171] In another possible implementation, the first paragraph is obtained by dividing the second clustering result, and the first position is the order of the first paragraph in all the paragraphs obtained by the division, wherein the paragraph order represents the order in which the content in the paragraph appears in the second clustering result. For example, the second clustering result includes 15 lines, and the following three paragraphs are obtained by dividing the second clustering result: the first paragraph, paragraph a, and paragraph b, wherein the first paragraph includes lines 1 to 5 in the second clustering result, paragraph a includes lines 6 to 10 in the second clustering result, and paragraph b includes lines 11 to 15 in the second clustering result. At this time, in the second clustering result, the content in the first paragraph appears before the content in paragraph a and the content in paragraph b, so the order of the first paragraph is 1, that is, the first position is 1.
[0172] 402. The language model determines a second position of the second paragraph in the third clustering result.
[0173] In the embodiment of the present application, the second position is the position of the second paragraph in the third clustering result. The meaning of the second position can be found in the explanation of the first position in step 401, and will not be repeated here.
[0174] 403. The language model determines a second similarity between the first position and the second position.
[0175] In the embodiment of the present application, the greater the second similarity, the smaller the difference between the first position and the second position, that is, the second similarity is negatively correlated with the difference. In one possible implementation, the language model determines the absolute value of the difference between the first position and the second position as the second similarity. In another possible implementation, the language model determines the ratio of the first position to the second position, and determines the absolute value of the difference between the ratio and 1 as the second similarity.
[0176] 404. The language model determines a third similarity between the semantics of the first paragraph and the semantics of the second paragraph.
[0177] 405. When the weighted sum of the second similarity and the third similarity is greater than or equal to a threshold, the language model merges the first paragraph with the second paragraph to obtain the execution result.
[0178] On the one hand, since the expression of text is usually logical, and the second clustering results and the third clustering results are both texts, the second clustering results and the third clustering results are both logical. And because the second clustering results and the third clustering results are both used to express the execution results of the target task, the expression logic of the second clustering results and the expression logic of the third clustering results are similar. Therefore, the difference between the position of the common content in the second clustering results and the position in the third clustering results should be small. Since the second similarity can characterize the difference between the position of the first paragraph in the second clustering results and the position of the second paragraph in the third clustering results, the second similarity can be used as a basis for judging whether the first paragraph and the second paragraph are common content.
[0179] On the other hand, the higher the similarity between the semantics of the first paragraph and the semantics of the second paragraph, the higher the matching degree between the semantics of the first paragraph and the semantics of the second paragraph, and the higher the probability that the first paragraph and the second paragraph have common content. The third similarity is the similarity between the semantics of the first paragraph and the semantics of the second paragraph, so the third similarity can also be used as a basis for judging whether the first paragraph and the second paragraph have common content.
[0180] Based on this, by weighting and summing the second similarity and the third similarity, a basis for judging whether the first paragraph and the second paragraph have common content can be obtained. Specifically, the weighted sum of the second similarity and the third similarity can be used as a basis for judging whether the first paragraph and the second paragraph have common content, wherein the larger the weighted sum is, the greater the probability that the first paragraph and the second paragraph have common content. The text processing device uses the threshold as a basis to judge whether the weighted sum is large or small. Specifically, if the weighted sum is greater than or equal to the threshold, it means that the weighted sum is large, and then it is determined that the first paragraph and the second paragraph have common content, and the language model thus fuses the first paragraph and the second paragraph to obtain an execution result. On the contrary, if the weighted sum is less than the threshold, it means that the weighted sum is small, and then it is determined that the first paragraph and the second paragraph do not have common content, and the language model thus does not fuse the first paragraph and the second paragraph to obtain an execution result.
[0181] In this embodiment, the text processing device uses a language model to determine a first position of the first paragraph in the second clustering result. The language model is used to determine a second position of the second paragraph in the third clustering result. The language model is used to determine a second similarity between the first position and the second position. The language model is used to determine a third similarity between the semantics of the first paragraph and the semantics of the second paragraph. When the weighted sum of the second similarity and the third similarity is greater than or equal to a threshold value, the language model is used to fuse the first paragraph and the second paragraph to obtain an execution result, thereby improving the accuracy of the execution result.
[0182] It should be understood that the execution subject of steps 401 to 405 is a text processing device. Specifically, the text processing device executes steps 401 to 405 using a language model.
[0183] See also Figure 3 , Figure 3 A comparison diagram of SBS and FSC provided in the embodiment of the present application. Figure 3 As shown in , the approach of SBS is: after the question is input into the language model, the language model answers the question according to n different chains of thought, and obtains n candidate answers, where each candidate answer is an answer to the question. Then one candidate answer is selected from the n candidate answers as the final answer to the question, as shown in Figure 3 As shown, the final answer is the second candidate answer.
[0184] Optionally, after obtaining n first processing results, the SBS determines n third consistency scores corresponding to the n candidate answers, wherein the implementation method of determining the third consistency score can refer to the implementation method of determining the first consistency score described above. The candidate answer corresponding to the maximum value of the n third consistency scores is taken as the final answer.
[0185] In the process of executing FSC, the language model answers the question based on n different chains of thought (i.e., performs the target task on the processed text) and obtains n first processing results, where each first processing result is an answer to the question. Then the language model is used to extract common content with semantic matching from the n first processing results, such as Figure 3 As shown, the language model extracts common content for each paragraph. Specifically, a common content is extracted for paragraph I, a common content is extracted for paragraph II, a common content is extracted for paragraph III, a common content is extracted for paragraph IV, and a common content is extracted for paragraph V. Finally, the common content is merged to generate the final answer.
[0186] By comparison, it can be seen that the final answer output by FSC integrates the common content of the n first processing results, so that the fine-grainedness of the output final answer is at the paragraph level, while the final answer output by SBS is one of the n first processing results. Therefore, the fine-grainedness of the final answer output by SBS is weaker than that of the final answer output by FSC.
[0187] See also Figure 4 , Figure 4A flow chart of FSC provided for an embodiment of the present application. Specifically, before executing FSC, the language model performs the target task on the text to be processed based on n different chains of thinking to obtain n first processing results. First, in the consistency screening stage, the first processing results with high first consistency scores are screened from the n first processing results, and the first processing results with low first consistency scores are eliminated. Specifically, the k first processing results with the largest first consistency scores among the n first processing results are selected as the first processing results with high first consistency scores. Correspondingly, the first processing results other than the first processing results with the largest k first consistency scores are first processing results with low first consistency scores. Figure 4 As shown, k first processing results with the highest first consistency scores are selected to obtain k consistent results, and the k consistent results include: first processing result s1, first processing result s2, first processing result s3, first processing result s4, first processing result s5, ...
[0188] Then, in the clustering stage, the k consistent results are clustered to obtain m result sets. Figure 4 Three of the m result sets are shown, which are a set of triangles, a set of rectangles, and a set of parallelograms. Then, m first clustering results are obtained based on the m result sets. Figure 4 Three of the m first clustering results are shown, represented by a triangle, a rectangle, and a parallelogram, respectively.
[0189] In the fine-grained self-consistency stage, prompt words are generated based on the m first clustering results and the target task. Figure 4 As shown, the prompt word includes m first clustering results, a target task, and a description of guiding the language model to perform the target task based on the m first clustering results. Figure 4 In the example, the m first clustering results include the first processing result s1{s1 text} and the first processing result s2{s2 text}. The target task is to generate a summary of the text to be processed. The description of guiding the language model to perform the target task based on the m first clustering results is: Please merge the common content of the above summaries to generate a final summary. Under the guidance of the prompt word, the language model merges the common content of the above summaries to generate a final summary.
[0190] See also Figure 5 , Figure 5 A flowchart of another text processing method provided in an embodiment of the present application. Figure 5As shown, after obtaining the text to be processed, the text processing device uses the language model to perform model answer sampling. Specifically, the language model performs the target task on the text to be processed according to n different chains of thinking, and obtains n first processing results as a candidate sample set. According to the consistency algorithm, a consistent sample set is obtained by screening from the n first processing results. Specifically, based on the first consistency score, k consistent results are screened out from the n first processing results as a consistent sample set. Based on the clustering algorithm, the k consistent results are clustered to obtain m result sets, and then based on the m result sets, m first clustering results are obtained as clustering sample sets. According to the fine-grained self-consistency method, the m first clustering results are fused to obtain a final reply, which is the execution result of the target task. The implementation of this step can be seen in Figure 4 Description of the fine-grained self-consistency stage in .
[0191] The present application embodiment also provides the comparative data of FSC and other methods described above to illustrate the technical advantages of FSC. Please refer to Table 1, which shows that the language model uses different methods to perform target tasks on three different test sets. The methods used include random methods, self-consistency methods for open domain generation (Self-consistency for open-ended generations, UCS), unified self-consistency methods for large language model generation (Universal Self-Consistency for Large Language Model Generation, USC), and FSC, wherein the random method refers to the language model generating n candidate answers according to n different thinking chains, and randomly selecting one from the n candidate answers as the execution result of the target task. The three different test sets are the HumanEval test set, the HumanEval+ test set, and the BIRD-SQL test set, and the target task is to generate code.
[0192] Specifically, when using the deep learning model (generative pre-trained, GPT)-3.5-turbo to perform the task of generating code on the HumanEval test set, the accuracy of GPT-3.5-turbo in generating code using a random method is 69.8.
[0193] The accuracy of GPT-3.5-turbo using the UCS method to generate codes is 70.1, which is 0.3 higher than the random method. The accuracy of GPT-3.5-turbo using the USC method to generate codes is 70.5, which is 0.7 higher than the random method. The accuracy of GPT-3.5-turbo using the FSC method to generate codes is 74.5, which is 4.7 higher than the random method. When using GPT-3.5-turbo to generate codes for the HumanEval+ test set, the accuracy of GPT-3.5-turbo using the random method to generate codes is 63.2. The accuracy of GPT-3.5-turbo using the UCS method to generate codes is 63.2, which is not higher than the random method. The accuracy of GPT-3.5-turbo using the USC method to generate codes is 66.3, which is 3.1 higher than the random method. The accuracy of GPT-3.5-turbo's code generation using the FSC method is 68.4, which is 5.2 points higher than the random method. When using GPT-3.5-turbo to generate code for the BIRD-SQL test set, the accuracy of GPT-3.5-turbo's code generation using the random method is 43.1, and the efficiency of the generated code is 43.9. The accuracy of GPT-3.5-turbo's code generation using the UCS method is 43.6, which is 0.5 points higher than the random method, and the efficiency of the generated code is 44.5, which is 0.6 points higher than the random method. The accuracy of GPT-3.5-turbo's code generation using the USC method is 43.6, which is 0.5 points higher than the random method, and the efficiency of the generated code is 44.6, which is 0.7 points higher than the random method. The accuracy of GPT-3.5-turbo's code generation using the FSC method is 45.3, which is an improvement of 2.2 compared to the random method. The efficiency of code generation is 46.0, which is an improvement of 2.1 compared to the random method.
[0194] When GPT-4 is used to generate codes for the HumanEval test set, the accuracy of GPT-4 using random methods to generate codes is 82.5. The accuracy of GPT-4 using the UCS method to generate codes is 82.3, which is 0.2 points lower than the random method. The accuracy of GPT-4 using the USC method to generate codes is 86.1, which is 3.6 points higher than the random method. The accuracy of GPT-4 using the FSC method to generate codes is 87.1, which is 4.6 points higher than the random method. When GPT-4 is used to generate codes for the HumanEval+ test set, the accuracy of GPT-4 using random methods to generate codes is 76.4. The accuracy of GPT-4 using the UCS method to generate codes is 76.7, which is 0.3 points higher than the random method. The accuracy of GPT-4 using the USC method to generate codes is 80.9, which is 4.5 points higher than the random method. The accuracy of GPT-4 code generation using the FSC method is 82.8, which is 6.4% higher than the random method. When using GPT-4 to generate code for the BIRD-SQL test set, the accuracy of GPT-4 code generation using the random method is 49.5, and the efficiency of generation is 50.6. The accuracy of GPT-4 code generation using the UCS method is 50.5, which is 1.0 higher than the random method, and the efficiency of code generation is 51.8, which is 1.2 higher than the random method. The accuracy of GPT-4 code generation using the USC method is 50.9, which is 1.4 higher than the random method, and the efficiency of code generation is 51.6, which is 1.0 higher than the random method. The accuracy of GPT-4's code generation using the FSC method is 51.4, which is an improvement of 1.9 compared to the random method. The efficiency of code generation is 52.2, which is an improvement of 1.6 compared to the random method.
[0195]
[0196] Table 1
[0197] Based on the experimental results shown in Table 1, it can be seen that for the task of executing generated code, FSC can achieve the best results on all three test sets compared with the random method and the USC method.
[0198] Please refer to Table 2, which shows the results of the language model using different methods to perform the task of generating text summaries based on different test sets. Specifically, when using GPT-3.5-turbo to generate text summaries for the news text (DailyMail) test set, the recall-oriented understudy for gisting evaluation 1, Rouge 1, generated by GPT-3.5-turbo using the random method, was 37.3, Rouge 2 was 14.1, Rouge L was 38.4, and the Bert Score was 60.6. The Rouge 1, Rouge 2, Rouge L, and Bert Score of the text summaries generated by GPT-3.5-turbo using the UCS method were 36.9, 14.0, 38.2, and 60.5, respectively. The Rouge 1, Rouge 2, Rouge L, and Bert Score of the text summaries generated by GPT-3.5-turbo using the USC method were 37.7, 14.3, 38.7, and 60.8, respectively. The text summary generated by GPT-3.5-turbo using the FSC method has a Rouge1 of 38.6, a Rouge2 of 14.4, a RougeL of 39.0, and a BertScore of 60.9.
[0199] When using GPT-3.5-turbo to generate text summaries for the TV drama summary (SummScreen) test set, the Rouge1 of the text summary generated by GPT-3.5-turbo using the random method is 18.3, Rouge2 is 2.1, RougeL is 16.8, and BertScore is 48.8. The Rouge1 of the text summary generated by GPT-3.5-turbo using the UCS method is 16.9, Rouge2 is 2.0, RougeL is 16.4, and BertScore is 48.3. The Rouge1 of the text summary generated by GPT-3.5-turbo using the USC method is 19.3, Rouge2 is 2.3, RougeL is 17.2, and BertScore is 49.3. The Rouge1 of the text summary generated by GPT-3.5-turbo using the FSC method is 20.1, Rouge2 is 2.1, RougeL is 17.4, and BertScore is 49.6.
[0200] The above data show that when using GPT-3.5-turbo to generate text summaries for the DailyMail test set and the SummScreen test set, the text summaries generated by GPT-3.5-turbo using the FSC method are judged as the best text summaries in most of the evaluation indicators of the test. Only when generating text summaries for the SummScreen test set, the text summaries generated by GPT-3.5-turbo using the FSC method are weaker than the text summaries generated using the USC method on Rouge2.
[0201] When using GPT-4 to generate text summaries for the DailyMail test set, GPT-4 generated text summaries using the random method with a Rouge1 score of 37.5, a Rouge2 score of 14.5, a RougeL score of 38.9, and a BertScore of 61.0. GPT-4 generated text summaries using the UCS method with a Rouge1 score of 36.9, a Rouge2 score of 14.3, a RougeL score of 38.6, and a BertScore of 60.9. GPT-4 generated text summaries using the USC method with a Rouge1 score of 37.6, a Rouge2 score of 14.6, a RougeL score of 39.0, and a BertScore of 61.1. GPT-4 generated text summaries using the FSC method with a Rouge1 score of 38.1, a Rouge2 score of 14.7, a RougeL score of 39.3, and a BertScore of 61.2.
[0202] When using GPT-4 to generate text summaries on the SummScreen test set, GPT-4 uses the random method to generate text summaries with Rouge1 of 19.1, Rouge2 of 2.6, RougeL of 17.3, and BertScore of 49.5. GPT-4 uses the UCS method to generate text summaries with Rouge1 of 18.6, Rouge2 of 2.4, RougeL of 17.0, and BertScore of 49.3. GPT-4 uses the USC method to generate text summaries with Rouge1 of 19.3, Rouge2 of 2.7, RougeL of 17.5, and BertScore of 49.6. GPT-4 uses the FSC method to generate text summaries with Rouge1 of 19.5, Rouge2 of 2.9, RougeL of 17.8, and BertScore of 50.0.
[0203]
[0204] Table 2
[0205] The above data show that when using GPT-4 to generate text summaries for the DailyMail test set and the SummScreen test set, the text summaries generated by GPT-3.5-turbo using the FSC method are judged as the best text summaries in all evaluation indicators of the test.
[0206] Please refer to Table 3, which shows the results of the model using different methods to perform math problem solving tasks based on different test sets. Specifically, when using GPT-3.5-turbo to perform math problem solving tasks on the grade school math (GSM) 8k test set, the accuracy of the math answers obtained by GPT-3.5-turbo using the random method is 75.9. The accuracy of the math answers solved by GPT-3.5-turbo using the UCS method is 77.2. The accuracy of the math answers solved by GPT-3.5-turbo using the USC method is 80.6. The accuracy of the math answers solved by GPT-3.5-turbo using the Self-Consistency (SC) method is 82.0. The accuracy of the math answers solved by GPT-3.5-turbo using the FSC method is 81.0.
[0207] When using GPT-3.5-turbo to perform math problem solving tasks on the math (MATH) test set, the accuracy of the math answers obtained by GPT-3.5-turbo using the random method is 35.0. The accuracy of the math answers obtained by GPT-3.5-turbo using the UCS method is 35.6. The accuracy of the math answers obtained by GPT-3.5-turbo using the USC method is 39.3. The accuracy of the math answers obtained by GPT-3.5-turbo using the SC method is 41.9. The accuracy of the math answers obtained by GPT-3.5-turbo using the FSC method is 39.5.
[0208] The above data show that when using GPT-3.5-turbo to perform math problem solving tasks on the GSM8k test set and the MATH test set, the accuracy of the math answers obtained by GPT-3.5-turbo using the FSC method is second only to the accuracy of the math answers obtained using the SC method.
[0209] When using GPT-4 to perform math problem-solving tasks on the GSM8k test set, the accuracy of the math answers obtained by GPT-4 using the random method is 87.5. The accuracy of the math answers obtained by GPT-4 using the UCS method is 87.6. The accuracy of the math answers obtained by GPT-4 using the USC method is 88.1. The accuracy of the math answers obtained by GPT-4 using the SC method is 88.8. The accuracy of the math answers obtained by GPT-4 using the FSC method is 91.3.
[0210] When using GPT-4 to perform math problem-solving tasks on the MATH test set, the accuracy of the math answers obtained by GPT-4 using the random method is 50.2. The accuracy of the math answers obtained by GPT-4 using the UCS method is 50.7. The accuracy of the math answers obtained by GPT-4 using the USC method is 54.8. The accuracy of the math answers obtained by GPT-4 using the SC method is 55.5. The accuracy of the math answers obtained by GPT-4 using the FSC method is 56.0.
[0211]
[0212] Table 3
[0213] The above data show that when using GPT-4 to perform math problem-solving tasks on the GSM8k test set and the MATH test set, the math answers obtained by GPT-4 using the FSC method have the highest accuracy.
[0214] Please refer to Table 4, which shows the results of the model using different methods to perform the task of generating codes based on the distribution ratio of different error samples and correct samples. Specifically, GPT-3.5-turbo is used to perform the task of generating codes on the HumanEval test set. When the generated initial sample is 5 error sample codes and 0 correct sample codes, the accuracy of the code generated by GPT using the random method is 0%. The accuracy of the code generated by GPT using the UCS method is 0%. The accuracy of the code generated by GPT using the USC method is 0%. The accuracy of the code generated by GPT using the FSC method is 1.1%. When the generated initial sample is 4 error sample codes and 1 correct sample code, the accuracy of the code generated by GPT using the random method is 20%. The accuracy of the code generated by GPT using the UCS method is 13.9%. The accuracy of the code generated by GPT using the USC method is 13.9%. The accuracy of the code generated by GPT using the FSC method is 27.9%. When the generated initial sample is 3 error sample codes and 2 correct sample codes, the accuracy of the code generated by GPT using the random method is 40%. The accuracy of the code generated by GPT using the UCS method is 35.8%. The accuracy of the code generated by GPT using the USC method is 47.1%. The accuracy of the code generated by GPT using the FSC method is 62.2%. When the initial sample generated is 2 wrong sample codes and 3 correct sample codes, the accuracy of the code generated by GPT using the random method is 60%. The accuracy of the code generated by GPT using the UCS method is 68.3%. The accuracy of the code generated by GPT using the USC method is 56.6%. The accuracy of the code generated by GPT using the FSC method is 70.0%. When the initial sample generated is 1 wrong sample code and 4 correct sample codes, the accuracy of the code generated by GPT using the random method is 80%. The accuracy of the code generated by GPT using the UCS method is 82.1%. The accuracy of the code generated by GPT using the USC method is 86.9%. The accuracy of the code generated by GPT using the FSC method is 91.6%.
[0215] The above data show that when using GPT-3.5-turbo to perform the task of generating code on the HumanEval test set, the distribution ratio of incorrect samples and correct samples of the input samples is in any case. The code generated by GPT-3.5-turbo using the FSC method has the highest accuracy.
[0216] GPT-4 is used to perform the code generation task on the HumanEval test set. When the generated initial sample is 5 wrong sample codes and 0 correct sample codes, the accuracy of the code generated by GPT using the random method is 0%. The accuracy of the code generated by GPT using the UCS method is 0%. The accuracy of the code generated by GPT using the USC method is 0%. The accuracy of the code generated by GPT using the FSC method is 2.2%. When the generated initial sample is 4 wrong sample codes and 1 correct sample code, the accuracy of the code generated by GPT using the random method is 20%. The accuracy of the code generated by GPT using the UCS method is 23.1%. The accuracy of the code generated by GPT using the USC method is 16.6%. The accuracy of the code generated by GPT using the FSC method is 29.1%. When the generated initial sample is 3 wrong sample codes and 2 correct sample codes, the accuracy of the code generated by GPT using the random method is 40%. The accuracy of the code generated by GPT using the UCS method is 31.0%. The accuracy of the code generated by GPT using the USC method is 51.7%. The accuracy of the code generated by GPT using the FSC method is 55.1%. When the initial sample generated is 2 wrong sample codes and 3 correct sample codes, the accuracy of the code generated by GPT using the random method is 60%. The accuracy of the code generated by GPT using the UCS method is 65.9%. The accuracy of the code generated by GPT using the USC method is 87.2%. The accuracy of the code generated by GPT using the FSC method is 82.9%. When the initial sample generated is 1 wrong sample code and 4 correct sample codes, the accuracy of the code generated by GPT using the random method is 80%. The accuracy of the code generated by GPT using the UCS method is 73.6%. The accuracy of the code generated by GPT using the USC method is 91.6%. The accuracy of the code generated by GPT using the FSC method is 97.2%.
[0217]
[0218] Table 4
[0219] The above data shows that when GPT-4 is used to perform the code generation task on the HumanEval test set, when the distribution ratio of incorrect samples and correct samples of the input samples is 2 / 3, the accuracy of the code generated by GPT-4 using the FSC method is slightly lower than the accuracy of the code generated by GPT-4 using the USC method. In other cases, the accuracy of the code generated by GPT-4 using the FSC method is the highest.
[0220] Please refer to Table 5, which shows the results of using a small model such as the Mistral-7B model to perform code generation tasks using different methods based on different test sets. Specifically, when the Mistral-7B model is used to generate code for the HumanEval test set, the accuracy of the Mistral-7B model using the random method to generate code is 19.7. The accuracy of the Mistral-7B model using the UCS method to generate code is 20.3. The accuracy of the Mistral-7B model using the USC method to generate code is 26.2. The accuracy of the Mistral-7B model using the FSC method to generate code is 29.9.
[0221] When using a small model such as the Mistral-7B model to generate code for the HumanEval+ test set, the Mistral-7B model has an accuracy of 16.9 using the random method to generate code. The Mistral-7B model has an accuracy of 17.2 using the UCS method to generate code. The Mistral-7B model has an accuracy of 21.9 using the USC method to generate code. The Mistral-7B model has an accuracy of 24.4 using the FSC method to generate code.
[0222] method HumanEval test set HumanEval+ test set Random 19.7 16.9 UCS 20.3 17.2 USC 26.2 21.9 FSC 29.9 24.4
[0223] Table 5
[0224] The above data show that when a small model such as the Mistral-7B model is used to perform tasks, the Mistral-7B model can also improve the accuracy of task execution using the FSC method.
[0225] Please refer to Table 6, which is a comparison of the results of the task of generating text summaries using different methods using GPT-4 based on different test sets. Specifically, there is a word segment library, which is used to match the overlap with the text summary generated by the model. When the overlap is higher, the generated text summary is more accurate. When using GPT-4 to perform the task of generating text summaries on the DailyMail test set, there is a 79.2% probability that the overlap between the text summary generated by GPT-4 using the FSC method and the word segment library is better than the overlap between the text summary generated by GPT-4 using the UCS method and the word segment library. There is a 67.1% probability that the overlap between the text summary generated by GPT-4 using the FSC method and the word segment library is better than the overlap between the text summary generated by GPT-4 using the USC method and the word segment library.
[0226] When using GPT-4 to perform the task of generating text summaries on the Summscreen test set, the overlap between the text summaries generated by GPT-4 using the FSC method and the word segment library is 67.6% higher than the overlap between the text summaries generated by GPT-4 using the UCS method and the word segment library. The overlap between the text summaries generated by GPT-4 using the FSC method and the word segment library is 81.8% higher than the overlap between the text summaries generated by GPT-4 using the USC method and the word segment library.
[0227] Win Rate FSC vs UCS FSC vs USC DailyMail test suite 79.2% 67.1% Summscreen test set 87.6% 81.8%
[0228] Table 6
[0229] The above data show that when GPT-4 performs the task of generating text summaries, the text summaries generated by GPT-4 using the FSC method have a higher degree of overlap with the word library, and the generated text summaries are more accurate.
[0230] In one possible implementation scenario, the target task is to extract a summary of the text. Based on the text processing method described above, extracting a summary of the text can improve the accuracy of the extracted summary. Specifically, after obtaining the text to be processed, the language model is used to extract the summary of the text to be processed according to n different chains of thought to obtain n first processing results, wherein the first processing results include candidate summaries of the text to be processed. Based on the candidate summaries in the n first processing results and the task of extracting the summary of the text to be processed, prompt words are generated, wherein the prompt words are used to guide the language model to generate a final summary of the text to be processed based on the candidate summaries in the n first processing results. Under the guidance of the prompt words, the candidate summaries in the n first processing results are merged using the language model to obtain the final summary of the text to be processed.
[0231] Optionally, after obtaining n first processing results, the text processing device obtains k consistent results based on step 201 and step 202. Then, based on the candidate summaries in the k consistent results and the task of extracting the summary of the text to be processed, a prompt word is generated, wherein the prompt word is used to guide the language model to generate a final summary of the text to be processed based on the candidate summaries in the k consistent results. Under the guidance of the prompt word, the candidate summaries in the k consistent results are merged using the language model to obtain the final summary of the text to be processed.
[0232] Optionally, after obtaining k consistent results, the text processing device obtains m first clustering results based on step 301 and step 302. Then, based on the candidate summaries in the m first clustering results and the task of extracting the summary of the text to be processed, a prompt word is generated, wherein the prompt word is used to guide the language model to generate a final summary of the text to be processed based on the candidate summaries in the m first clustering results. Under the guidance of the prompt word, the candidate summaries in the m first clustering results are merged using the language model to obtain the final summary of the text to be processed.
[0233] Optionally, the text to be processed is a note. In this case, the target task is to extract a summary of the note. Extracting the summary of the note based on the text processing method described above can improve the accuracy of the summary of the note.
[0234] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0235] The method of the embodiment of the present application is described in detail above, and the device of the embodiment of the present application is provided below.
[0236] See also Figure 6 , Figure 6 This is a structural diagram of a text processing device provided in an embodiment of the present application. The text processing device 1 includes: an acquisition unit 11, a processing unit 12, and a generation unit 13. Specifically:
[0237] An acquisition unit 11 is used to acquire the text to be processed;
[0238] A processing unit 12 is used to use a language model to perform a target task on the text to be processed according to n different chains of thought to obtain n first processing results, where the target task is a natural language processing task, and n is an integer greater than 1;
[0239] A generating unit 13, configured to generate a prompt word based on the n first processing results and the target task, wherein the prompt word is used to guide the language model to perform the target task based on the n first processing results;
[0240] The processing unit 12 is used to obtain the execution result of the target task by fusing the contents of the n first processing results using the language model under the guidance of the prompt word.
[0241] In combination with any embodiment of the present application, the generating unit 13 is specifically used for:
[0242] Based on the n first processing results, determine n first consistency scores of the n first processing results, where the first consistency scores correspond to the first processing results one by one, and the first consistency scores represent the consistency between the first processing result and the n first processing results;
[0243] Determine that the first processing results corresponding to the largest k of the n first consistency scores among the n first processing results are k consistent results, where k is a positive integer less than n;
[0244] Based on the k consistent results and the target task, generating the prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the k consistent results;
[0245] The processing unit 12 is specifically used for:
[0246] Under the guidance of the prompt word, the language model is used to fuse the contents of the k consistent results to obtain the execution result.
[0247] In combination with any implementation manner of the present application, the n first processing results include a second processing result, the n first consistency scores include a second consistency score, and the second consistency score is the first consistency score of the second processing result;
[0248] The generating unit 13 is specifically used for:
[0249] Determine a first similarity between the second processing result and the first processing results other than the second processing result among the n first processing results, and obtain (n-1) first similarities;
[0250] The second consistency score is obtained based on the sum of the (n-1) first similarities.
[0251] In combination with any embodiment of the present application, the generating unit 13 is specifically used for:
[0252] Clustering the k consistent results to obtain m result sets, where m is a positive integer less than k, and the result set is a set of the consistent results;
[0253] Based on the m result sets, m first clustering results are obtained, where the first clustering results correspond one-to-one to the result sets;
[0254] Based on the m first clustering results and the target task, generating the prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the m first clustering results;
[0255] The processing unit 12 is specifically used for:
[0256] Under the guidance of the prompt word, the language model is used to fuse the contents of the m first clustering results to obtain the execution result.
[0257] In combination with any embodiment of the present application, the generating unit 13 is specifically used for:
[0258] For any one of the m result sets, determine the consistent result closest to the center of the set from the set as the first clustering result, and obtain the m first clustering results.
[0259] In combination with any embodiment of the present application, the processing unit 12 is specifically used for:
[0260] Under the guidance of the prompt word, the language model fuses common contents with semantic matching in the m first clustering results to obtain the execution result.
[0261] In combination with any embodiment of the present application, the m is greater than 1, the m first clustering results include a second clustering result and a third clustering result, the second clustering result includes the first paragraph, and the third clustering result includes the second paragraph;
[0262] The processing unit 12 is specifically used for:
[0263] Determining a first position of the first paragraph in the second clustering result using the language model;
[0264] Determining a second position of the second paragraph in the third clustering result by using the language model;
[0265] Determining a second similarity between the first position and the second position using the language model;
[0266] Determining a third similarity between the semantics of the first paragraph and the semantics of the second paragraph using the language model;
[0267] The first paragraph and the second paragraph are merged by using the language model when a weighted sum of the second similarity and the third similarity is greater than or equal to a threshold, to obtain the execution result.
[0268] In combination with any implementation manner of the present application, the target task is to extract a summary of the text.
[0269] In an embodiment of the present application, after obtaining the text to be processed, the text processing device uses a language model to perform a target task on the text to be processed according to n different chains of thought, and obtains n first processing results. A prompt word is generated based on the n first processing results and the target task. Under the guidance of the prompt word, the execution result of the target task can be obtained by fusing the contents of the n first processing results using a language model. Since different first processing results are obtained based on different chains of thought, the language model obtains the execution result of the target task by fusing the contents of the n first processing results, which can not only realize the use of different chains of thought to obtain the execution result, but also compared to selecting one from the n first processing results as the execution result, the text processing device uses the contents of different first execution results to obtain the execution result, thereby improving the accuracy of the execution result, and also enables the execution result to include the contents of different first execution results, thereby enriching the diversity of the content in the execution result.
[0270] In some embodiments, the functions or modules included in the device provided in the embodiments of the present application can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.
[0271] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device 2 includes a processor 21 and a memory 22. Optionally, the electronic device 2 also includes an input device 23 and an output device 24. The processor 21, the memory 22, the input device 23 and the output device 24 are coupled via a connector, and the connector includes various interfaces, transmission lines or buses, etc., which are not limited in the embodiments of the present application. It should be understood that in each embodiment of the present application, coupling refers to mutual connection in a specific manner, including direct connection or indirect connection through other devices, for example, it can be connected through various interfaces, transmission lines, buses, etc.
[0272] The processor 21 may include one or more processors, for example, one or more central processing units (CPUs). When the processor is a CPU, the CPU may be a single-core CPU or a multi-core CPU. Optionally, the processor 21 may be a processor group consisting of multiple CPUs, and the multiple processors are coupled to each other via one or more buses. Optionally, the processor may also be other types of processors, etc., which are not limited in the embodiments of the present application.
[0273] The memory 22 can be used to store computer program instructions and various computer program codes including the program code for executing the program code of the present application. Optionally, the memory includes but is not limited to random access memory (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM), or portable read only memory (CD-ROM), which is used for related instructions and data.
[0274] The input device 23 is used to input data and / or signals, and the output device 24 is used to output data and / or signals. The input device 23 and the output device 24 can be independent devices or an integrated device.
[0275] It can be understood that in the embodiment of the present application, the memory 22 can be used not only to store relevant instructions, but also to store relevant data. The embodiment of the present application does not limit the specific data stored in the memory.
[0276] Understandably, Figure 7 Only a simplified design of an electronic device is shown. In practical applications, the electronic device may also include other necessary components, including but not limited to any number of input / output devices, processors, memories, etc., and all electronic devices that can implement the embodiments of the present application are within the protection scope of the present application.
[0277] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0278] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. Those skilled in the art can also clearly understand that the descriptions of the various embodiments of the present application have different focuses. For the convenience and brevity of description, the same or similar parts may not be repeated in different embodiments. Therefore, for parts not described or not described in detail in a certain embodiment, refer to the records of other embodiments.
[0279] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0280] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0281] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0282] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0283] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned method embodiments. The aforementioned storage medium includes: a read-only memory (ROM) or a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
Claims
1. A text processing method, characterized in that: The method comprises: Get the text to be processed; Using a language model to perform a target task on the text to be processed according to n different chains of thought, to obtain n first processing results, wherein the target task is a natural language processing task, and n is an integer greater than 1; Based on the n first processing results and the target task, generating a prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the n first processing results; Under the guidance of the prompt word, the language model is used to fuse the contents of the n first processing results to obtain the execution result of the target task.
2. The method according to claim 1, characterized in that The generating a prompt word based on the n first processing results and the target task includes: Based on the n first processing results, determine n first consistency scores of the n first processing results, where the first consistency scores correspond to the first processing results one by one, and the first consistency scores represent the consistency between the first processing result and the n first processing results; Determine that the first processing results corresponding to the largest k of the n first consistency scores among the n first processing results are k consistent results, where k is a positive integer less than n; Based on the k consistent results and the target task, generating the prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the k consistent results; Under the guidance of the prompt word, the language model is used to fuse the contents of the n first processing results to obtain the execution result of the target task, including: Under the guidance of the prompt word, the language model is used to fuse the contents of the k consistent results to obtain the execution result.
3. The method according to claim 2, characterized in that The n first processing results include a second processing result, the n first consistency scores include a second consistency score, and the second consistency score is the first consistency score of the second processing result; The determining, based on the n first processing results, n first consistency scores of the n first processing results comprises: Determine a first similarity between the second processing result and the first processing results other than the second processing result among the n first processing results, and obtain (n-1) first similarities; The second consistency score is obtained based on the sum of the (n-1) first similarities.
4. The method according to claim 2 or 3, characterized in that: The generating the prompt word based on the k consistent results and the target task includes: Clustering the k consistent results to obtain m result sets, where m is a positive integer less than k, and the result set is a set of the consistent results; Based on the m result sets, m first clustering results are obtained, where the first clustering results correspond one-to-one to the result sets; Based on the m first clustering results and the target task, generating the prompt word, wherein the prompt word is used to guide the language model to perform the target task based on the m first clustering results; Under the guidance of the prompt word, the language model is used to fuse the contents of the k consistent results to obtain the execution result, including: Under the guidance of the prompt word, the language model is used to fuse the contents of the m first clustering results to obtain the execution result.
5. The method according to claim 4, characterized in that The obtaining m first clustering results based on the m result sets includes: For any one of the m result sets, determine the consistent result closest to the center of the set from the set as the first clustering result, and obtain the m first clustering results.
6. The method according to claim 4, characterized in that Under the guidance of the prompt word, the language model is used to fuse the contents of the m first clustering results to obtain the execution result, including: Under the guidance of the prompt word, the language model fuses common contents with semantic matching in the m first clustering results to obtain the execution result.
7. The method according to claim 6, characterized in that The m is greater than 1, the m first clustering results include a second clustering result and a third clustering result, the second clustering result includes the first paragraph, and the third clustering result includes the second paragraph; The language model integrates the common contents in the m clustering results to obtain the execution result, including: The language model determines a first position of the first paragraph in the second clustering result; Determining, by the language model, a second position of the second paragraph in the third clustering result; Determining, by the language model, a second similarity between the first position and the second position; The language model determines a third similarity between the semantics of the first paragraph and the semantics of the second paragraph; The language model fuses the first paragraph and the second paragraph to obtain the execution result when a weighted sum of the second similarity and the third similarity is greater than or equal to a threshold.
8. The method according to any one of claims 1 to 3, characterized in that The target task is to extract a summary of the text.
9. A text processing device, characterized in that: The text processing device comprises: An acquisition unit, used for acquiring the text to be processed; A processing unit, configured to use a language model to perform a target task on the text to be processed according to n different chains of thought to obtain n first processing results, wherein the target task is a natural language processing task, and n is an integer greater than 1; a generating unit, configured to generate a prompt word based on the n first processing results and the target task, wherein the prompt word is used to guide the language model to perform the target task based on the n first processing results; The processing unit is used to obtain the execution result of the target task by fusing the contents of the n first processing results using the language model under the guidance of the prompt word.
10. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and when the processor executes the computer instructions, the electronic device executes the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor is enabled to execute the method according to any one of claims 1 to 8.
12. A computer program product, characterized in that The computer program product comprises a computer program or instructions; when the computer program or instructions are run on a computer, the computer is caused to execute the method according to any one of claims 1 to 8.
