A large model prompt word optimization method and related device
By using multiple sets of large-scale models and multiple rounds of question-and-answer optimization technology, the existing automation Prompt optimization technology is solved, and efficient and flexible Prompt optimization is achieved, improving the optimization effect and automation level.
Patent Information
- Application Number
- CN202411724204.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-04-08
AI Technical Summary
Existing automation Prompt optimization techniques are inefficient and poorly effective, lacking flexibility and deep understanding of task background and language details.
By using at least one set of large-scale models to optimize the Prompt generated based on the task requirement description, the initial Prompt is optimized from multiple angles in sequence, multiple rounds of dialogue information is generated, and the Prompt and multi-round dialogue information are integrated to obtain the final optimized Prompt.
The automation degree and efficiency of Prompt optimization have been significantly improved, the diversity and robustness of the final optimized Prompt have been enhanced, and the optimization effect has been effectively improved.
Smart Images

Figure CN119783685A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of large model technology, and in particular to a large model prompt word optimization method and related devices. Background Art
[0002] As large models are increasingly used in various fields, optimizing Prompt has become the key to improving model performance. Various industries have invested resources and energy to continuously explore and improve Prompt optimization methods to ensure that large models can achieve maximum performance in practical applications.
[0003] Currently, Prompt's optimization methods are mainly divided into two categories: manual optimization and automatic optimization.
[0004] Manual optimization is currently the most direct and traditional optimization method. Through manual design and adjustment, optimizers can refine the prompt based on their understanding of the task requirements. The advantage of manual optimization lies in its flexibility and pertinence, and it can tailor the prompt according to the characteristics and requirements of specific tasks. Although manual optimization methods have the advantages of strong flexibility and high customization, they also have some challenges, such as being time-consuming and requiring high professional knowledge. Therefore, with the widespread application of large models, automated optimization has gradually received attention.
[0005] Automated optimization is to automatically generate and adjust prompts through algorithms and technical means to improve the output quality of large models. This method usually relies on data-driven and machine learning techniques, which can generate a large number of prompt candidates in a short time and select the best solution from them. The advantages of automated optimization are its efficiency and scalability. It can complete a large number of optimization tasks in a short time and can effectively handle complex multi-task scenarios. However, automated optimization may lack the flexibility of manual optimization in some cases, especially when a deep understanding of task background and language details is required. Moreover, existing automatic optimization technologies have low optimization efficiency and poor optimization effects.
[0006] Therefore, how to provide an optimization method for a large model Prompt to improve the optimization efficiency and optimization effect of the large model Prompt has become an urgent problem to be solved by those skilled in the art. Summary of the invention
[0007] In view of the above problems, this application provides a large model prompt word optimization method and related devices to achieve the purpose of improving optimization efficiency and optimization effect. The specific scheme is as follows:
[0008] The first aspect of the present application provides a large model prompt word optimization method, comprising:
[0009] Obtain the task requirement description given by the user;
[0010] Using at least one group of large model combinations, optimizing the Prompt generated based on the task requirement description to obtain at least one group of Prompts and at least one multi-round dialogue information; each group of large model combinations corresponds to a group of Prompts and a multi-round dialogue information; the multi-round dialogue information is used to indicate the optimization process of the group of large models for the Prompt generated based on the task requirement description;
[0011] The at least one group of Prompts and the at least one multi-round dialogue information are integrated to obtain a final optimized Prompt.
[0012] In a possible implementation, each group of large model combinations includes a first large model and a second large model. For each group of large model combinations, the prompt generated based on the task requirement description is optimized to obtain a group of prompts and a multi-round dialogue information in the following manner:
[0013] Based on the task requirement description, the first large model is called to generate an initial prompt;
[0014] The initial Prompt is optimized using the second largest model in a multi-round question-answering manner to obtain an optimized Prompt and the multi-round dialogue information, and a combination of the initial Prompt and the optimized Prompt is the set of Prompts.
[0015] In a possible implementation, the multi-round question-answering method is used to optimize the initial prompt using the second largest model to obtain the optimized prompt and the multi-round dialogue information, including:
[0016] The initial prompt is optimized from multiple angles in turn using the second largest model in a multi-round question-answering manner; wherein each time the initial prompt is optimized from one angle using the second largest model, a round of dialogue information is generated;
[0017] The Prompt obtained after optimizing the initial Prompt from the last angle using the second largest model is used as the optimized Prompt; the combination of each round of dialogue information generated after optimizing the initial Prompt from various angles using the second largest model is used as the multi-round dialogue information.
[0018] In a possible implementation, for the current angle, optimizing the initial Prompt from the current angle using the second largest model includes:
[0019] Determine the Prompt to be optimized; if the current angle is the first angle, use the initial Prompt as the Prompt to be optimized; if the current angle is an angle other than the first angle, obtain the Prompt of the second largest model after optimization from the previous angle of the current angle as the Prompt to be optimized;
[0020] The Prompt to be optimized is optimized from the current angle using the second largest model to obtain the Prompt after the current angle is optimized.
[0021] In a possible implementation, the method of multiple rounds of question-answering is used to optimize the initial prompt from multiple perspectives using the second largest model, including:
[0022] By adopting a multi-round question-answering method, the second largest model is used to optimize the initial prompt from the perspectives of task requirement description analysis correction, negative example analysis correction, output format analysis correction and overall analysis correction.
[0023] In a possible implementation, the integrating the at least one group of Prompts and the at least one multi-round dialogue information to obtain a final optimized Prompt includes:
[0024] Obtain a preset integrated Prompt template, wherein the integrated Prompt template includes integrated task description information of the Prompt and a data filling slot;
[0025] Filling the at least one group of Prompts and the at least one multi-round dialogue information into the data filling slot to generate an integrated Prompt;
[0026] The integrated Prompt is input into the target large model to obtain the Prompt output by the target large model as the final optimized Prompt.
[0027] The second aspect of the present application provides a large model prompt word optimization device, comprising:
[0028] An acquisition unit, used to acquire a task requirement description given by a user;
[0029] A grouping optimization unit, used to optimize the Prompt generated based on the task requirement description using at least one group of large model combinations to obtain at least one group of Prompts and at least one multi-round dialogue information; each group of large model combinations corresponds to a group of Prompts and a multi-round dialogue information; the multi-round dialogue information is used to indicate the optimization process of the group of large models for the Prompt generated based on the task requirement description;
[0030] The integration unit is used to integrate the at least one group of Prompts and the at least one multi-round dialogue information to obtain a final optimized Prompt.
[0031] In a possible implementation, each group of large model combinations includes a first large model and a second large model, and the group optimization unit includes:
[0032] An initial prompt generating unit, used to call the first large model and generate an initial prompt based on the task requirement description;
[0033] The initial prompt optimization unit is used to optimize the initial prompt using the second largest model in a multi-round question-answering manner to obtain an optimized prompt and the multi-round dialogue information, wherein the combination of the initial prompt and the optimized prompt is the set of prompts.
[0034] In a possible implementation, the initial prompt optimization unit is specifically used to:
[0035] The initial prompt is optimized from multiple angles in turn using the second largest model in a multi-round question-answering manner; wherein each time the initial prompt is optimized from one angle using the second largest model, a round of dialogue information is generated;
[0036] The Prompt obtained after optimizing the initial Prompt from the last angle using the second largest model is used as the optimized Prompt; the combination of each round of dialogue information generated after optimizing the initial Prompt from various angles using the second largest model is used as the multi-round dialogue information.
[0037] In a possible implementation, the initial prompt optimization unit is specifically used to:
[0038] For the current angle, determine the Prompt to be optimized; if the current angle is the first angle, use the initial Prompt as the Prompt to be optimized; if the current angle is an angle other than the first angle, obtain the Prompt of the second largest model after optimization from the previous angle of the current angle as the Prompt to be optimized;
[0039] The Prompt to be optimized is optimized from the current angle using the second largest model to obtain the Prompt after the current angle is optimized.
[0040] In a possible implementation, the initial prompt optimization unit is specifically used to:
[0041] By adopting a multi-round question-answering method, the second largest model is used to optimize the initial prompt from the perspectives of task requirement description analysis correction, negative example analysis correction, output format analysis correction and overall analysis correction.
[0042] In a possible implementation, the integration unit is specifically used to:
[0043] Obtain a preset integrated Prompt template, wherein the integrated Prompt template includes integrated task description information of the Prompt and a data filling slot;
[0044] Filling the at least one group of Prompts and the at least one multi-round dialogue information into the data filling slot to generate an integrated Prompt;
[0045] The integrated Prompt is input into the target large model to obtain the Prompt output by the target large model as the final optimized Prompt.
[0046] A third aspect of the present application provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the large model prompt word optimization method of the first aspect or any implementation of the first aspect.
[0047] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0048] The memory is used to store computer programs;
[0049] The processor is used to execute the computer program so that the electronic device can implement the large model prompt word optimization method of the first aspect or any implementation method of the first aspect.
[0050] A fifth aspect of the present application provides a computer-readable storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the large model prompt word optimization method of the above-mentioned first aspect or any implementation of the first aspect.
[0051] By means of the above technical scheme, the large model prompt word optimization method and related device provided by the present application, after obtaining the task requirement description, first optimizes the Prompt generated based on the task requirement description by using at least one set of large model combinations based on the task requirement description to obtain at least one set of Prompt and at least one multi-round dialogue information; and then further integrates at least one set of Prompt and at least one multi-round dialogue information to obtain the final optimized Prompt. The entire scheme does not require complex training, and the optimization of Prompt can be achieved through confrontation and cooperation between models, which reduces the burden of manually constructing high-quality text, significantly reduces time and resource costs, and improves the automation and efficiency of Prompt optimization. Moreover, the optimization based on the wisdom of multiple large models can eliminate the blind spots of individual large models, enhance the diversity and robustness of the final optimized Prompt, and effectively improve the optimization effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0053] Figure 1 A schematic diagram of a flow chart of a large model prompt word optimization method provided in an embodiment of the present application;
[0054] Figure 2 A flowchart of a method for optimizing a Prompt generated based on a task requirement description to obtain a group of Prompts and a multi-round dialogue information provided in an embodiment of the present application;
[0055] Figure 3 A schematic diagram of obtaining a group of prompts and a multi-round dialogue information disclosed in an embodiment of the present application;
[0056] Figure 4 A schematic diagram of a Prompt optimization process provided in an embodiment of the present application;
[0057] Figure 5 A schematic diagram of the structure of a large model prompt word optimization device provided in an embodiment of the present application;
[0058] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0060] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0061] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0062] In recent years, large language models (LLMs), as important achievements in the field of artificial intelligence, have received widespread attention and application. Large-scale development has evolved from basic machine learning models to deep learning models, and has gradually acquired the powerful ability to understand and generate natural language. As the scale of parameters continues to increase, large models can more accurately capture the nuances in language, thereby achieving more intelligent tasks such as dialogue, text generation, and translation. These models can not only process a large amount of complex semantic information, but also demonstrate excellent performance in multi-task learning, knowledge reasoning, etc., making them widely used in various industries.
[0063] Prompt, or prompt word, is the bridge between users and large-scale interaction. In the interaction with large-scale, the design of prompt directly affects the quality of model output. A good prompt can guide the large model to generate more accurate and expected results, while an inappropriate prompt may cause the generated content to deviate from the topic or produce misleading information. Therefore, the design of prompt is not just a simple input text, but a combination of art and science.
[0064] An accurate prompt can reduce the possibility of large models generating biased or misleading content, thereby improving the reliability of generated content. Remember the phrase Let's think step by step in Zero-Shot COT? Recently, Google found a better phrase through OPRO: Take a deep breath and work on this problem step-by-step, which directly improved the GSM8K result from 71.8% -> 80.2%. It can be seen that a good prompt can stimulate the maximum potential of LLM, thereby achieving good results in downstream tasks. The charm (mystery) of prompts lies here. Before LLM was not "smart" enough, humans tamed LLM through prompt engineering.
[0065] As large models are increasingly used in various fields, optimizing Prompt has become the key to improving model performance. Various industries have invested resources and energy to continuously explore and improve Prompt optimization methods to ensure that large models can achieve maximum performance in practical applications.
[0066] By carefully designing and iteratively optimizing Prompt, we are able to fully unleash the potential of large models and make them perform better in various complex tasks.
[0067] Currently, Prompt's optimization methods are mainly divided into two categories: manual optimization and automatic optimization.
[0068] Manual optimization is currently the most direct and traditional optimization method. Through manual design and adjustment, optimizers can refine the prompt based on their understanding of the task requirements. The advantage of manual optimization lies in its flexibility and pertinence, and can tailor prompts according to the characteristics and requirements of specific tasks.
[0069] This approach usually includes the following steps:
[0070] 1) Gradual refinement: Optimizers gradually refine the expression of prompts through repeated trials. For example, in generative tasks, by adding details to prompts or adjusting wording, the model is guided to generate content that is more in line with expectations.
[0071] 2) Multiple rounds of testing and feedback: Manual optimization relies on repeated testing and feedback. Optimizers will design multiple prompt versions, compare the output effects of these versions through multiple rounds of testing, and gradually find the optimal prompt.
[0072] 3) Adjustment of context information: Manual optimization also includes the adjustment of context information. By adding more context information to the prompt, optimizers can help the model better understand the task background and generate more accurate results.
[0073] 4) Application of experience and intuition: Experienced optimizers can use intuition to design and adjust prompts based on their understanding of language and tasks. Although this approach relies on personal experience, it can often achieve significant results in complex tasks.
[0074] Although manual optimization methods have the advantages of high flexibility and customization, they also have some challenges, such as being time-consuming and requiring high expertise. Therefore, with the widespread application of large models, automated optimization has gradually gained attention.
[0075] Automated optimization is to automatically generate and adjust prompts through algorithms and technical means to improve the output quality of large models. This method usually relies on data-driven and machine learning technologies, which can generate a large number of prompt candidates in a short time and select the best solution from them.
[0076] The main methods of automatic optimization include:
[0077] 1) Templated generation: Multiple prompt candidates are automatically generated through predefined templates. Templated generation can quickly cover different expressions and language structures, providing a rich selection space.
[0078] 2) Reinforcement Learning: Using reinforcement learning algorithms, Prompt is automatically optimized. The system will adjust the design of Prompt based on the quality of the model output results, thus forming a continuously optimized feedback loop and gradually improving the effect of Prompt.
[0079] 3) Large-scale search and evaluation: Automatic optimization methods usually rely on large-scale search and evaluation. A large number of different prompts are generated through automated tools, and these prompts are evaluated using models to select the best versions.
[0080] 4) AI-assisted design: Use AI models to assist in the design and optimization of prompts. For example, by analyzing past data, AI models can predict which prompt designs are likely to produce better results, thereby helping optimizers find the right solution faster.
[0081] The advantages of automated optimization are its efficiency and scalability. It can complete a large number of optimization tasks in a short period of time and can effectively handle complex multi-task scenarios. However, automated optimization may lack the flexibility of manual optimization in some cases, especially when a deep understanding of the task background and language details is required. In addition, existing automated optimization technologies also have the following disadvantages:
[0082] Disadvantage 1: Most of the current prompt optimization methods require training. Although the prompt optimization methods that rely on training have performed well in improving model performance, they also have significant disadvantages. These disadvantages include high consumption of time and computing resources, high dependence on high-quality data, limited model generalization capabilities, high development barriers, and uncertainty in the optimization process. These factors limit the effectiveness of prompt optimization in certain application scenarios and highlight the need for more efficient and more general optimization methods.
[0083] Disadvantage 2: Current prompt optimization methods usually rely on a single large model or a single standard. Although this method can quickly generate results, it also has significant limitations. Due to the single perspective, the optimization process often fails to fully capture the complexity and diversity of the task, which can easily lead to insufficient coverage. In addition, prompt optimization is usually a process that requires continuous iteration and adjustment. The lack of multi-angle feedback and real-time iterative improvement mechanism limits the depth and quality of optimization. This single-standard optimization method may not be able to effectively cope with complex or innovative tasks, resulting in the final result being difficult to achieve the expected comprehensiveness and accuracy.
[0084] It can be seen that the existing automatic optimization technology has low optimization efficiency and poor optimization effect.
[0085] In order to solve the above problems, the embodiment of the present application provides a large model prompt word optimization method. The large model prompt word optimization method of the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0086] Reference Figure 1 , Figure 1 A flowchart of a large model prompt word optimization method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, a large model prompt word optimization method provided in an embodiment of the present application may include the following steps, which are described in detail below.
[0087] S101: Obtaining a task requirement description given by a user;
[0088] In this application, the task requirement description is given by any user. The user does not need to have strong summarization ability. The user can be a professional NLP practitioner or a non-professional NLP (Natural Language Processing) practitioner. The task requirement description can be in any form, including but not limited to the following: ① Direct task overview; ② Task specification details with special requirements; ③ Only input and output samples; ④ With expected output format restrictions, no matter what form, it only needs to be provided by the user, and its role is to enable LLM1 to generate an initial prompt according to the task requirement description. For example: "I will give you a question, and you need to extract the parameters in this question, including the topic, country, and time parameters."
[0089] S102: using at least one group of large model combinations, optimizing the Prompt generated based on the task requirement description to obtain at least one group of Prompts and at least one multi-round dialogue information; each group of large model combinations corresponds to a group of Prompts and a multi-round dialogue information; the multi-round dialogue information is used to indicate the optimization process of the group of large models for the Prompt generated based on the task requirement description;
[0090] In the present application, each group of large model combinations includes a first large model and a second large model. The first large model and the second large model can be any two different large models in the existing large models, or can be the same large model. This application does not impose any limitation on this.
[0091] The number of large model combinations can be one group or multiple groups, which can be determined based on user needs, and this application does not impose any restrictions on this. Using multiple groups of large models has obvious advantages over a single group of large models. It provides diversity and richness, can be optimized from more angles, and improves the comprehensiveness and robustness of Prompt; it can also reduce the risk of bias, better compare and verify different solutions, and speed up the discovery and iteration of innovative improvements, and obtain more robust and adaptable optimization results. Therefore, as a preferred method, multiple groups of large model combinations can be used in this application to optimize the Prompt generated based on the task requirement description to obtain multiple groups of Prompts and multiple multi-round dialogue information.
[0092] S103: Integrate the at least one group of Prompts and the at least one multi-round dialogue information to obtain a final optimized Prompt.
[0093] In the present application, a Prompt can be selected from the at least one group of Prompts as the final optimized Prompt based on the at least one multi-round dialogue information, or a new Prompt can be regenerated as the final optimized Prompt based on the at least one group of Prompts and the at least one multi-round dialogue information. This application does not impose any limitations on this.
[0094] In this embodiment, after obtaining the task requirement description, at least one group of large models are combined based on the task requirement description to optimize the Prompt generated based on the task requirement description to obtain at least one group of Prompts and at least one multi-round dialogue information; and at least one group of Prompts and at least one multi-round dialogue information are further integrated to obtain the final optimized Prompt. The entire solution does not require complex training, and the optimization of Prompt can be achieved through confrontation and cooperation between models, which reduces the burden of manually constructing high-quality texts, significantly reduces time and resource costs, and improves the automation and efficiency of Prompt optimization. Moreover, the optimization based on the wisdom of multiple large models can eliminate the blind spots of individual large models, enhance the diversity and robustness of the final optimized Prompt, and effectively improve the optimization effect.
[0095] In one possible implementation, each group of large model combinations includes a first large model and a second large model. In another embodiment of the present application, a method for optimizing the Prompt generated based on the task requirement description to obtain a group of Prompts and a multi-round dialogue information for each group of large model combinations is described in detail.
[0096] Reference Figure 2 , Figure 2 A flowchart of a method for optimizing a Prompt generated based on a task requirement description to obtain a set of Prompts and a multi-round dialogue information is provided in an embodiment of the present application, such as Figure 2 As shown, the method comprises the following steps:
[0097] S201: Based on the task requirement description, calling the first large model to generate an initial prompt;
[0098] After obtaining the task requirement description given by the user, it is necessary to generate a Prompt template based on the preset initial Prompt, generate an initial Prompt, and input the initial Prompt into the first large model (for the convenience of description, LLM1 is used to refer to the first large model in this application). LLM1 can output a Prompt, which can be used as the initial Prompt to be optimized.
[0099] For ease of understanding, the present application embodiment provides a preset initial prompt to generate a prompt template example, as follows:
[0100] Now I have a requirement. The task requirement description given to you may be a direct task description, or it may give some special requirements, or even just give input and output samples. You need to write a prompt that meets the requirements based on these requirements. The task requirement description is: {Here is the task requirement description given by the user}. Please generate a prompt for this task based on the above description.
[0101] Based on the above-mentioned example of generating a Prompt template from the initial Prompt, the embodiment of the present application also provides an example of input and output data of LLM1, as shown in Table 1 below:
[0102] Table 1
[0103]
[0104] As shown in Table 1, LLM1 will output a prompt that can include the task requirement description given by the user. This prompt still needs to be improved.
[0105] S202: Adopting a multi-round question-answering method, using the second largest model to optimize the initial Prompt, to obtain an optimized Prompt and the multi-round dialogue information, the combination of the initial Prompt and the optimized Prompt is the set of Prompts.
[0106] For easier understanding, please refer to Figure 3 , Figure 3 This is a schematic diagram of obtaining a group of prompts and a multi-round dialogue information disclosed in an embodiment of the present application. Figure 3 As shown in the figure, LLM1 first generates prompt1 (i.e., the initial prompt) based on the task requirement description, and LLM2 conducts multiple rounds of dialogue based on prompt1 to obtain a multi-round dialogue information and prompt2 (i.e., the optimized prompt).
[0107] In a possible implementation, the multi-round question-answering method is used to optimize the initial prompt using the second largest model to obtain the optimized prompt and the multi-round dialogue information, including:
[0108] The method of multiple rounds of question and answer is adopted, and the second largest model is used to optimize the initial Prompt from multiple angles in sequence; wherein, after the initial Prompt is optimized from one angle by using the second largest model each time, a round of dialogue information is generated; the Prompt obtained after the initial Prompt is optimized from the last angle by using the second largest model is used as the optimized Prompt; and the combination of each round of dialogue information generated after the initial Prompt is optimized from various angles by using the second largest model is used as the multi-round dialogue information.
[0109] Specifically, for the current angle, the initial Prompt is optimized from the current angle using the second largest model, including: determining the Prompt to be optimized; if the current angle is the first angle, using the initial Prompt as the Prompt to be optimized; if the current angle is an angle other than the first angle, obtaining the Prompt after the second largest model is optimized from the previous angle of the current angle as the Prompt to be optimized; optimizing the Prompt to be optimized from the current angle using the second largest model to obtain the Prompt after the current angle is optimized.
[0110] In this application, a multi-round question-and-answer method is used, and the second largest model is used to optimize the initial Prompt from multiple angles in turn. It is possible to observe the description of the task requirements in the initial Prompt from different angles, propose details or problems that the first largest model may not have considered, point out deficiencies and give constructive suggestions, and gradually provide feedback to continuously optimize the quality of the initial Prompt. Compared with traditional manual adjustments or reliance on single model feedback, the optimization method of multi-model collaboration gradually refines the Prompt and improves its accuracy and adaptability through the advantages of multi-angle feedback, higher efficiency and reduced deviation. Multiple rounds of iterative optimization make Prompt more robust and better able to cope with complex tasks.
[0111] In the present application, as an implementable method, at least two can be selected from the task requirement description analysis correction angle, the negative example analysis correction angle, the output format analysis correction angle and the overall analysis correction angle, and multiple rounds of question and answer can be used to optimize the initial prompt from the selected angles in turn using the second largest model.
[0112] As a preferred method, in this application, a multi-round question-and-answer method can be adopted, and the second largest model can be used to optimize the initial Prompt from the perspectives of task requirement description analysis correction, negative example analysis correction, output format analysis correction, and overall analysis correction.
[0113] In this method, the Prompt obtained after optimizing the initial Prompt from the perspective of overall analysis and correction using the second largest model can be used as the optimized Prompt; the combination of each round of dialogue information generated after optimizing the initial Prompt from various angles using the second largest model can be used as the multi-round dialogue information.
[0114] For ease of understanding, this application provides a specific implementation method for optimizing the initial Prompt using the second largest model from the perspectives of task requirement description analysis correction, negative example analysis correction, output format analysis correction, and overall analysis correction, as follows:
[0115] ①Task requirement description analysis correction angle:
[0116] This perspective mainly needs to analyze whether the initial prompt accurately expresses the task requirement description, and correct the task requirement description errors in the initial prompt.
[0117] The implementation method is to generate a task requirement description analysis correction Prompt based on a preset task requirement description analysis correction Prompt template, and input the task requirement description analysis correction Prompt into the second largest model (for the convenience of description, LLM2 is used in this application to refer to the second largest model), and LLM2 can output a reply. The reply and the task requirement description analysis correction Prompt are a round of dialogue information, and the reply includes the task requirement description analysis results and the task requirement description after correction Prompt.
[0118] For ease of understanding, the present application embodiment provides a preset task requirement description analysis correction prompt template example, which is as follows:
[0119] I have a requirement, the task requirement description is: {Here is the task requirement description given by the user}, based on the above description, a prompt generated for this task is: {Here is the initial prompt generated by LLM1}. Now please analyze the above prompt, what do you think are the deficiencies that lead to the task requirement description not being clear enough, which may be ambiguous and lead to errors, please point out the deficiencies and give suggestions.
[0120] Based on the above preset task requirement description analysis correction prompt template example, the embodiment of the present application also provides an example of input and output data of LLM2 in the task requirement description analysis correction angle, as shown in Table 2 below:
[0121] Table 2
[0122]
[0123] As shown in Table 2, the improved prompt example output by LLM2 (i.e., the prompt after the task requirement description is corrected) is more comprehensive and professional in describing the task requirement than the initial prompt. The optimization from this perspective can flexibly apply the powerful knowledge reserve capacity of the large model itself. Compared with manual verification, the efficiency and effect are greatly improved.
[0124] ② Negative example analysis correction angle:
[0125] Due to the diversity of natural languages, the meanings of expressions in different word orders may be different. Based on this, in this application, the corrected Prompt of the task requirement description can be further improved through negative example analysis correction.
[0126] The implementation method is to generate a negative example analysis correction Prompt based on a preset negative example analysis correction Prompt template, and input the negative example analysis correction Prompt into LLM2, and LLM2 can output a reply. The reply and the negative example analysis correction Prompt are a round of dialogue information. The reply contains negative examples, negative example analysis results, and the Prompt after negative example analysis correction.
[0127] For ease of understanding, the present application embodiment provides a preset negative example analysis correction prompt template example, which is as follows:
[0128] I have a requirement, the task requirement description is: {Here is the task requirement description given by the user}, based on the above description, a prompt generated for this task is: {Here is the corrected prompt for the task requirement description}. Now please analyze the above prompt, and based on the above prompt, please give a negative example, that is, an example based on which this prompt may have an error, to prove that this task may have an ambiguous description, and based on this error example, give a modification suggestion for the prompt.
[0129] Based on the above preset negative example analysis correction prompt template example, the embodiment of the present application also provides an input and output data example of LLM2 in the negative example analysis correction angle, as shown in the following Table 3:
[0130] Table 3
[0131]
[0132] As shown in Table 3, the modified Prompt output by LLM2 (i.e., the Prompt corrected by negative example analysis) is more comprehensive and professional in expressing the task requirement description than the Prompt corrected by the task requirement description. The optimization from this perspective can flexibly apply the powerful knowledge reserve capacity of the large model itself. Compared with relying on fixed thinking to rack one's brains to come up with negative examples, the efficiency and effect are greatly improved.
[0133] ③ Output format analysis correction angle:
[0134] Good output format restrictions can ensure the consistency and standardization of task results, reduce ambiguity, improve the accuracy of information extraction, enhance readability and usability, and facilitate subsequent automated data processing, ultimately reducing the error rate and improving the efficiency of overall task execution. Based on this, in this application, the Prompt after the negative example analysis correction is further improved through output format analysis correction.
[0135] The implementation method is to generate an output format analysis correction Prompt based on a preset output format analysis correction Prompt template, and input the output format analysis correction Prompt into LLM2, and LLM2 can output a reply. The reply and the output format analysis correction Prompt are a round of dialogue information. The reply contains the output format analysis result and the Prompt after output format correction.
[0136] For ease of understanding, the present application embodiment provides a preset output format analysis correction prompt template example, which is as follows:
[0137] I have a requirement, the task requirement description is: {Here is the task requirement description given by the user}, based on the above description, a prompt generated for this task is: {Here is the prompt after the negative example analysis correction}. Now please analyze the above prompt. For your modified prompt, are there any problems with the output format restrictions? Please give suggestions so that it can adapt to various complex situations and give a modified prompt.
[0138] Based on the above preset output format analysis correction prompt template example, the embodiment of the present application also provides an example of input and output data of LLM2 in output format analysis correction angle, as shown in Table 4 below:
[0139] Table 4
[0140]
[0141] As shown in Table 4, the modified Prompt output by LLM2 (i.e., the Prompt after the output format is corrected) has a more complete output format compared with the Prompt after the negative example analysis correction.
[0142] ④Overall analysis and correction angle:
[0143] Considering that the optimization angles for Prompt are not exhaustive, in order to further improve the quality of Prompt, in this application, the output format of Prompt can be further improved through overall analysis and correction.
[0144] The implementation method is to generate an overall analysis correction Prompt based on a preset overall analysis correction Prompt template, and input the overall analysis correction Prompt into LLM2, and LLM2 can output a reply. The reply and the overall analysis correction Prompt are a round of dialogue information. The reply contains the overall analysis results and the Prompt after the overall analysis correction.
[0145] For ease of understanding, the present application embodiment provides a preset overall analysis correction prompt template example, which is as follows:
[0146] I have a requirement, the task requirement description is: {Here is the task requirement description given by the user}, based on the above description, a prompt generated for this task is: {Here is the prompt after the output format is corrected}. Now please analyze the above prompt. Overall, is there anything that needs to be improved? Please give suggestions and provide the modified prompt.
[0147] Based on the above-mentioned preset overall analysis correction prompt template example, the embodiment of the present application also provides an example of input and output data of LLM2 in the overall analysis correction angle, as shown in the following Table 5:
[0148] Table 5
[0149]
[0150] As shown in Table 5, the modified Prompt (i.e., optimized Prompt) output by LLM2 has many improvements compared with the initial Prompt, and it is a more complete Prompt.
[0151] In another embodiment of the present application, a specific implementation method of S103 integrating the at least one group of Prompts and the at least one multi-round dialogue information to obtain a final optimized Prompt is described, including: obtaining a preset integrated Prompt template, the integrated Prompt template containing integrated task description information and a data filling slot of the Prompt; filling the at least one group of Prompts and the at least one multi-round dialogue information into the data filling slot to generate an integrated Prompt; inputting the integrated Prompt into the target large model to obtain the Prompt output by the target large model as the final optimized Prompt.
[0152] It should be noted that after obtaining at least one set of prompts and at least one multi-round dialogue information, it is necessary to generate an integrated prompt based on a preset integrated prompt template, and input the integrated prompt into the target large model, and the target large model can output a prompt, which can be used as the final optimized prompt. In this application, the target large model can be any large model, preferably a large model selected by the user for performing tasks.
[0153] For ease of understanding, the present application embodiment provides a preset integrated prompt template example, which is as follows:
[0154] You will receive multiple sets of prompt optimization results and suggestions generated by LLM for a certain task. Your task is to integrate and refine these optimization results and generate a final optimized prompt. Please follow the steps below:
[0155] 1. **Classification and organization**: Please classify and organize all optimization suggestions according to different dimensions (task description, format requirements, negative example processing, etc.).
[0156] 2. **Compare and analyze**: Compare each set of optimization suggestions, analyze the commonalities and differences, and find out which suggestions are generally applicable in different models and which suggestions are more innovative.
[0157] 3. **Extract the best solution**: Based on the comparison results, extract the best prompt, combine the highlights from different feedbacks, and form a complete and optimized prompt.
[0158] Next, the text that needs to be analyzed is {here is at least one set of prompts and at least one multi-round dialogue information}. Please make sure your answer is clear and complete, and output the final prompt.
[0159] Among them, "{here is at least one set of Prompt and at least one multi-round dialogue information}" is the data filling slot.
[0160] For a better understanding of the entire technical solution, please refer to the attached Figure 4 , Figure 4 A schematic diagram of a Prompt optimization process provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, assuming there are n groups of large models, such as Figure 4 In the LLM1 to LLMn shown, each group of large models includes two large models, such as LL1 and LLM2, LLM1 and LLMn, etc. Each group of large models generates a group of Prompts and a multi-round dialogue information. The target large model LLM generates a prompt based on each group of Prompts and each multi-round dialogue information, which is the final optimized Prompt.
[0161] In summary, the solution proposed in this application not only improves the applicability and accuracy of prompts by integrating the wisdom and feedback of multiple groups of models, but also greatly reduces the need for manual intervention, making the optimization of complex tasks more efficient and robust. It allows non-professionals to easily play with the optimization of large model prompts.
[0162] A large model prompt word optimization method provided in an embodiment of the present application is introduced above, and a device for executing the large model prompt word optimization method will be introduced below.
[0163] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of a large model prompt word optimization device provided in an embodiment of the present application. Figure 5 As shown, the large model prompt word optimization device includes:
[0164] An acquisition unit 11 is used to acquire a task requirement description given by a user;
[0165] The group optimization unit 12 is used to optimize the Prompt generated based on the task requirement description using at least one group of large model combinations to obtain at least one group of Prompts and at least one multi-round dialogue information; each group of large model combinations corresponds to a group of Prompts and a multi-round dialogue information; the multi-round dialogue information is used to indicate the optimization process of the group of large models for the Prompt generated based on the task requirement description;
[0166] The integration unit 13 is used to integrate the at least one group of Prompts and the at least one multi-round dialogue information to obtain a final optimized Prompt.
[0167] In a possible implementation, each group of large model combinations includes a first large model and a second large model, and the group optimization unit includes:
[0168] An initial prompt generating unit, used to call the first large model and generate an initial prompt based on the task requirement description;
[0169] The initial prompt optimization unit is used to optimize the initial prompt using the second largest model in a multi-round question-answering manner to obtain an optimized prompt and the multi-round dialogue information, wherein the combination of the initial prompt and the optimized prompt is the set of prompts.
[0170] In a possible implementation, the initial prompt optimization unit is specifically used to:
[0171] The initial prompt is optimized from multiple angles in turn using the second largest model in a multi-round question-answering manner; wherein each time the initial prompt is optimized from one angle using the second largest model, a round of dialogue information is generated;
[0172] The Prompt obtained after optimizing the initial Prompt from the last angle using the second largest model is used as the optimized Prompt; the combination of each round of dialogue information generated after optimizing the initial Prompt from various angles using the second largest model is used as the multi-round dialogue information.
[0173] In a possible implementation, the initial prompt optimization unit is specifically used to:
[0174] For the current angle, determine the Prompt to be optimized; if the current angle is the first angle, use the initial Prompt as the Prompt to be optimized; if the current angle is an angle other than the first angle, obtain the Prompt of the second largest model after optimization from the previous angle of the current angle as the Prompt to be optimized;
[0175] The Prompt to be optimized is optimized from the current angle using the second largest model to obtain the Prompt after the current angle is optimized.
[0176] In a possible implementation, the initial prompt optimization unit is specifically used to:
[0177] By adopting a multi-round question-answering method, the second largest model is used to optimize the initial prompt from the perspectives of task requirement description analysis correction, negative example analysis correction, output format analysis correction and overall analysis correction.
[0178] In a possible implementation, the integration unit is specifically used to:
[0179] Obtain a preset integrated Prompt template, wherein the integrated Prompt template includes integrated task description information of the Prompt and a data filling slot;
[0180] Filling the at least one group of Prompts and the at least one multi-round dialogue information into the data filling slot to generate an integrated Prompt;
[0181] The integrated Prompt is input into the target large model to obtain the Prompt output by the target large model as the final optimized Prompt.
[0182] The present application also provides an electronic device in an embodiment. Figure 6 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0183] like Figure 6 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 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.
[0184] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0185] An embodiment of the present application also provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any large model prompt word optimization method provided in the embodiment of the present application.
[0186] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any large model prompt word optimization method provided in the embodiment of the present application.
[0187] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0188] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0189] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0190] 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 may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A large model prompt word optimization method, characterized in that: include: Obtain the task requirement description given by the user; Using at least one set of large model combinations, optimizing the prompts generated based on the task requirement description to obtain at least one set of prompts and at least one multi-round dialogue information; Each large model combination corresponds to a set of prompts and a multi-round dialogue message; The multi-round dialogue information is used to indicate the optimization process of the group of large models for the Prompt generated based on the task requirement description; The at least one group of Prompts and the at least one multi-round dialogue information are integrated to obtain a final optimized Prompt.
2. The method according to claim 1, characterized in that Each group of large model combinations includes a first large model and a second large model. For each group of large model combinations, the prompt generated based on the task requirement description is optimized to obtain a group of prompts and a multi-round dialogue information as follows: Based on the task requirement description, the first large model is called to generate an initial prompt; The initial Prompt is optimized using the second largest model in a multi-round question-answering manner to obtain an optimized Prompt and the multi-round dialogue information, and a combination of the initial Prompt and the optimized Prompt is the set of Prompts.
3. The method according to claim 2, characterized in that The method of using multiple rounds of question and answer, and using the second largest model to optimize the initial prompt, obtain the optimized prompt and the multiple rounds of dialogue information, including: The initial prompt is optimized from multiple angles in turn using the second largest model in a multi-round question-answering manner; wherein each time the initial prompt is optimized from one angle using the second largest model, a round of dialogue information is generated; The Prompt obtained after optimizing the initial Prompt from the last angle using the second largest model is used as the optimized Prompt; the combination of each round of dialogue information generated after optimizing the initial Prompt from various angles using the second largest model is used as the multi-round dialogue information.
4. The method according to claim 3, characterized in that For the current angle, the initial Prompt is optimized from the current angle using the second largest model, including: Determine the Prompt to be optimized; if the current angle is the first angle, use the initial Prompt as the Prompt to be optimized; if the current angle is an angle other than the first angle, obtain the Prompt of the second largest model after optimization from the previous angle of the current angle as the Prompt to be optimized; The Prompt to be optimized is optimized from the current angle using the second largest model to obtain the Prompt after the current angle is optimized.
5. The method according to claim 3, characterized in that: The method of multiple rounds of question and answer is used to optimize the initial prompt from multiple angles using the second largest model, including: By adopting a multi-round question-answering method, the second largest model is used to optimize the initial prompt from the perspectives of task requirement description analysis correction, negative example analysis correction, output format analysis correction and overall analysis correction.
6. The method according to claim 1, characterized in that The step of integrating the at least one group of prompts and the at least one multi-round dialogue information to obtain a final optimized prompt includes: Obtain a preset integrated Prompt template, wherein the integrated Prompt template includes integrated task description information of the Prompt and a data filling slot; Filling the at least one group of Prompts and the at least one multi-round dialogue information into the data filling slot to generate an integrated Prompt; The integrated Prompt is input into the target large model to obtain the Prompt output by the target large model as the final optimized Prompt.
7. A large model prompt word optimization device, characterized in that: include: An acquisition unit, used to acquire a task requirement description given by a user; A grouping optimization unit, configured to optimize the prompts generated based on the task requirement description using at least one group of large model combinations to obtain at least one group of prompts and at least one multi-round dialogue information; Each large model combination corresponds to a set of prompts and a multi-round dialogue message; The multi-round dialogue information is used to indicate the optimization process of the group of large models for the Prompt generated based on the task requirement description; The integration unit is used to integrate the at least one group of Prompts and the at least one multi-round dialogue information to obtain a final optimized Prompt.
8. A computer program product, characterized in that It includes computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the large model prompt word optimization method as described in any one of claims 1 to 6.
9. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the large model prompt word optimization method as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the large model prompt word optimization method as described in any one of claims 1 to 6.
Citation Information
Cited By
Cue word layered optimization method for complex problem decomposition
CN120234399A
Prompt word optimization method, intelligent agent and storage medium
CN120278153A
Code generation method and device based on large model
CN120929061A
A large model-based code generation method and device
CN120929061B
Large model Prompt dynamic generation method and device and medium
CN121214462A