Method and device for optimizing text prompt of large model, equipment and storage medium

By combining the automatic evaluation ability of the large model and optimizing Prompt, the problem of insufficient applicability of the Prompt optimization solution to complex tasks in the existing technology is solved, and the performance and application value of the large model in various tasks is improved.

CN119106737AActive Publication Date: 2024-12-10BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411310967.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2024-12-10
Estimated Expiration
2044-09-19

AI Technical Summary

Technical Problem

The existing Prompt optimization solution relies on simple evaluation methods and is difficult to apply to complex tasks, limiting the performance and application value of large models in multiple tasks.

Method used

Combining the automatic evaluation ability of the big model, by entering text prompts and task samples, evaluating processing results and optimizing Prompt based on the evaluation results, breaking the limitations of traditional evaluation methods and making Prompt optimization suitable for a wider range of task types.

Benefits of technology

A deeper, more comprehensive and more detailed evaluation of the content of the answers to the big model is achieved, which improves the performance and application value of the big model in complex tasks, and reduces the consumption of human and material resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119106737A_ABST
    Figure CN119106737A_ABST
Patent Text Reader

Abstract

The invention provides an optimization method and device for text prompt of a large model, equipment and a storage medium, and relates to the technical field of artificial intelligence, in particular to the technical field of large models, intelligent search and the like. According to the specific implementation scheme, a first text prompt and a first task sample are input into a large model, and a processing result of the large model for the first task sample is obtained; evaluating the processing result by adopting the large model to obtain an evaluation result; and under the condition that the evaluation result shows that the processing result has the problem, optimizing the first text prompt to obtain a second text prompt based on a reason which is recorded in the evaluation result and causes the problem.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to technical fields such as large models and intelligent search. Background Art

[0002] In the current field of artificial intelligence, especially in the application of large models, although these models can handle a variety of complex tasks, their final performance is often affected by prompts.

[0003] Prompt, the instruction input into the model, can directly determine the output quality of the large model. Therefore, how to design and optimize prompts becomes a key step to improve the performance of large model tasks. In recent years, the demand for prompt engineering automation has become increasingly strong, and the method of automatically optimizing prompts has therefore become a hot topic. Summary of the invention

[0004] The present invention provides a method, device, equipment and storage medium for optimizing text prompts of a large model.

[0005] According to one aspect of the present disclosure, a method for optimizing text prompts of a large model is provided, comprising:

[0006] Inputting the first text prompt and the first task sample into the large model to obtain a processing result of the large model for the first task sample;

[0007] Using the large model to evaluate the processing result to obtain an evaluation result;

[0008] In the case where the evaluation result indicates that the processing result has a problem, the first text prompt is optimized to obtain a second text prompt based on the cause of the problem recorded in the evaluation result.

[0009] According to another aspect of the present disclosure, there is provided a device for optimizing text prompts of a large model, comprising:

[0010] A first processing module, used for inputting a first text prompt and a first task sample into a large model, and obtaining a processing result of the large model for the first task sample;

[0011] An evaluation module, used for evaluating the processing result by using the large model to obtain an evaluation result;

[0012] The optimization module is used to optimize the first text prompt to obtain a second text prompt based on the cause of the problem recorded in the evaluation result when the evaluation result indicates that the processing result has a problem.

[0013] According to another aspect of the present disclosure, there is provided an electronic device, comprising:

[0014] at least one processor; and

[0015] a memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute any method in the embodiments of the present disclosure.

[0017] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any method according to the embodiments of the present disclosure.

[0018] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements any method according to the embodiments of the present disclosure when executed by a processor.

[0019] In the disclosed embodiment, the reasoning and understanding ability of the large model is used to realize automatic evaluation, which can achieve a deeper, more comprehensive and more detailed evaluation of the answer content of the large model. In each round of optimization, it will no longer rely on simple judgment criteria such as traditional regular matching and numerical calculation, but will make full use of the evaluation ability of the large model itself to score and evaluate the effect of the generated Prompt. This method not only breaks the limitations of traditional evaluation methods, but also makes the automatic optimization of Prompt no longer limited to a few types of tasks that can be evaluated by simple rules, such as arithmetic problems and multiple-choice questions, but can be extended to a wider range of general tasks, thereby further improving the performance and application value of the large model in various complex tasks.

[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0022] Figure 1 It is a flowchart of a method for optimizing text prompts of a large model according to an embodiment of the present disclosure;

[0023] Figure 2 It is a flowchart of a method for optimizing text prompts of a large model according to an embodiment of the present disclosure;

[0024] Figure 3It is a flowchart of a method for optimizing text prompts of a large model according to an embodiment of the present disclosure;

[0025] Figure 4 is an architectural diagram of a method for optimizing text prompts for a large model according to an embodiment of the present disclosure;

[0026] Figure 5 It is an architectural diagram of an optimization device for text prompts of a large model according to an embodiment of the present disclosure;

[0027] Figure 6 It is a block diagram of an electronic device used to implement the optimization method of text prompts for a large model according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0029] The terms "first", "second", etc. in this disclosure are used to distinguish similar objects, and are not necessarily used to describe a specific order or precedence. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, including a series of steps or units. The method, system, product or device is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] In the related technology, the automatic optimization scheme of Prompt has obvious limitations in application. Common Prompt optimization schemes generally rely on evaluating and screening the performance of the optimized Prompt on a specific sample set. The evaluation part mainly uses simple methods such as regular matching or numerical calculation with the reference answer. Therefore, the current Prompt optimization scheme is mainly focused on task types that can be easily judged as correct or not, such as multiple-choice questions and arithmetic problems. This simple evaluation method has limited the application of the current Prompt optimization scheme in more complex tasks, and it is difficult to give full play to the capabilities of large models.

[0031] In order to solve this problem, an optimization method for text prompts of a large model is proposed in the embodiment of the present disclosure. In this method, the automatic optimization of Prompt is combined with the automatic evaluation capability of the large model itself, such as Figure 1 As shown, it can be implemented as follows:

[0032] S101, inputting a first text prompt and a first task sample into a large model to obtain a processing result of the large model for the first task sample.

[0033] The first text prompt is the initial prompt information provided for the target object, which will be updated later to automatically optimize the prompt information.

[0034] Among them, the first task sample is the set of questions raised by the target object.

[0035] Among them, the large model can be a large language model (LLMs). Large language models refer to a specific type of large model that is specifically used to process text data. This type of model is a natural language processing model based on a neural network, which can be used to generate, understand and process text data. Large language models can have tens of billions of parameters, can generate high-quality text, and can be used for various natural language processing tasks, such as question answering, text generation, dialogue systems, etc.

[0036] The large language model has good reasoning ability and small sample learning ability. The large language model can understand the model on a large scale or can be trained on a large number of samples. Based on the large model, accurate semantic understanding can be achieved.

[0037] S102, using a large model to evaluate the processing result and obtain an evaluation result.

[0038] S103: When the evaluation result indicates that the processing result has a problem, based on the cause of the problem recorded in the evaluation result, the first text prompt is optimized to obtain a second text prompt.

[0039] When the evaluation result indicates that there is no problem with the processing result, the first text prompt is no longer optimized and is applied as the final prompt information.

[0040] In the disclosed embodiment, the reasoning and understanding ability of the large model is used to realize automatic evaluation, which can achieve a deeper, more comprehensive and more detailed evaluation of the answer content of the large model. In each round of optimization, it will no longer rely on simple judgment criteria such as traditional regular matching and numerical calculation, but will make full use of the evaluation ability of the large model itself to score and evaluate the effect of the generated Prompt. This method not only breaks the limitations of traditional evaluation methods, but also makes the automatic optimization of Prompt no longer limited to a few types of tasks that can be evaluated by simple rules, such as arithmetic problems and multiple-choice questions, but can be extended to a wider range of general tasks, thereby further improving the performance and application value of the large model in various complex tasks.

[0041] In some embodiments, a large model is used to evaluate the processing results to obtain the evaluation results, which can be implemented as follows: when the first task sample does not have a standard answer, the evaluation criteria, the first task sample and the processing results are input into the large model to obtain the evaluation results output by the large model based on the evaluation criteria.

[0042] Among them, the standard answer is the reference answer, such as the answer to a multiple-choice question or an arithmetic question. In the disclosed example, marking the result is optional, so the first task sample can be an open-ended task. Exemplarily, the task of the first task sample can be a writing task, such as "I need an article describing autumn." Alternatively, the first task sample is a task that can get an answer based on certain logical calculations, such as what 1+1 equals. In the disclosed embodiment, whether the first task sample has a standard answer can be determined based on actual conditions, and the disclosed embodiment is not limited here.

[0043] In the disclosed embodiment, when the first task sample does not have a standard answer, the evaluation criteria, the first task sample and the processing result are input into the large model, so that the large model can use its powerful reasoning ability to obtain the evaluation result of the first task sample, so that the large model has a more accurate prompt information for the task.

[0044] In some embodiments, a large model is used to evaluate the processing results to obtain the evaluation results, which can be implemented as follows: when the first task sample has a standard answer, the evaluation criteria, the first task sample, the standard answer and the processing result are input into the large model to obtain the evaluation results output by the large model based on the evaluation criteria.

[0045] The evaluation criteria have been described above and will not be elaborated on in detail in the embodiments of the present disclosure.

[0046] Samples of the first task include multiple-choice questions and calculation questions.

[0047] In the disclosed embodiment, when the first task sample has a standard answer, the evaluation criteria, the first task sample, the processing result and the standard answer are input into the big model, so that the big model performs evaluation with reference to the standard answer. The evaluation process is targeted and can utilize the big model's own powerful reasoning ability to improve the accuracy of the big model's evaluation results.

[0048] In some embodiments, in order to better optimize the text prompt, whether the first task sample has a standard answer, such as Figure 2 As shown, the evaluation criteria can be determined based on the following methods:

[0049] S201, obtaining a second task sample set, a model output result set of the second task sample set, and comment information for the model output result set; wherein the model output result set is obtained by processing the second task samples in the second task sample set by the large model based on the third text prompt; the comment information is used to indicate whether the model output result of each second task sample meets expectations; if it does not meet expectations, the comment information also includes the reasons for the non-compliance in the third text prompt.

[0050] The second task sample set and the first task sample set may be the same sample set or different sample sets, which is not limited in the embodiment of the present disclosure.

[0051] For any second task sample, if the model output result of the second task sample does not meet expectations, the model output result can be annotated, which can be manual or automatic. The annotation information also includes the reason for not meeting expectations in the third text prompt.

[0052] In addition, there are one or more third text prompts. The third text prompt may be the same as the second text prompt or different, and the embodiments of the present disclosure do not limit this. In the case of including multiple third text prompts, the following operations may be performed for each third text prompt: using a large model to process each second task sample in the second task sample based on the third text prompt to obtain the processing results of each second task sample; thereafter, generating remark information for the processing results of each second task sample, the remark information is used to indicate whether the processing result of the second task sample is correct, and if it is incorrect, it is necessary to point out the reason why the third text prompt caused the error; summarizing the remark information of each second task sample to obtain the remark information of the model output result set of the second task sample set under the third text prompt.

[0053] Therefore, by using different third task samples, different problem samples can be summarized, so that the large model can learn and understand the different problems of the text prompts, so that in S202, the second task sample set, the model output result set and the annotation information can be input into the large model, so that the large model outputs the evaluation criteria.

[0054] During implementation, the second task sample set, the model output result set, and the remark information are input into the large model in a certain format, and the large model determines the evaluation criteria based on the second task sample set and the remark information, so that when the automatic evaluation is subsequently applied for scoring, the evaluation criteria generated in this step and the problem of the target object, the processing results, etc. are input into the large model together to obtain a more accurate automatic evaluation result. Among them, the problem of the target object is the second task sample set.

[0055] In the disclosed embodiment, the second task sample set, the model output result set and the remark information are input into the large model, and the large model's ability to analyze and summarize long texts is used to obtain the evaluation criteria. In this way, the accuracy of the subsequent automatic evaluation of the first task sample processing results can be improved, and at the same time, automated evaluation is achieved based on this process, saving human and material resources.

[0056] In some embodiments, in order to automatically optimize the text prompt, the text prompt can be iteratively optimized based on the following methods until the desired result is achieved, such as Figure 3 As shown:

[0057] S301 : When respective second text prompts are obtained for a plurality of first text prompts, a plurality of candidate text prompts are screened out from the plurality of second text prompts based on a heuristic search method.

[0058] Among them, the heuristic search method can be beam search, which gradually approaches the optimal solution by retaining multiple high-scoring candidates in the search space and performing layer-by-layer search.

[0059] During implementation, an initial text hint can be provided to be used as the starting point of Beam Search for subsequent multiple rounds of iterative optimization.

[0060] When an initial text prompt is provided, during the first round of iterations, the initial text prompt can be optimized for the first task sample with problems, and a candidate text prompt is obtained each time the optimization is performed, so as to ensure that after the first round of iterations, there are a certain number of candidate text prompts for use in subsequent iterative optimizations.

[0061] In the embodiment of the present disclosure, the first text prompt may be an initial text prompt, or may be any first text prompt obtained in each round of optimization after the first round of iteration.

[0062] In some embodiments, based on a heuristic search method, screening out a plurality of candidate text prompts from a plurality of second text prompts may be implemented as follows:

[0063] Step A1, evaluating the accuracy of each second text prompt in the first task sample set to obtain a score for each second text prompt.

[0064] During implementation, for each second text prompt, the large model can use the second text prompt to process the first task sample set to obtain the processing results of each first task sample in the first task sample set. According to the self-evaluation method of the large model on the processing results of each first task sample, the number of first task samples with correct processing results is determined to obtain the correct sample size, and the ratio of the correct sample size to the total sample size of the first task sample set is calculated to obtain the score of the second text prompt. In this way, the score of each second text prompt can be obtained.

[0065] For example, there are 100 questions in the first task sample set. When the large model evaluates prompt1, if 50 first task samples are answered correctly, the accuracy of prompt1 is 0.5, and the corresponding score of prompt1 is 0.5. Similarly, when prompt2 also answers these 100 questions, if 70 first task samples are answered correctly, the accuracy of prompt2 is 0.7, and the corresponding score of prompt2 is 0.7.

[0066] Step A2: Filter out a plurality of candidate text prompts based on the scores of the second text prompts.

[0067] During implementation, the scores of the second text prompts are sorted, and the k candidate text prompts with the highest scores are selected to enter the next round of search process, where k≥1.

[0068] Wherein, k is a positive integer and can be flexibly set according to the requirements. For example, for simple tasks, k can be set to a smaller value; for complex tasks, k can be set to a relatively larger value.

[0069] In the disclosed embodiment, from the perspective of the accuracy of the prompt information in solving the problem, the score of each second text prompt is determined, and then a plurality of candidate text prompts ranked at the top are screened out to facilitate subsequent iterative tuning of the text prompts, thereby improving the optimization efficiency.

[0070] S302, taking each candidate text prompt as a new first text prompt, returning to the step of inputting the first text prompt and the first task sample into the large model to obtain the processing result of the large model for the first task sample, until the termination condition is met.

[0071] Therefore, in each subsequent round of iteration, there are k high-quality text prompts to continue to be optimized. The k text prompts represent different optimization directions. Every time a first task sample with a processing error is encountered, a variant will be generated for the corresponding text prompt. Each generated variant is also an optimization direction. Through continuous iterative optimization, it is possible to find the best solution in a sufficient search space and gradually approach the optimal solution.

[0072] In the disclosed embodiment, based on the heuristic search method, multiple candidate text prompts are screened out from multiple second text prompts, and variants are continuously generated based on these candidate text prompts for optimization. The evaluation capability of the large model can be combined with iterative optimization to achieve automatic optimization of the text prompts.

[0073] In some embodiments, the termination condition may include at least one of the following:

[0074] a) Reach the target number of iterations

[0075] During implementation, in an exemplary case where the target number of iterations is M, in a case where M rounds of iterative updates are performed, the text prompt with the highest score is selected from the last round of iterations as the final text prompt.

[0076] b) The improvement of the evaluation index used to screen out multiple candidate text prompts in the heuristic search method meets the preset cutoff condition

[0077] During implementation, the preset cutoff condition can be understood as the score of each candidate text prompt no longer significantly increases with the increase in the number of iterations.

[0078] c) Achieve expected mission performance indicators

[0079] During implementation, the task performance indicator may be understood as the accuracy of the first text prompt being greater than a preset threshold.

[0080] The iterative optimization task can be terminated when one of the above termination conditions is met, or the loop task can be terminated when any two or three of the above conditions are met. The specific method used as the termination condition can be determined based on actual conditions, and the embodiments of the present disclosure do not limit this.

[0081] In the disclosed embodiment, the iterative optimization process is terminated using a termination condition, which can ensure that the optimization process can be terminated in an orderly manner. In the case of using multiple indicators as termination conditions, the quality of the text information finally obtained can be further improved.

[0082] After the termination condition is met, the final prompt result will be returned to the target object. The target object can directly apply the prompt to the actual task, or further adjust it according to specific needs. The entire process from the initial prompt input to the final result output is completed under the automation framework. The target object only needs to provide the initial prompt to obtain an optimized high-quality prompt.

[0083] In practical applications, the target object can flexibly adjust the parameters of Beam Search, such as Beam Size (i.e. k) and the number of iterations, to meet the needs of different tasks and resource constraints. Through multiple rounds of iterative optimization, the quality of Prompt can be effectively improved, thereby improving the performance of large models in various complex tasks.

[0084] In some embodiments, since the processing result of the first task sample may have various problems, the first text prompt may be optimized in a targeted manner to obtain the second text prompt based on the causes of the problems recorded in the evaluation results.

[0085] Exemplarily, optimizing the first text prompt based on different reasons may include the following contents:

[0086] 1) When the cause of the problem includes that the large model ignores the first target requirement in the first text prompt, the first text prompt is optimized by highlighting the first target requirement.

[0087] If it is found that the large model ignores the first target requirement in the first text prompt, the key text in the prompt can be bolded using Markdown bold syntax to emphasize the key text, so that the large model can focus on the key text.

[0088] In addition to using bold to highlight, you can also use underline, modify color font, italic, use special characters, etc. In real time, any text format that can highlight the first target requirement is applicable to the embodiment of the present disclosure. Among them, as an exemplary way of highlighting, the "style imitation: capture the language style of the original text" in the prompt can be adjusted to " Style imitation : Capture the language style of the original text", which can be understood as highlighting the "style imitation".

[0089] In the disclosed embodiment, by highlighting the first target requirement, the large model can pay attention to and understand the first target requirement in the first text prompt, so that when the large model executes the task in the later stage, it can ensure that the task is completed in accordance with the first target requirement, thereby improving the quality of the first text prompt.

[0090] 2) When the cause of the problem includes unclear reference of the second target requirement in the first text prompt, the first text prompt is optimized by clarifying the reference object in the second target requirement.

[0091] During implementation, more explicit references can be used to reduce ambiguity. When the prompt contains multiple components, using more explicit references can reduce uncertainty when generating large models. For example, in the prompt, "capture the language style of the original text". Since the prompt contains multiple pieces of information, the word "original text" may not be clear. It can be adjusted to "[oral copy sample]" based on actual conditions to clearly refer to a specific piece of text in the prompt. The first text prompt after optimization is "capture the language style of [oral copy sample]".

[0092] In the disclosed embodiment, the use of clear references can reduce ambiguity and make large model recognition clearer, thereby optimizing the first text prompt.

[0093] 3) When the cause of the problem includes that the preset requirements for the model answer in the first text prompt are not accurately described, the first text prompt is optimized by adding examples to the preset requirements.

[0094] During implementation, examples can be used to make prompts clearer. When the requirements for the model's answer in the prompt are difficult to describe accurately, some examples can be added to make the large model easier to understand. For example, the prompt "cleverly integrate characteristic elements in the imitation" can be adjusted to "cleverly integrate characteristic elements in the imitation, such as characteristic catchphrases, ancient poetry explanations, popular science knowledge, etc."

[0095] In the disclosed embodiment, the method of adding examples is used to make the prompt information clearer, so that the second prompt information obtained after optimization can reduce the difficulty of the large model in understanding the model answer requirements as much as possible, thereby prompting the accuracy of the large model processing tasks.

[0096] 4) When the reason includes that the large model cannot follow the explicit requirement in the first text prompt, the first text prompt is optimized by strengthening the explicit requirement.

[0097] When a clear requirement has been clearly given in the prompt but the expected processing result of the large model still cannot be met, the tone of the clear requirement can be strengthened so that the large model can pay more attention to the clear requirement, making the clear requirement appear more important so as to correctly handle the task.

[0098] In language, emphasis is the use of specific vocabulary, grammatical structures, or punctuation to enhance the expression of a sentence, making it more prominent, emphatic, or emotional. Here are some examples of emphasis:

[0099] (1) Use interjections such as “ah”, “wow”, “oh”, etc. to express surprise, joy, etc. in spoken language.

[0100] (2) Use emphatic adverbs: such as "very", "really", "indeed", etc., to strengthen the intensity of adjectives or verbs.

[0101] (3) Use parallel structures: By repeating similar sentence structures, the rhythm and emphasis of the language can be enhanced.

[0102] (4) Use exclamatory sentences: Use an exclamation mark (!) at the end of a sentence to express strong emotion or emphasis.

[0103] (5) Use question sentences: By asking questions, you can attract the listener's attention and make them think.

[0104] (6) Use metaphors and exaggerations: Metaphors can be used to express ideas vividly, while exaggerations can highlight certain features.

[0105] (7) Use inversion: In English, inversion can emphasize a part of the sentence.

[0106] (8) Use repetition: Repeating a word or sentence can strengthen the tone and impression.

[0107] (9) Use contrast: By contrasting different things or ideas, you can emphasize one of them.

[0108] (10) Use imperative sentences: When you need to express a strong request or command, you can use imperative sentences.

[0109] It should be noted that the emphasis on tone is not limited to the above examples, and the tone can be strengthened based on actual conditions to optimize the first text prompt.

[0110] The example "Please imitate the given [product information] and [oral copy sample] according to the above prompts and requirements, and directly provide the imitative copy content." can be adjusted to "Please imitate the given [product information] and [oral copy sample] according to the above prompts and requirements. Please strictly abide by all the above task requirements, otherwise you will be prohibited from any creation! And directly provide the imitative copy content.".

[0111] The tuning of this method strengthens the tone of the requirement by adding "Please strictly comply with all the above task requirements, otherwise you will be prohibited from creating anything!", so that the large model can better understand the task requirements, so that the large model has a clear task orientation and can better complete the task. Therefore, the second text prompt obtained by tuning this method can make it easier for the large model to understand the requirements and complete the task better.

[0112] 5) When the cause of the problem includes that the third target requirement in the first text prompt is not detailed enough, the first text prompt is optimized by describing the third target requirement in detail.

[0113] During implementation, if there is a problem of insufficient description in the Prompt, a more detailed description can be used to make the large model easier to understand. For example, in the Prompt, "If a small part of the content deviates from the 'question' but does not affect the correctness of the main meaning of the 'answer to be verified'", the description "A small part of the content deviates from the 'question' but does not affect the correctness of the main meaning of the 'answer to be verified'" may have the problem of insufficient details. The deviation may cause the large model to not know where the deviation occurs, and "the main meaning is correct" may cause the large model to not know what the main meaning is. Therefore, the description here can be adjusted to "If a small part of the content is not completely consistent with the 'question', but the overall core meaning is consistent with the 'question', and this deviation is not enough to change the main meaning of the answer, it is partially accurate."

[0114] In the disclosed embodiment, the first question prompt is optimized by using a detailed description, so that the prompt information can be made more detailed, thereby enabling the large model to capture more detailed content in the prompt information and improve the accuracy of the large model.

[0115] 6) In the case where the cause of the problem includes the fourth objective requirement in the first text prompt causing misunderstanding of the large model, the first text prompt is optimized by rewriting the fourth objective requirement to eliminate the misunderstanding.

[0116] During implementation, if the description in the prompt causes the large model to misunderstand the requirements, the description that causes misunderstanding can be modified to make the prompt more accurate in expressing the requirements. For example, when the prompt requires "the result must be returned in json format, and according to the evaluation conclusion, it can be returned in other formats in some special cases", in this case, the description of the return format requirement can be modified to "please return in json format in xxx case, and in special case yyy, it can also be returned in zzz format" to make the description more accurate.

[0117] In the disclosed embodiment, descriptions that are prone to misunderstanding are modified into clear descriptions, so that the tuned second text prompt can help the large model understand the task more clearly, and then obtain accurate processing results based on its own strong reasoning ability.

[0118] For ease of understanding, the optimization process in the embodiment of the present disclosure is as follows: Figure 4As shown, the first text prompt (such as the initial text prompt P0), the second task sample (Q), the model output result set (A0), and the remark information (I) are input into the large model. In addition, for any second task sample, if there is a standard answer, the standard answer (R) of the second task sample can be input into the large model together, so as to use the summary and analysis ability of the large model to automatically summarize a set of evaluation criteria. Then, the large model can use the set of evaluation criteria to automatically evaluate the processing results of the first task sample set to obtain an evaluation result. Based on the cause of the problem in the evaluation result, a variant is generated for the first text prompt, so as to iteratively optimize the first text prompt and obtain multiple second text prompts evolved from the first text prompt. For example, Figure 4 The figure includes a second text prompt P1, a second text prompt P2, a second text prompt P3, ..., a second text prompt PN. Then, each second text prompt is input into the large model to score each second text prompt, and the score A1, A2, A3, ..., AN of each second text prompt is obtained. Based on the score of each second text prompt, the k second text prompts with the highest scores are screened out as candidate text prompts. Among them, N is greater than k. Thus, a round of optimization iteration ends. It is judged whether the termination condition is met. If the termination condition is not met, each candidate text prompt is used as a new first text prompt, and the next round of optimization iteration is carried out until the termination condition is met, and a candidate prompt information (P') with the highest score is screened out.

[0119] like Figure 4 As shown in the table, an example of the initial text prompt P0 that needs to be optimized is given. The first task sample is subsequently processed based on P0 to obtain the processing result generated by the large model. Then the large model automatically evaluates the processing result to obtain the evaluation result. Figure 4 As shown in , the evaluation result indicates that the reason why the processing result does not meet expectations is that the model answer fails to follow the requirements in the prompt. Therefore, P0 can be automatically optimized based on the reason to obtain the corresponding second text prompt. Relying on the above method for iteration, multiple optimized text prompts will be obtained. Figure 4 As shown, three types of second text prompts P1, P2, and P3 are obtained. The large model needs to evaluate these three types of second text prompts respectively to evaluate the accuracy of each second text prompt for the task set, thereby obtaining the score of each second text prompt, and then selecting high-quality second text prompts based on the score to continue iterative optimization. Figure 4 As shown, among the three second text prompts P1, P2, and P3, P1 and P2 have higher scores. In the case of k=2, P1 and P2 can be selected as new first text prompts for iterative optimization.

[0120] Based on the same technical concept, the present disclosure proposes an optimization device 500 for text prompts of a large model, such as Figure 5As shown, including:

[0121] The first processing module 501 is used to input the first text prompt and the first task sample into the large model to obtain the processing result of the large model for the first task sample;

[0122] Evaluation module 502, used to evaluate the processing result using a large model to obtain an evaluation result;

[0123] The optimization module 503 is used to optimize the first text prompt to obtain a second text prompt based on the cause of the problem recorded in the evaluation result when the evaluation result indicates that the processing result has a problem.

[0124] In some embodiments, the evaluation module is used to:

[0125] When the first task sample does not have a standard answer, the evaluation criteria, the first task sample and the processing result are input into the large model to obtain the evaluation result output by the large model based on the evaluation criteria.

[0126] In some embodiments, the evaluation module is configured to:

[0127] When the first task sample has a standard answer, the evaluation criteria, the first task sample, the standard answer and the processing result are input into the large model to obtain the evaluation result output by the large model based on the evaluation criteria.

[0128] In some embodiments, the system further includes a second processing module for:

[0129] In the case where respective second text prompts are obtained for the plurality of first text prompts, a plurality of candidate text prompts are screened out from the plurality of second text prompts based on a heuristic search method;

[0130] Each candidate text prompt is used as a new first text prompt, and the step of inputting the first text prompt and the first task sample into the large model to obtain the processing result of the large model for the first task sample is returned until the termination condition is met.

[0131] In some embodiments, the second processing module is used to:

[0132] Evaluate the accuracy of each second text prompt in the first task sample set to obtain a score for each second text prompt;

[0133] Based on the scores of the second text prompts, a plurality of candidate text prompts are screened out.

[0134] In some embodiments, the termination condition includes at least one of the following:

[0135] Reach the target number of iterations;

[0136] The improvement of the evaluation index used to screen out multiple candidate text prompts in the heuristic search method meets the preset cutoff condition;

[0137] Achieve expected mission performance indicators.

[0138] In some embodiments, the system further includes an evaluation criteria determination module for:

[0139] Obtain a second task sample set, a model output result set of the second task sample set, and remark information for the model output result set; wherein the model output result set is obtained by processing the second task samples in the second task sample set by the large model based on the third text prompt; the remark information is used to indicate whether the model output result of each second task sample meets expectations; if it does not meet expectations, the remark information also includes the reasons for not meeting expectations in the third text prompt;

[0140] The second task sample set, the model output result set and the annotation information are input into the large model so that the large model outputs the evaluation criteria.

[0141] In some embodiments, the optimization module is specifically used to:

[0142] When the reason includes that the large model ignores the first target requirement in the first text prompt, the first text prompt is optimized by highlighting the first target requirement.

[0143] In some embodiments, the optimization module is specifically configured to:

[0144] When the reason includes that the second target requirement in the first text prompt has unclear reference, the first text prompt is optimized by clarifying the reference object in the second target requirement.

[0145] In some embodiments, the optimization module is specifically configured to:

[0146] When the reason includes that the preset requirement for the model answer in the first text prompt is not accurately described, the first text prompt is optimized by adding examples to the preset requirement.

[0147] In some embodiments, the optimization module is specifically configured to:

[0148] When the reason includes that the large model cannot follow the explicit requirement in the first text prompt, the first text prompt is optimized by strengthening the explicit requirement.

[0149] In some embodiments, the optimization module is specifically configured to:

[0150] When the reason includes that the third target requirement in the first text prompt is not detailed enough, the first text prompt is optimized by describing the third target requirement in detail.

[0151] In some embodiments, the optimization module is specifically configured to:

[0152] In the case where the reason includes that the fourth target requirement in the first text prompt causes misunderstanding by the large model, the first text prompt is optimized by rewriting the fourth target requirement in a manner to eliminate the misunderstanding.

[0153] For the description of specific functions and examples of each module and submodule of the device in the embodiment of the present disclosure, reference can be made to the relevant description of the corresponding steps in the above method embodiment, which will not be repeated here.

[0154] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0155] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0156] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0157] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0158] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0159] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as the optimization method for the text prompt of a large model. For example, in some embodiments, the optimization method for the text prompt of a large model may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the optimization method for the text prompt of the large model described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to execute the optimization method for text prompting of a large model in any other appropriate manner (eg, by means of firmware).

[0160] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0161] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0162] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0163] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0164] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0165] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0166] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0167] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the principles of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. An optimization method for text prompts of large models, include: Inputting the first text prompt and the first task sample into the large model to obtain a processing result of the large model for the first task sample; Using the large model to evaluate the processing result to obtain an evaluation result; In the case where the evaluation result indicates that the processing result has a problem, the first text prompt is optimized to obtain a second text prompt based on the cause of the problem recorded in the evaluation result.

2. The method according to claim 1, in, The step of using the large model to evaluate the processing result to obtain an evaluation result includes: In the case where the first task sample does not have a standard answer, the evaluation criteria, the first task sample and the processing result are input into the large model to obtain the evaluation result output by the large model based on the evaluation criteria.

3. The method according to claim 1, in, The step of using the large model to evaluate the processing result to obtain an evaluation result includes: In the case where the first task sample has a standard answer, the evaluation criteria, the first task sample, the standard answer and the processing result are input into the large model to obtain the evaluation result output by the large model based on the evaluation criteria.

4. The method according to any one of claims 1 to 3, further comprising: include: In the case where respective second text prompts are obtained for the plurality of first text prompts, a plurality of candidate text prompts are screened out from the plurality of second text prompts based on a heuristic search method; Each candidate text prompt is used as a new first text prompt, and the step of inputting the first text prompt and the first task sample into the large model to obtain the processing result of the large model for the first task sample is returned until the termination condition is met.

5. The method according to claim 4, in, The method of selecting multiple candidate text prompts from multiple second text prompts based on the heuristic search method includes: Evaluate the accuracy of each second text prompt in the first task sample set to obtain a score for each second text prompt; The plurality of candidate text prompts are screened out based on the scores of the second text prompts.

6. The method according to claim 4, wherein the termination condition comprises at least one of the following: Reach the target number of iterations; The improvement of the evaluation index used to screen out the multiple candidate text prompts in the heuristic search method meets a preset cutoff condition; Achieve expected mission performance indicators.

7. The method according to claim 2 or 3, further comprising determining the evaluation criteria based on the following method: Acquire a second task sample set, a model output result set of the second task sample set, and comment information for the model output result set; in, The model output result set is obtained by processing the second task samples in the second task sample set by the large model based on the third text prompt; the remark information is used to indicate whether the model output result of each second task sample meets expectations; if it does not meet expectations, the remark information also includes the reasons in the third text prompt that lead to non-compliance with expectations; The second task sample set, the model output result set and the annotation information are input into the large model so that the large model outputs the evaluation criteria.

8. The method according to any one of claims 1 to 7, in, The optimizing the first text prompt based on the cause of the problem recorded in the evaluation result includes: When the reason includes that the large model ignores the first target requirement in the first text prompt, the first text prompt is optimized by highlighting the first target requirement.

9. The method according to any one of claims 1 to 8, in, The optimizing the first text prompt based on the cause of the problem recorded in the evaluation result includes: When the reason includes that the second target requirement in the first text prompt is unclear in reference, the first text prompt is optimized by clarifying the reference object in the second target requirement.

10. The method according to any one of claims 1 to 9, in, The optimizing the first text prompt based on the cause of the problem recorded in the evaluation result includes: When the reason includes that the preset requirement for the model answer in the first text prompt is not accurately described, the first text prompt is optimized by adding examples to the preset requirement.

11. The method according to any one of claims 1 to 10, in, The optimizing the first text prompt based on the cause of the problem recorded in the evaluation result includes: In a case where the reason includes that the large model cannot comply with the explicit requirement in the first text prompt, the first text prompt is optimized by strengthening the explicit requirement.

12. The method according to any one of claims 1 to 11, in, The optimizing the first text prompt based on the cause of the problem recorded in the evaluation result includes: When the reason includes that the third target requirement in the first text prompt is not detailed enough, the first text prompt is optimized by describing the third target requirement in detail.

13. The method according to any one of claims 1 to 12, in, The optimizing the first text prompt based on the cause of the problem recorded in the evaluation result includes: In a case where the cause includes a fourth target requirement in the first text prompt causing misunderstanding by the large model, the first text prompt is optimized by rewriting the fourth target requirement to eliminate the misunderstanding.

14. An optimization device for text prompts of large models, include: A first processing module, used for inputting a first text prompt and a first task sample into a large model, and obtaining a processing result of the large model for the first task sample; An evaluation module, used for evaluating the processing result by using the large model to obtain an evaluation result; The optimization module is used to optimize the first text prompt to obtain a second text prompt based on the cause of the problem recorded in the evaluation result when the evaluation result indicates that the processing result has a problem.

15. The device according to claim 14, in, The evaluation module is specifically used for: In the case where the first task sample does not have a standard answer, the evaluation criteria, the first task sample and the processing result are input into the large model to obtain the evaluation result output by the large model based on the evaluation criteria.

16. The device according to claim 14, in, The evaluation module is specifically used for: In the case where the first task sample has a standard answer, the evaluation criteria, the first task sample, the standard answer and the processing result are input into the large model to obtain the evaluation result output by the large model based on the evaluation criteria.

17. The apparatus according to any one of claims 14 to 16, further comprising a second processing module, configured to: In the case where respective second text prompts are obtained for the plurality of first text prompts, a plurality of candidate text prompts are screened out from the plurality of second text prompts based on a heuristic search method; Each candidate text prompt is used as a new first text prompt, triggering the first processing module to return to execute the step of inputting the first text prompt and the first task sample into the large model to obtain the processing result of the large model for the first task sample until the termination condition is met.

18. The device according to claim 17, in, The second processing module is used for: Evaluate the accuracy of each second text prompt in the first task sample set to obtain a score for each second text prompt; The plurality of candidate text prompts are screened out based on the scores of the second text prompts.

19. The apparatus according to claim 17, wherein the termination condition comprises at least one of the following: Reach the target number of iterations; The improvement of the evaluation index used to screen out the multiple candidate text prompts in the heuristic search method meets a preset cutoff condition; Achieve expected mission performance indicators.

20. The apparatus according to claim 15 or 16, further comprising an evaluation criteria determination module, configured to: Acquire a second task sample set, a model output result set of the second task sample set, and comment information for the model output result set; in, The model output result set is obtained by processing the second task samples in the second task sample set by the large model based on the third text prompt; the remark information is used to indicate whether the model output result of each second task sample meets expectations; if it does not meet expectations, the remark information also includes the reasons in the third text prompt that lead to non-compliance with expectations; The second task sample set, the model output result set and the annotation information are input into the large model so that the large model outputs the evaluation criteria.

21. The device according to any one of claims 14 to 20, in, The optimization module is specifically used for: When the reason includes that the large model ignores the first target requirement in the first text prompt, the first text prompt is optimized by highlighting the first target requirement.

22. The device according to any one of claims 14 to 21, in, The optimization module is specifically used for: When the reason includes that the second target requirement in the first text prompt is unclear in reference, the first text prompt is optimized by clarifying the reference object in the second target requirement.

23. The device according to any one of claims 14 to 22, in, The optimization module is specifically used for: When the reason includes that the preset requirement for the model answer in the first text prompt is not accurately described, the first text prompt is optimized by adding examples to the preset requirement.

24. The device according to any one of claims 14 to 23, in, The optimization module is specifically used for: In a case where the reason includes that the large model cannot comply with the explicit requirement in the first text prompt, the first text prompt is optimized by strengthening the explicit requirement.

25. The device according to any one of claims 14 to 24, in, The optimization module is specifically used for: When the reason includes that the third target requirement in the first text prompt is not detailed enough, the first text prompt is optimized by describing the third target requirement in detail.

26. The device according to any one of claims 14 to 25, in, The optimization module is specifically used for: In a case where the cause includes a fourth target requirement in the first text prompt causing misunderstanding by the large model, the first text prompt is optimized by rewriting the fourth target requirement to eliminate the misunderstanding.

27. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 13.

28. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-13.

29. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Text generation method and system

    CN117540012A

  • Method and system for optimizing cue word, electronic equipment and storage medium

    CN118428492A