Prompt optimization method, computer program product, equipment and readable storage medium
By combining general large model and fine-tuning model, using feedback information to optimize prompt words, the problem of the general pre-trained model's complex prompt word optimization in professional fields is solved, and efficient and quality optimized prompt word output is achieved.
Patent Information
- Application Number
- CN202510365427.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-07-18
AI Technical Summary
The existing general pre-trained model has complex processes and poor optimization effects and efficiency in the prompt word optimization process in professional fields.
Combining the pre-trained general big model and fine-tuning model, the prompt words are optimized through feedback information, and the general big model is used to provide a guarantee when the fine-tuning model is insufficient. The quality of the prompt words is improved through generalization extraction and feedback library update, and the prompt words that meet the requirements are directly output.
It improves the efficiency and quality of prompt words optimization in professional fields, lowers the threshold for use, and enhances practicality.
Smart Images

Figure CN120337915A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technologies, and particularly to a method for optimizing prompt words, a computer program product, a device, and a readable storage medium. Background Art
[0002] A prompt can be a word, phrase, sentence, paragraph, or even an entire document, and its quality directly affects the model's understanding ability and task execution efficiency. That is, by designing and optimizing the input, it is possible to guide the LLM (Large Language Model) to generate more accurate, relevant, and high-quality outputs. Therefore, the prompt optimization technology is an important research direction in the field of artificial intelligence in recent years.
[0003] Currently, some solutions for optimizing prompt words using general pre-trained models have been proposed. However, although general pre-trained models have rich knowledge reserves, the process of optimizing prompt words is complex, especially for professional fields, where the optimization effect and efficiency of prompt words are poor. Summary of the Invention
[0004] To solve the above technical problems, this application provides a method for optimizing prompt words, a computer program product, a device, and a readable storage medium.
[0005] In a first aspect, this application provides a method for optimizing prompt words, including the following steps:
[0006] According to the task description input to the target large language model, guide the pre-trained general large model and the pre-trained fine-tuning model to respectively output prompt words;
[0007] According to the task description, guide the general large model to respectively output feedback information for the two prompt words;
[0008] In response to the feedback information indicating that at least one of the prompt words meets the output requirements, output the corresponding prompt word as the target prompt word, and the target prompt word is used to replace the task description and input it into the target large language model;
[0009] In response to the feedback information indicating that none of the prompt words meet the output requirements, guide the general large model to optimize the prompt words based on the feedback information and output the feedback information for the optimized prompt words.
[0010] In one embodiment, the general large model is used to output the feedback information based on a feedback library;
[0011] After guiding the general large model to optimize the prompt words based on the feedback information and output the feedback information for the optimized prompt words, it further includes:
[0012] Update the feedback library according to the feedback information of the prompt words before and after optimization;
[0013] According to the task description, guide the general large model to output the feedback information of the prompt words before and after optimization based on the updated feedback library.
[0014] In one embodiment, after guiding the general large model to optimize the prompt word based on the feedback information and output the feedback information of the optimized prompt word, it further includes:
[0015] Write the prompt words before and after optimization and the feedback information into the temporary result library correspondingly;
[0016] In response to the update count of the feedback library reaching the first preset count or the optimization count of the prompt word reaching the second preset count, determine the target prompt word from the temporary result library according to the feedback information and output it.
[0017] In one embodiment, after determining the target prompt word from the temporary result library according to the feedback information, it further includes:
[0018] Determine at least one highly relevant prompt word and at least one lowly relevant prompt word from the temporary result library according to the task description and the feedback information;
[0019] Construct at least one piece of preference data and store it in the database, where the preference data includes the task description, one of the highly relevant prompt words and one of the lowly relevant prompt words;
[0020] In response to the preference data in the database reaching the preset quantity, train the fine-tuning model based on the preference data.
[0021] In one embodiment, the updating the feedback library according to the feedback information of the prompt words before and after optimization includes:
[0022] Guide the general large model to determine the target feedback information from the feedback information of the prompt words before and after optimization;
[0023] Perform generalization extraction on the target feedback information to obtain a first generalization extraction result;
[0024] Update the feedback library based on the first generalization extraction result.
[0025] In one embodiment, the general large model is used to output the prompt word based on a general prompt library;
[0026] After outputting the target prompt word, it further includes:
[0027] Perform generalization extraction on the target prompt to obtain a second generalization extraction result;
[0028] Update the general prompt library according to the second generalization extraction result.
[0029] In one embodiment, the feedback information includes modification opinions and evaluation information of the corresponding prompt, and the evaluation information is used to characterize the correlation degree between the corresponding prompt and the task description.
[0030] In a second aspect, the present application provides a computer program product, including computer programs / instructions, which when executed by a processor, implement the steps of the method described in the first aspect.
[0031] In a third aspect, the present application provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the method described in the first aspect is implemented.
[0032] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0033] On the basis of conforming to the common knowledge in the art, the above preferred conditions can be combined arbitrarily to obtain various preferred examples of the present application.
[0034] The above-mentioned prompt optimization method, computer program product, device, and readable storage medium can achieve the following beneficial effects: combining a general large model with a fine-tuning model, in the case where the quality of the prompt output by the fine-tuning model is poor for the task description in a professional field, using the general large model as a fallback to improve the quality of the output target prompt, reduce the usage threshold, and improve the practicability. In the case where the fine-tuning model can directly output a prompt with better quality, directly output the target prompt that meets the output requirements, and improve the efficiency of prompt optimization. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is the first flowchart of the prompt optimization method in an embodiment of the present application;
[0036] Figure 2 It is the second flowchart of the prompt optimization method in an embodiment of the present application;
[0037] Figure 3 It is the third flowchart of the prompt optimization method in an embodiment of the present application;
[0038] Figure 4The fourth process schematic diagram of the prompt optimization method in an embodiment of the present application;
[0039] Figure 5 The fifth process schematic diagram of the prompt optimization method in an embodiment of the present application;
[0040] Figure 6 The module schematic diagram of the prompt optimization system in an embodiment of the present application;
[0041] Figure 7 The first internal structure diagram of the computer device in an embodiment of the present application;
[0042] Figure 8 The second internal structure diagram of the computer device in an embodiment of the present application. Detailed implementation manners
[0043] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.
[0044] It should be noted that the diagrams provided in this embodiment only illustrate the basic concept of the present application in a schematic manner. The diagrams only show the components related to the present application, rather than being drawn according to the number, shape and size of the components in actual implementation. The form, quantity and proportion of each component in actual implementation can be arbitrarily changed, and the component layout form may also be more complex. The structures, proportions, sizes, etc. shown in the drawings of this specification are only used to cooperate with the content disclosed in the specification for those skilled in this technology to understand and read, and are not used to limit the limiting conditions under which the present application can be implemented. Therefore, they do not have technical substance. Any modification of the structure, change of the proportional relationship or adjustment of the size, without affecting the effects that the present application can produce and the purposes that can be achieved, should still fall within the scope that can be covered by the technical content disclosed in the present application. At the same time, the terms such as "upper", "lower", "left", "right", "middle" and "one" cited in this specification are only for the convenience of clear description and are not used to limit the scope under which the present application can be implemented. The change or adjustment of their relative relationship, without substantial change of the technical content, should also be regarded as the scope under which the present application can be implemented.
[0045] Referring to "embodiment" in this article means that the specific features, structures or characteristics described in combination with the embodiment can be included in at least one embodiment of the present application. The phrase appears in various positions in the text does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0046] As shown herein, unless the context clearly indicates otherwise, words such as "a", "an", "one", and / or "the" are not specifically singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of the steps and elements that have been clearly identified, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements.
[0047] The definitions included herein, such as the terms "have", "may have", "include", or "may include" as used herein, indicate the existence of the corresponding functions, operations, elements, etc. of this article, and do not limit the existence of one or more other functions, operations, elements, etc. In addition, it should be understood that the terms "include" or "have" as used herein indicate the existence of the features, numbers, steps, operations, elements, components, or combinations thereof described in the specification, and do not exclude the existence or addition of one or more other features, numbers, steps, operations, elements, components, or combinations thereof.
[0048] In the embodiments of this application, prefix words such as "first" and "second" are only used to distinguish different described objects, and have no limiting effect on the position, order, priority, quantity, content, etc. of the described objects. The use of ordinal numbers and other prefix words for distinguishing described objects in the embodiments of this application does not constitute a limitation on the described objects. The statements of the described objects refer to the description in the context of the claims or embodiments, and should not constitute an unnecessary limitation due to the use of such prefix words. In addition, in the description of this embodiment, unless otherwise specified, the meaning of "a plurality" is two or more.
[0049] As Figure 1 shown, in one embodiment, the prompting word optimization method provided by this application includes:
[0050] S101. According to the task description input to the target large language model, guide the pre-trained general large model and the pre-trained fine-tuning model to respectively output prompting words.
[0051] Among them, the task description is usually input by the user and is used to guide the target large language model to generate the content desired by the user.
[0052] For the task description, the general large model is used to output prompting words based on the general prompting word library. The general prompting word library usually includes the required general rules, general instructions, and several (such as 5-10) general structured prompts in a specific domain (vertical domain). These prompts can be preset manually or generated using the general large model.
[0053] Exemplarily, the task description can be input into a general large model, and the general large model can be guided by the input instruction to select a prompt most relevant to the task description from the general prompt library and refine and complete it according to the task description as the output prompt.
[0054] For the task description, the fine-tuning model is used to directly generate the corresponding prompt. The fine-tuning model can be a pre-trained model without fine-tuning, such as smaller models like Qwen2.5-3B and Qwen2.5-7B, or a pre-trained model fine-tuned based on a small number of manually preset prompts in a specific domain.
[0055] It can be understood that the pre-trained model is a general model trained on a large-scale dataset, with broad language understanding capabilities, usually used to learn the feature representations of general language, images, or other data, but not optimized for specific tasks. The fine-tuning model refers to further training on the basis of the pre-trained model with preference data for specific tasks to improve the performance of the pre-trained model on that specific task.
[0056] S102. According to the task description, guide the general large model to respectively output the feedback information of two prompts.
[0057] Exemplarily, the two prompts and the task description can be input into the general large model, and the general large model can be guided by the input instruction to output the feedback information of each prompt based on the feedback library.
[0058] Among them, the feedback library is a collection used to store and manage the information required for the model to generate feedback, usually including a batch (such as 10-20) of the most valuable, most worthy of attention feedback examples, evaluation information, modification opinions, etc. in the vertical domain. The initial content in the feedback library can be generated by the general large model and continuously updated during the process of prompt optimization.
[0059] It can be understood that for the task description in a certain professional field, the optimization effect of the prompt by the general large model is limited, and before the fine-tuning model is sufficiently trained, it is also impossible to directly output high-quality prompts for the task description in that professional field.
[0060] At this time, the prompts output by both the general large model and the fine-tuning model do not meet the output requirements. It is necessary to guide the general large model to optimize the prompt based on the feedback information and output the feedback information of the optimized prompt to determine again whether the optimized prompt meets the output requirements.
[0061] Therefore, if the feedback information indicates that the prompts do not meet the output requirements, then execute step S103.
[0062] S103. In response to the feedback information indicating that none of the prompting words meet the output requirements, guide the general large model to optimize the prompting words based on the feedback information, and output the feedback information of the optimized prompting words.
[0063] In one embodiment, step S103 includes:
[0064] Input two prompting words and their feedback information into the general large model, guide the general large model to optimize the two prompting words respectively, obtain two optimized prompting words, and then, according to the task description, guide the general large model to output the feedback information of the optimized prompting words based on the feedback library respectively, so as to determine whether at least one of the optimized prompting words meets the output requirements.
[0065] If the feedback information indicates that at least one prompting word meets the output requirements, step S104 can be executed: In response to the feedback information indicating that at least one prompting word meets the output requirements, output the corresponding prompting word as the target prompting word, and the target prompting word is used to replace the task description and input it into the target large language model.
[0066] If the feedback information indicates that none of the optimized prompting words meet the output requirements, step S103 is executed again. Based on this, the general large model can be used to continuously optimize the prompting words until the target prompting word that meets the output requirements is output.
[0067] In another embodiment, step S103 includes:
[0068] S1031. According to the feedback information, determine the first prompting word to be optimized from the two prompting words, and guide the general large model to optimize the first prompting word to obtain the optimized second prompting word;
[0069] S1032. According to the task description, guide the general large model to output the feedback information of the optimized second prompting word based on the feedback library.
[0070] When step S1031 is executed for the first time, the two prompting words are the initial prompting words output by the general large model and the fine-tuning model. When step S1031 is executed for the second time and above, the two prompting words are the first prompting word to be optimized and the optimized second prompting word in the previous time.
[0071] In this embodiment, in step S1031, the prompting word with higher quality and more relevant to the task description can be selected from the two prompting words according to the feedback information as the first prompting word to be optimized, and only the first prompting word is optimized to improve the efficiency of prompting word optimization.
[0072] To improve the efficiency of prompt optimization, the feedback library can also be updated based on the feedback information of the prompts before and after optimization, and the general large model can be guided to re-output the feedback information of the prompts before and after optimization based on the updated feedback library to improve the accuracy of the feedback information.
[0073] That is, in one embodiment, after step S103, it further includes:
[0074] S201. Update the feedback library according to the feedback information of the prompts before and after optimization;
[0075] S202. According to the task description, guide the general large model to output the feedback information of the prompts before and after optimization based on the updated feedback library.
[0076] In one embodiment, step S201 includes:
[0077] S2011. Guide the general large model to determine the target feedback information from the feedback information of the prompts before and after optimization;
[0078] S2022. Perform generalization extraction on the target feedback information to obtain the first generalization extraction result;
[0079] S2023. Update the feedback library based on the first generalization extraction result.
[0080] Exemplarily, the general large model includes an LLM feedbacker, an LLM optimizer, and an LLM judge 1. The LLM feedbacker is used to output the feedback information of the prompt. The LLM optimizer is used to optimize the prompt. The LLM judge 1 is used to compare the feedback information and perform generalization extraction on the most valuable feedback information as the target feedback information.
[0081] As Figure 2 shown, the general large model and the fine-tuned large model respectively output prompt 1 and prompt 2, and input the task description, prompt 1, and prompt 2 into the LLM feedbacker to obtain their feedback information.
[0082] Based on the feedback information of prompt 1 and prompt 2, it is judged whether there is a prompt that meets the output requirements. If so, the prompt that meets the output requirements is output as the target prompt. If not, a prompt to be optimized is determined from the two prompts, and it is optimized based on the LLM optimizer to obtain the optimized prompt.
[0083] Input the optimized prompt into the LLM feedbacker again to obtain the feedback information of the optimized prompt, and determine whether the optimized prompt meets the output requirements. If so, output the optimized prompt as the target prompt. If not, use the LLM judge 1 to determine the target feedback information from the feedback information of the optimized and unoptimized prompts, and perform generalization extraction on the target feedback information to obtain the first generalization extraction result to update the feedback library.
[0084] Use the LLM feedbacker to output the feedback information of the optimized and unoptimized prompts based on the updated feedback library, and determine whether there is a prompt that meets the output requirements based on the feedback information. If so, output the prompt that meets the output requirements as the target prompt. If not, select an unoptimized prompt from the optimized and unoptimized prompts and continue to optimize it using the LLM optimizer. Repeat the process of updating the feedback library and optimizing the prompt until the target prompt is output.
[0085] In this embodiment, by guiding the general large model to compare the optimized and unoptimized prompts and their feedback information, select the feedback information with the most optimal value as the target feedback information, perform generalization extraction on the target feedback information, and use the generalization extraction result to update the feedback library, so as to continuously update the feedback library according to the selected feedback information with the most optimal value during the process of optimizing the prompt, improve the accuracy of the feedback information, and further improve the efficiency of prompt optimization.
[0086] Among them, generalization extraction refers to extracting general patterns or rules from specific instances so that they can be applied to more extensive situations. Its core lies in discovering commonalities from specific data to form generalizable models or rules.
[0087] The feedback information usually includes the modification opinions and evaluation information of the corresponding prompt. The evaluation information is used to characterize the correlation degree between the corresponding prompt and the task description. Among them, the evaluation information can include evaluation content, such as evaluation words for the quality, accuracy, and relevance to the task description of the prompt, and can also include scores, which are used to comprehensively reflect the quality of the prompt.
[0088] The content such as feedback examples, evaluation information, and modification opinions required by the feedback library can be generalized and extracted from the above feedback information to update the feedback library.
[0089] After outputting the feedback information of the optimized and unoptimized prompts based on the updated feedback library, determine again whether there is at least one prompt that meets the output requirements according to the feedback information. If so, execute step S104. If not, execute step S103 again.
[0090] In the above embodiments, mainly in the case where the fine-tuning model has insufficient capabilities, the capabilities of the general large model are used as a fallback. By optimizing the prompt words and updating the feedback library, the target prompt words that meet the output requirements are obtained.
[0091] Since the general large model usually outputs prompt words based on the general prompt library, in this regard, the general prompt library can also be optimized according to the target prompt words output each time to further improve the fallback ability of the general large model.
[0092] That is, in one embodiment, after the target prompt words are output, it further includes:
[0093] S301. Generalize and extract the target prompt words to obtain a second generalization extraction result;
[0094] S302. Update the general prompt library according to the second generalization extraction result.
[0095] Exemplarily, the general large model outputs prompt words based on the general prompt library, and the general large model further includes an LLM judge 2, and the LLM judge 2 is used to generalize and extract the target prompt words.
[0096] See Figure 3 , after the target prompt words are output, use the LLM judge 2 to generalize and extract the target prompt words to obtain a second generalization extraction result to update the general prompt library.
[0097] Based on this, the quality of the initial prompt words output by the general large model according to the task description can be improved, thereby reducing the number of iterations required for the prompt words and the feedback library.
[0098] If the target prompt words that meet the output requirements still cannot be obtained after iterating the prompt words and the feedback library multiple times, in order to ensure that usable prompt words can be output and avoid long waiting times for users, the number of optimizations of the prompt words and the number of optimizations of the feedback library can be limited.
[0099] In one embodiment, after step S103, it further includes:
[0100] S401. Write the prompt words and feedback information before and after optimization into the temporary result library correspondingly;
[0101] S402. In response to the update count of the feedback library reaching the first preset count or the optimization count of the prompt words reaching the second preset count, determine the target prompt words from the temporary result library according to the feedback information and output them.
[0102] Exemplarily, see Figure 4, after each time the feedback information of the optimized prompt is output, according to the mapping relationship between the prompt and the feedback information, the original and optimized prompts and their corresponding feedback information are written into the temporary result library, or according to the mapping relationship between the task description, the prompt and the feedback information, the task description, the original and optimized prompts and their corresponding feedback information are written into the temporary result library.
[0103] When the update times of the feedback library reach the first preset number or the optimization times of the prompt reach the second preset number, the prompt most relevant to the task description can be selected as the target prompt for output according to the feedback information of each prompt in the temporary result library.
[0104] Based on the above embodiments, the present application can also construct preference data based on the data stored in the temporary result library for the fine-tuning model to train, so as to continuously improve the ability of the fine-tuning model during the process of prompt optimization, reduce the process of manual data collection and annotation, and improve the training efficiency of the fine-tuning model.
[0105] In one embodiment, after step S402, it further includes:
[0106] S501. Determine at least one highly relevant prompt and at least one lowly relevant prompt from the temporary result library according to the task description and the feedback information;
[0107] S502. Construct at least one piece of preference data and store it in the database, where the preference data includes the task description, a highly relevant prompt, and a lowly relevant prompt;
[0108] S503. In response to the preference data in the database reaching the preset quantity, train the fine-tuning model based on the preference data.
[0109] In one embodiment, the LLM judge 2 is further configured to sort the data in the temporary result library according to the feedback information and the task description to select highly relevant prompts and lowly relevant prompts.
[0110] Exemplarily, refer to Figure 5 , according to the feedback information, use the LLM judge 2 to sort the prompts in the temporary result library from high to low according to the relevance between the prompt and the task description, and select highly relevant prompts and lowly relevant prompts from the temporary result library. Based on the highly relevant prompts and lowly relevant prompts selected by the LLM judge 2, construct preference data in combination with the task description and store it in the database.
[0111] For example, after the prompts are sorted from high to low in relevance, the order of the prompts is 1-10. Combine the prompts with order 1 and order 10 into a pair, combine the prompts with order 2 and order 9 into a pair, and so on to combine multiple pairs of prompts. Each pair of prompts can be combined with the task description to construct corresponding preference data, which is then stored in the database. When the preference data in the database reaches a certain quantity, the fine-tuning model is automatically trained based on the preference data.
[0112] Based on this, each time the prompt optimization method provided in this embodiment is performed, one or more pieces of preference data can be obtained. After the preference data reaches the preset quantity, the fine-tuning model is automatically trained, which can continuously optimize the fine-tuning model and improve the ability of the fine-tuning model to output high-quality prompts for a certain professional field. Eventually, based on the task description of the professional field, the fine-tuning model can directly output high-quality prompts that meet the output requirements, improving the optimization effect and efficiency of the prompts.
[0113] For the above embodiment, considering the performance and deployment cost of the general large model, different general large models can be selected according to requirements when outputting feedback information, refining and complementing the prompts in the general prompt library, optimizing the prompts, sorting the prompts in the temporary result library, determining the target feedback information, and performing generalization extraction.
[0114] It can be understood that the larger the number of parameters, the stronger the logical reasoning and context processing ability of the general large model, and the smaller the number of parameters, the faster the output speed. Therefore, for determining the target feedback information, sorting the prompts in the temporary result library, and performing generalization extraction, a general large model with stronger performance needs to be selected to ensure the reliability of the target feedback information and the generalization extraction result. For outputting feedback information, refining and complementing the prompts in the general prompt library, and optimizing the prompts, a general large model with lower cost and fewer parameters can be selected to improve efficiency.
[0115] That is, in one embodiment, the general large model includes a first large model, such as GPT-4, and also includes a second large model, such as GPT3.5. Among them, the number of parameters of the first large model is greater than that of the second large model.
[0116] The first large model is used to determine the feedback information from the feedback information of the prompts before and after optimization, to sort the prompts in the temporary result library, and to perform generalization extraction on the target feedback information and the target prompts. The second large model is used to output prompts according to the task description, to output the feedback information of the prompts based on the feedback library, and to optimize the prompts.
[0117] It should be understood that although Figures 1-5The steps in the flowchart are shown in sequence according to the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figures 1-5 At least some of the steps in Figures 1-5 may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least some of the sub-steps or stages of other steps or other steps.
[0118] To implement the above prompt optimization method, the present application also provides a computer program product, including computer programs / instructions, which, when executed by a processor, implement the steps of the prompt optimization method in the above embodiments.
[0119] In one embodiment, this computer program product is presented as a prompt optimization system. As Figure 6 shown, the prompt optimization system includes:
[0120] A prompt generation module 601, configured to guide the pre-trained general large model and the pre-trained fine-tuning model to respectively output prompts according to the task description input to the target large language model;
[0121] A feedback module 602, configured to guide the general large model to respectively output feedback information of two prompts according to the task description;
[0122] A prompt optimization module 603, configured to, in response to the feedback information indicating that the prompts do not meet the output requirements, guide the general large model to optimize the prompts based on the feedback information and output the feedback information of the optimized prompts;
[0123] A prompt output module 604, configured to, in response to the feedback information indicating that at least one prompt meets the output requirements, output the corresponding prompt as the target prompt, and the target prompt is used to replace the task description input to the target large language model.
[0124] For the specific limitations of the prompt optimization system, reference can be made to the limitations of the prompt optimization method in the above text, which will not be elaborated here. Each module in the above prompt optimization system can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0125] The present application also provides a computer device. In one embodiment, the computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the prompt optimization method in the above embodiment are implemented.
[0126] In one embodiment, the computer device may be a server, and its internal structure diagram may be as Figure 7 shown. The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store relevant data for prompt optimization. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a prompt optimization method is implemented.
[0127] In one embodiment, the computer device may be a terminal, and its internal structure diagram may be as Figure 8 shown. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a prompt optimization method is implemented. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a button, a trackball, or a touchpad provided on the housing of the computer device, or an external keyboard, a touchpad, or a mouse, etc.
[0128] Those skilled in the art can understand that Figure 7 and Figure 8 the structures shown in are only block diagrams of some structures related to the solution of the present application, and do not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.
[0129] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the prompt optimization method in the above embodiments are implemented.
[0130] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the various embodiments provided by the present application can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0131] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.
[0132] The above embodiments only represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. A prompt optimization method, characterized in that, The prompt optimization method includes the following steps: According to the task description input to the target large language model, guide the pre-trained general large model and the pre-trained fine-tuning model to output prompts respectively; According to the task description, guide the general large model to output feedback information of the two prompts respectively; In response to the feedback information indicating that neither of the prompts meets the output requirements, guide the general large model to optimize the prompts based on the feedback information and output the feedback information of the optimized prompts; In response to the feedback information indicating that at least one of the prompts meets the output requirements, output the corresponding prompt as the target prompt, and the target prompt is used to replace the task description and input it into the target large language model.
2. The prompting word optimization method according to claim 1, wherein The general large model is used to output the feedback information based on the feedback library; After guiding the general large model to optimize the prompts based on the feedback information and output the feedback information of the optimized prompts, it further includes: Update the feedback library according to the feedback information of the prompts before and after optimization; According to the task description, guide the general large model to output the feedback information of the prompts before and after optimization based on the updated feedback library.
3. The prompting word optimization method according to claim 2, wherein After guiding the general large model to optimize the prompts based on the feedback information and output the feedback information of the optimized prompts, it further includes: Write the prompts before and after optimization and the feedback information into the temporary result library correspondingly; In response to the update times of the feedback library reaching the first preset number or the optimization times of the prompts reaching the second preset number, determine and output the target prompt from the temporary result library according to the feedback information.
4. The prompting word optimization method according to claim 3, wherein, After determining the target prompt from the temporary result library according to the feedback information, it further includes: Determine at least one highly relevant prompt and at least one lowly relevant prompt from the temporary result library according to the task description and the feedback information; Construct at least one piece of preference data and store it in the database, and the preference data includes the task description, one highly relevant prompt and one lowly relevant prompt; In response to the preference data in the database reaching the preset quantity, train the fine-tuning model based on the preference data.
5. The prompting word optimization method according to claim 2, wherein The updating the feedback library according to the feedback information of the prompts before and after optimization includes: Guide the general large model to determine the target feedback information from the feedback information of the prompts before and after optimization; Perform generalization extraction on the target feedback information to obtain the first generalization extraction result; Update the feedback library based on the first generalization extraction result.
6. The prompting word optimization method according to claim 1, wherein The general large model is used to output the prompts based on the general prompt library; After outputting the target prompt, it further includes: Perform generalization extraction on the target prompt to obtain the second generalization extraction result; Update the general prompt library according to the second generalization extraction result.
7. The prompting word optimization method according to claim 1, wherein, The feedback information includes modification opinions and evaluation information corresponding to the prompt words, and the evaluation information is used to characterize the degree of relevance between the corresponding prompt words and the task description.
8. A computer program product, comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1-7 are implemented.
9. A computer device, comprising a memory, a processor, and a computer program stored on the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-7.
10. A computer-readable storage medium having computer programs / instructions stored thereon, characterized in that, When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1-7 are implemented.
Citation Information
Cited By
Network protocol intelligent extraction method based on large language model and application
CN120725152A
A network protocol intelligent extraction method based on a large language model and application thereof
CN120725152B
Large model application optimization method and device based on user feedback, equipment and medium
CN120806172A