Prompt word optimization method, intelligent agent and storage medium

By constructing and optimizing prompt word instances and setting tags based on the output results of the big model, the problem of insufficient adaptability of prompt word templates is solved, and efficient operation and high-performance output of the agent in multi-model and multi-task scenarios is achieved.

CN120278153AActive Publication Date: 2025-07-08BEIJING LANZHOU TECH CO LTD

Patent Information

Application Number
CN202510754281.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-06
Publication Date
2025-07-08
Estimated Expiration
2045-06-06

AI Technical Summary

Technical Problem

Under the existing agent framework, the prompt word template cannot be dynamically adapted according to different large model characteristics or task types, resulting in adaptability problems and affecting the operation efficiency and performance of the agent in multi-model and multi-task scenarios.

Method used

By constructing multiple prompt word instances, setting tags based on the output results of the target big model, iterative optimization and evaluation are performed, and adaptive tag prompt word templates are generated. Combining the closed-loop execution process and template formatting process of Thought-Action-Observation, ensuring the standardization and applicability of the prompt word template.

Benefits of technology

The quick and accurate matching of prompt word templates is achieved, which improves the operation efficiency and accuracy of the agent in different task types and large model dynamic scenarios, avoids the compatibility of fixed templates, and improves the generalization ability and task execution effect of the agent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120278153A_ABST
    Figure CN120278153A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, in particular to a cue word optimization method, an intelligent agent and a storage medium. According to the cue word optimization method provided by the invention, a plurality of cue word templates are generated, different cue word templates and different task sample combinations are input into different models, and through continuous evaluation and feedback optimization, a first cue word template adaptive to each task and model type is finally screened out; and setting a first label representing a corresponding task type and a second label representing a corresponding model type for each first cue word template to obtain a label cue word template and storing the label cue word template, so that searching in a task dimension and a model dimension is facilitated, rapid and accurate matching of the cue word templates can be realized, the adaptability of the cue word templates is improved, and the user experience is improved. Efficient operation of the intelligent agent in dynamic scenes of different tasks and models is supported, so that the intelligent agent can adapt to the cue word template with the most appropriate task and model type, and the generalization ability and execution effect of the intelligent agent in a multi-task scene and a multi-model are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of artificial intelligence, and particularly relates to a method for optimizing prompt words, an agent, and a storage medium. Background Art

[0002] In recent years, the technology of constructing agents based on large language models (LLMs) has developed rapidly. An agent refers to a system that can perceive the environment, make decisions, and execute actions. In many cases, especially when dealing with complex or multimodal tasks, an agent often calls multiple large models to improve performance and functional diversity, and the output of the large model depends on the guidance of the prompt word template. However, under the existing agent framework, the prompt word template is usually fixed. When the agent calls different large models to process different types of tasks, the prompt word template cannot be dynamically adapted according to the characteristics of different large models or task types, resulting in an adaptability problem. Summary of the Invention

[0003] To solve the above problems, the present invention provides a method for optimizing prompt words, an agent, and a storage medium.

[0004] The present invention provides the following technical solutions to solve the above technical problems: A method for optimizing prompt words, comprising the following steps: obtaining a prompt word template data set and a task sample data set, wherein the prompt word template data set includes a plurality of different prompt word templates, and the task sample data set includes task samples of a plurality of different task types; constructing a plurality of different prompt word instances based on each of the prompt word templates and each of the task samples, and inputting each of the prompt word instances into a plurality of target large models; constructing a first prompt word template set by a preset method based on the output results of the target large models, wherein the first prompt word template set includes a plurality of first prompt word templates; Setting a first label and a second label for the first prompt word template to obtain a labeled prompt word template, wherein the first label represents the task type of the task sample corresponding to the first prompt word template; the second label represents the type of the target large model corresponding to the input of the first prompt word template.

[0005] Preferably, constructing a first set of prompt templates based on the output result of the target large model by a preset method includes the following steps: evaluating the output result corresponding to the prompt template to obtain an evaluation result; performing an iterative operation on the prompt template based on the evaluation result to obtain an evaluation result of a new round of prompt templates; based on the evaluation result of the new round of prompt templates, determining whether the new round of prompt templates meets the preset conditions. If so, adding the new round of prompt templates to the first set of prompt templates; if not, repeating the iterative operation on the new round of prompt templates.

[0006] Preferably, the evaluating the output result corresponding to the prompt template includes the following steps: scoring the output result corresponding to the prompt template at the structural level and / or the content level; wherein, the scoring at the structural level includes scoring based on the output format accuracy of the output result; the scoring at the content level includes scoring based on the task completion accuracy of the output result.

[0007] Preferably, the performing an iterative operation on the prompt template based on the evaluation result to obtain an evaluation result of a new round of prompt templates includes the following steps: feeding back the evaluation result to the large model for generating prompt templates, and the large model for generating prompt templates generates a new round of prompt templates based on the evaluation result; constructing a new round of prompt instances with the new round of prompt templates and the corresponding task samples, and inputting the new round of prompt instances into the target large model; evaluating the output result of the target large model to obtain the evaluation result of the new round.

[0008] Preferably, the multiple different prompt templates are generated by a large model, and the large model generating the multiple different prompt templates includes the following steps: rewriting and optimizing the existing prompt templates based on the large model to obtain the multiple different prompt templates; and / or, inputting a generation instruction into the large model, and the large model generates the prompt template based on the generation instruction.

[0009] Preferably, the large model includes a large model for generating prompt templates; and / or, the large model includes a target large model, and the prompt templates generated by the target large model are used for inputting into the target large model.

[0010] Preferably, each of the prompt templates is subjected to template formatting before being input into the target large model; and / or, after the prompt instance is input into the target large model, the target large model adopts a Thought-Action-Observation closed-loop execution process; and / or, all-link data of the target large model running after the prompt instance is input is collected, and the all-link data is structurally stored, where the output result includes the structurally stored all-link data.

[0011] To solve the above technical problems, the present invention provides another technical solution as follows: The intelligent agent includes the following modules: an input module for receiving input information, where the input information is generated based on the labeled prompt template obtained by any one of the above-mentioned prompt optimization methods; a processing module for processing the input information received by the input module to obtain output information; and an output module for outputting the output information of the processing module.

[0012] Preferably, the generation of the input information includes the following steps: obtaining user task request information; determining the task type corresponding to the user task request information and identifying the large model type called by the intelligent agent for the user task request information; retrieving candidate prompt templates from the dataset of the labeled prompt templates based on the task type and the large model type; where the first label corresponding to the candidate prompt template is the same as the task type corresponding to the user task request information, and the second label corresponding to the candidate prompt template is the same as the large model type called by the user task request information; and obtaining the input information based on the user task request information and the candidate prompt template.

[0013] To solve the above technical problems, the present invention provides another technical solution as follows: A computer-readable storage medium, when the computer program is executed, implements the prompt optimization method described in any one of the above.

[0014] Compared with the prior art, a prompt optimization method, an intelligent agent, and a storage medium provided by the present invention have the following beneficial effects: 1. In the embodiment of the present invention, a method for optimizing prompt words is provided. By constructing multiple different prompt word instances based on multiple different prompt word templates and task samples of multiple different task types, and inputting each prompt word instance into multiple target large models respectively, a sufficient number of prompt word instances can be generated, avoiding the limitation of the optimization result caused by insufficient data diversity, and providing a guarantee for the base number for subsequent screening of label prompt word templates adapted to each target large model and each task type. Based on the output results of the target large model, multiple first prompt word templates obtained by a preset method have better performance. By setting a first label and a second label for the first prompt word template, a label prompt word template is obtained, where the first label represents the task type of the task sample corresponding to the first prompt word template; the second label represents the type of the target large model corresponding to the input of the first prompt word template. The double labels of the first label and the second label realize the structuring and standardization of the output result of the prompt word optimization method, laying a foundation for providing a two-dimensional indexing mechanism for the task type and the large model type, enabling the most matching prompt word template to be retrieved more conveniently and quickly through the double labels of the task type and the large model type, helping to achieve the fast and accurate matching of the prompt word template, and supporting the efficient operation of the intelligent agent in different task types and different large model dynamic scenarios. Since each label prompt word template corresponds to an adapted task type and target large model type respectively, compared with the fixed prompt word template written under the existing intelligent agent framework, the prompt word optimization method of the present invention enables different task types and target large model types to each correspond to a relatively adapted label prompt word template, thus avoiding compatibility problems caused by the mismatch between the fixed prompt word template and the large model type or task type.

[0015] 2. In the embodiment of the present invention, through the closed-loop process of evaluating, iterating, re-evaluating, and re-iterating the output result of the prompt word template in a cycle, the prompt word template can be continuously optimized. The evaluation link provides a clear guidance for iteration. By making targeted improvements based on the evaluation results, the first prompt word templates that meet the preset conditions are gradually screened out. Compared with single optimization, the quality and applicability of the prompt word template are greatly improved. Based on the preset conditions, it is judged whether to stop iteration, etc., to avoid wasting computing resources and balance the optimization effect and efficiency. Through the feedback-driven optimization mechanism, a prompt word template with excellent performance that matches the target large model and the task instruction type is finally obtained.

[0016] 3. In the embodiments of the present invention, scoring from the structural level can ensure the format standardization of the output results of the prompt template. When scoring based on the output format accuracy at the structural level, it ensures that the model output conforms to the expected structure, facilitating the parsing of the target large model; scoring from the content level can ensure the effectiveness of task completion. When scoring based on the task completion accuracy at the content level, it can ensure that the prompt template truly and accurately helps the target large model complete the task, improving the accuracy of task execution. Through the combination of scoring at the structural level and the content level, multi-dimensional evaluation is achieved, which can more accurately locate the types of problems existing in the prompt template, such as unreasonable structure or inaccurate content, thus providing a clear direction for subsequent iterative optimization and improving the iterative optimization efficiency.

[0017] 4. In the iterative process of the embodiments of the present invention, by feeding back the evaluation results, generating a new round of prompt templates, and testing again to obtain the evaluation results, a closed-loop optimization is formed. It no longer relies on manual adjustment of the prompt template, but discovers and fixes the problems existing in the interaction between the prompt template and the target large model through the actual output feedback of the target large model, such as the preference of the target large model for specific sentence patterns and the misjudgment tendency for vague instructions. According to the feedback evaluation results, the effect of the prompt template is enhanced directionally. Through the cumulative effect of multiple rounds of iteration, the quality of the prompt template is gradually improved, ensuring the adaptability and task completion degree of the specific prompt template on the target large model, and finally obtaining the first set of prompt templates that perform excellently on the target large model.

[0018] 5. In the embodiments of the present invention, by adopting the method of rewriting and optimizing the existing prompt template, improvements are made on the basis of the mature prompt template, thereby expanding and generating more variants of prompt templates with different styles and strategies; and by inputting the generation instruction into the large model, the large model generates the prompt template based on the generation instruction, which can make full use of the generation ability of the large model to achieve new creation according to the requirements. The generation instruction can include the structure output instruction, and in combination with context information such as scene description and task type, it guides the large model to generate a new prompt template that conforms to the specification, ensuring from the source that the prompt is applicable to specific task and framework requirements. The two prompt template generation methods can be flexibly selected or combined, which can generate high-quality prompt templates according to different task characteristics and optimization goals, improve the pertinence and effectiveness of prompt template generation, and at the same time enrich the sources and diversity of prompt templates.

[0019] 6. The prompt template generation large model in the embodiments of the present invention, such as large models like DeepSeek-V3, usually has stronger general generation capabilities and cross-domain migration capabilities, which can improve the flexibility of prompt template generation; while using the target large model for generating prompts can avoid the errors caused by cross-model migration, optimize the prompt templates according to the distribution of its own training data, and the generated prompt templates are also more in line with the parsing standards of its own large model, thereby improving the stability of prompt template generation. The prompt template generation large model and the target large model for generating prompt templates can be flexibly selected or combined for use, which can not only improve the diversity of prompt template generation, solve the problem of limited adaptability of fixed template tasks, but also ensure the stable execution of diverse prompt templates on the target large model. The generated prompt templates have both stability, flexibility and diversity, so as to better meet the complex requirements of multi-model and multi-task of the intelligent agent.

[0020] 7. Each prompt template in the embodiments of the present invention undergoes template formatting processing before being input into the target large model. After the prompt instance is input into the target large model, the target large model adopts the Thought-Action-Observation (TAO) closed-loop execution process, and collects all-link data during the operation of the target large model after the prompt instance is input, and performs structured storage on the all-link data. All of these are to make the entire prompt optimization process meet the principle of single variable, taking the difference of the prompt template as the only variable and avoiding the interference of irrelevant variables. Different prompt templates may have inconsistent formats, such as differences in JSON structures and different natural language expression styles. These non-content differences may lead to deviations in the output results of the target large model, such as format parsing errors and instruction understanding ambiguities. Through template formatting processing, all prompt templates are unified into a preset format, such as filling placeholders, aligning structure requirements, embedding task content, etc., to ensure that the only variable input into the target large model is the difference in the content of the prompt template rather than the format, so as to accurately screen out the first prompt template in subsequent evaluations. In addition, different target large models may have different built-in execution processes. For example, some large models directly generate results, while some large models need to call tools step by step. If the large model execution process and the output results are different, the differences may stem from the model execution logic. By forcibly adopting the Thought-Action-Observation (TAO) closed-loop process, that is, the standardized steps of thinking-action-observation feedback, the model execution process is fixed as a constant to ensure that all large models follow the same reasoning framework when processing prompts. By collecting all-link data, such as including the input template content, formatted parameters, operation records of each step in the TAO process, and the final output results, and performing structured storage, all variables during the operation of the large model are quantitatively recorded, avoiding variable confusion caused by data loss. Finally, it is ensured that each optimization only changes the content of the prompt template, while other factors that may affect the results, such as format, process, and data recording method, are fixed or standardized, ensuring that the improvement in the effect of the first prompt template is due to the optimization of the prompt template itself rather than the interference of irrelevant variables, so as to select the first prompt template that is precisely adapted.

[0021] 8. The embodiments of the present invention also provide an agent, and the agent has the same beneficial effects as the above-mentioned prompt optimization method, which will not be elaborated here.

[0022] 9. In the embodiments of the present invention, by obtaining user task request information, judging the task type and identifying the type of large model called, it is possible to accurately retrieve the candidate prompt template that best matches the task type and large model type from the label prompt template dataset, dynamically realizing that the selected candidate prompt template is highly adapted to the user task and the called model, forming a dual adaptability for the task type and large model type, being able to achieve fast and accurate matching of the prompt template, improving the accuracy and effectiveness of the large model response, avoiding the inability to fully utilize the performance of the large model due to insufficient adaptability of the prompt template to the large model or task type, and being able to output high-quality results that meet the specific task requirements of the user with the most matching prompt template, significantly enhancing the generalization ability and execution effect of the intelligent agent in multi-model and multi-task scenarios, contributing to the construction of an intelligent agent with a higher intelligent level, and effectively supporting the efficient operation of the intelligent agent in dynamic multi-model and multi-task scenarios.

[0023] 10. The embodiments of the present invention also provide a storage medium, which has the same beneficial effects as the above-mentioned prompt optimization method and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0025] Figure 1 It is a flowchart of the steps of a prompt optimization method provided by the first embodiment of the present invention.

[0026] Figure 2 It is a flowchart of the steps of step S3 of a prompt optimization method provided by the first embodiment of the present invention.

[0027] Figure 3 It is a flowchart of the steps of step S32 of a prompt optimization method provided by the first embodiment of the present invention.

[0028] Figure 4 It is a structural block diagram of an intelligent agent provided by the second embodiment of the present invention.

[0029] Figure 5 It is a flowchart of the steps for generating input information of the intelligent agent provided by the second embodiment of the present invention.

[0030] DESCRIPTION OF THE REFERENCE NUMERALS 100. Intelligent agent; 1. Input module; 2. Processing module; 3. Output module. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0031] In order to make the objectives, technical solutions and advantages of the present invention more clear and understandable, the present invention 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 invention and are not used to limit the present invention.

[0032] Please refer to Figure 1 , a prompting word optimization method is provided in the first embodiment of the present invention, including the following steps: Step S1, obtaining a prompting word template data set and a task sample data set, wherein the prompting word template data set includes a plurality of different prompting word templates, and the task sample data set includes task samples of a plurality of different task types; It should be noted that a prompting word template is a structured framework that can include fixed instructions and placeholders for dynamically generating specific prompts. For example: "Please translate the following {source language} text into {target language}: {text}." In the above prompting word template, {source language}, {target language}, and {text} are placeholders, and the rest are fixed instructions. A task sample can be a specific task instance or example, including input data or a reference to the expected output. For example: "Please translate the sentence 'The weather is really nice today' from Chinese into English." Step S2, constructing a plurality of different prompting word instances based on each prompting word template and each task sample, and inputting each prompting word instance into a plurality of target large models respectively; It should be noted that constructing a plurality of different prompting word instances based on each prompting word template and each task sample means combining each prompting word template with each task sample to form a specific prompting word instance with a complete context, that is, a complete prompting word. For example: The prompting word template is selected as "Please translate the following {source language} text into {target language}: {text}.", and the task sample is selected as "Please translate the sentence 'The weather is really nice today' from Chinese into English.", thus combining to form the prompting word instance "Please translate the following Chinese text into English: The weather is really nice today." in order to convert the task sample into a standardized prompting word instance using the fixed structure of the prompting word template, which is convenient for the parsing of the target large model and is beneficial to improving the quality of the output result of the target large model.

[0033] It should be noted that a large model refers to an artificial intelligence model trained with a vast amount of data and having a huge parameter scale. An agent refers to a system that can perceive the environment, make decisions, and execute actions. Since different large models may have their own advantages in different task domains, a single large model may not be able to meet the complex and diverse task requirements. Agents often integrate multiple large models. In many cases, especially when dealing with complex or multimodal tasks, agents often call multiple large models to improve performance and functional diversity. Multiple target large models refer to different large models for inputting prompt instance, which can be multiple different large models integrated by the agent. Inputting each prompt instance into these target large models aims to subsequently screen out the prompt template that is most suitable for each target large model.

[0034] Specifically, for ease of understanding, the following is an example: Each prompt template includes a, b, and c; each task sample includes 1, 2, and 3; each target large model includes model α, model β, and model γ; then input each prompt instance a1, a2, a3, b1, b2, b3, c1, c2, and c3 constructed by each prompt template and each task sample into model α, and input into model β and input into model γ.

[0035] Step S3, based on the output results of the target large models, construct a first set of prompt templates in a preset method, where the first set of prompt templates includes multiple first prompt templates; It should be noted that the first prompt template refers to a prompt template with excellent performance finally screened out based on a preset method. Optionally, the preset method can be screening based on evaluation metrics, screening through controlled variable comparison experiments, screening based on effect feedback, and multiple rounds of iteration on this basis to screen out the first prompt template.

[0036] Step S4, set a first label and a second label for the first prompt template to obtain a labeled prompt template, where the first label represents the task type of the task sample corresponding to the first prompt template; the second label represents the type of the target large model corresponding to the input of the first prompt template.

[0037] It should be noted that when a certain prompt template and a certain task sample are combined and input into a certain target large model, and finally this prompt template is selected as the first prompt template, the first label represents the task type of the task sample, and the second label represents the target large model, which is exactly the target large model into which this prompt template is input to obtain the screening result of the first prompt template this time. Setting the first label and the second label for the first prompt template to obtain the labeled prompt template means that the labeled prompt template corresponds to specific first and second labels, and this corresponding information can be stored in a structured database to support finding the matching labeled prompt template according to the task type dimension and the large model type dimension. This labeled prompt template has better performance when inputting the task type corresponding to the first label and the large model corresponding to the second label.

[0038] It can be understood that by constructing multiple different prompt instances based on multiple different prompt templates and task samples of multiple different task types, and inputting each prompt instance into multiple target large models respectively, a sufficient number of prompt instances can be generated, avoiding the limitation of the optimization result caused by insufficient data diversity, and providing a guarantee for the base number for subsequent screening of the labeled prompt templates adapted to each target large model and each task type. The multiple first prompt templates obtained by a preset method based on the output results of the target large model have better performance. Setting the first label and the second label for the first prompt template to obtain the labeled prompt template, where the first label represents the task type of the task sample corresponding to the first prompt template; the second label represents the type of the target large model corresponding to the input of the first prompt template. The dual labels of the first label and the second label realize the structuring and standardization of the output result of the prompt optimization method, laying a foundation for providing a two-dimensional indexing mechanism for the task type and the large model type, enabling the most matching prompt template to be retrieved more conveniently and quickly through the dual labels of the task type and the large model type, helping to achieve the fast and accurate matching of the prompt template, and fully supporting the efficient operation of the intelligent agent in the dynamic scenarios of different task types and different large models. Since each labeled prompt template corresponds to an adapted task type and target large model type respectively, compared with the fixed prompt templates written under the existing intelligent agent framework, the prompt optimization method of the present invention enables different task types and target large model types to each correspond to a relatively adapted labeled prompt template, thus avoiding compatibility problems caused by the mismatch between the fixed prompt template and the large model type or task type.

[0039] It should be noted that the prompt templates under the existing agent framework are fixedly written. An agent often integrates multiple large models. In many cases, especially when dealing with complex or multimodal tasks, the agent often calls multiple large models to improve performance and functional diversity. The singularity of such prompt templates seriously mismatches with the diversity of large models and task types, which will lead to insufficient adaptability of large models and limited task adaptability: different large models have significant differences in the response effects to the same prompt template. Some large models may perform well when using a certain fixed template, while other large models may have poor responses. The fixed prompt template cannot fully utilize the performance characteristics of each large model, which is not conducive to building a general agent framework with the adaptive ability of large models. In addition, different types of tasks have different requirements for prompt templates. Using a fixed prompt template to handle all task scenarios may lead to a decline in generalization ability. For example, a certain prompt template performs well in writing tasks but may not be effective in programming tasks. Therefore, it is difficult for a prompt template lacking task type awareness and dynamic adjustment ability to cover diverse application requirements. The first label and the second label corresponding to each label prompt template formed by the prompt optimization method of the present invention contribute to achieving the fast and accurate adaptation of the prompt template, and can effectively support the efficient operation of the agent in different task types and different large model dynamic scenarios.

[0040] Optionally, the recognition of the task type can be to construct a lightweight task classifier based on a large model. The classifier identifies the task type to which the input task sample content belongs. Among them, the task type can include general question answering, code generation, logical reasoning, writing creation, information extraction, etc., and other task types are not limited here.

[0041] Please refer to Figure 2 , further, step S3 constructs a first set of prompt templates based on the output result of the target large model by a preset method, including the following steps: Step S31, evaluate the output result corresponding to the prompt template to obtain an evaluation result; Step S32, perform an iterative operation on the prompt template based on the evaluation result to obtain an evaluation result of a new round of prompt templates; Step S33, based on the evaluation result of the new round of prompt templates, determine whether the new round of prompt templates meet the preset conditions. If so, add the new round of prompt templates to the first set of prompt templates; if not, repeat the iterative operation on the new round of prompt templates.

[0042] Understandably, the output result corresponding to the prompt template is evaluated to obtain an evaluation result, and based on the evaluation result, an iterative operation is performed on the prompt template to obtain the evaluation result of the new round of prompt template. The above steps mean that after the prompt template and the task sample are combined and input into the target large model, the target large model outputs the result corresponding to the prompt template, evaluates the output result, and performs an iterative operation on the prompt template based on the evaluation result. The significance of the evaluation and iterative operations lies in continuously optimizing the prompt template through a closed-loop process of evaluating, iterating, re-evaluating, and re-iterating the output result of the prompt template. The evaluation link provides a clear guidance for the iterative operation, and the iterative operation makes targeted improvements based on the evaluation result, gradually screening out the first prompt template that meets the preset conditions. Compared with single optimization, it greatly improves the quality and applicability of the prompt template. Based on the preset conditions, it avoids wasting computing resources and balances the optimization effect and efficiency. Through the feedback-driven optimization mechanism, a prompt template with excellent performance that matches the target large model and the task instruction type is finally obtained.

[0043] Optionally, the preset conditions can use the change range of the output result evaluation score, the accuracy threshold, the upper limit of the number of iterations, etc. to determine whether to stop the iteration.

[0044] Furthermore, evaluating the output result corresponding to the prompt template includes the following steps: Score the output result corresponding to the prompt template at the structural level and / or the content level; Among them, the scoring at the structural level includes scoring based on the output format accuracy of the output result; the scoring at the content level includes scoring based on the task completion accuracy of the output result.

[0045] Understandably, scoring from the structural level can ensure the format standardization of the output result of the prompt template. When scoring based on the output format accuracy at the structural level, it ensures that the model output conforms to the expected structure, facilitating the parsing of the target large model; scoring from the content level can ensure the effectiveness of task completion. When scoring based on the task completion accuracy at the content level, it can ensure that the prompt template truly and accurately helps the target large model complete the task and improves the accuracy of task execution. Through the combination of scoring at the structural level and the content level, multi-dimensional evaluation is achieved, and the specific types of problems existing in the prompt template can be more accurately located, whether it is an unreasonable structure or inaccurate content, thus providing a clear direction for the optimization of subsequent iterative operations and improving the optimization efficiency of iterative operations.

[0046] Optionally, as a specific implementation, evaluating the output result corresponding to the prompt template includes scoring the output result corresponding to the prompt template at the structural level and the content level; as another specific implementation, evaluating the output result corresponding to the prompt template only includes scoring the output result corresponding to the prompt template at the structural level; as another specific implementation, evaluating the output result corresponding to the prompt template only includes scoring the output result corresponding to the prompt template at the content level.

[0047] Optionally, scoring based on the output format accuracy of the output result includes determining whether the output result of the target large model conforms to the preset structure. For example, the preset structure needs to strictly follow the structure specification of Thought-Action-Observation. The output format accuracy can be detected by means such as rule matching and regular expressions. It should be noted that the Thought, Action, and Observation structure specifications of the large model are the core frameworks for the large model to make autonomous decisions and interact with the environment. Its core idea is to improve the reasoning ability and interpretability of the large model in complex tasks by simulating the human thinking-action-feedback cycle. Thought (thinking) refers to the internal reasoning process of the large model for the current task, manifested as intermediate steps or logical chains described in natural language. Action (action) refers to the specific operations generated by the large model based on Thought, including calling external tools, APIs, or performing internal calculations. Observation (observation) refers to the result or environmental feedback returned after the execution of Action, used to adjust subsequent decisions.

[0048] Optionally, scoring based on the task completion accuracy of the output result includes evaluating the correctness and effectiveness of the output content when the target large model completes specific example instances. For example, whether the question and answer are correct, whether the code is executable, and whether the reasoning process is rigorous. The task completion accuracy can be evaluated by means such as matching degree and execution verification in combination with manually labeled data and reference answers.

[0049] Please refer to Figure 3 , further, step S32 performs an iterative operation on the prompt template based on the evaluation result to obtain a new round of evaluation results of the prompt template, including the following steps: Step S321, feedback the evaluation result to the large model for generating the prompt template. The large model for generating the prompt template generates a new round of prompt templates based on the evaluation result; Step S322, construct a new round of prompt instances with the new round of prompt templates and the corresponding task samples, and input the new round of prompt instances into the target large model; Step S323, evaluate the output result of the target large model to obtain a new round of evaluation results.

[0050] Understandably, the large model for generating prompt templates refers to a large model specifically used for generating prompt templates. The task samples corresponding to the new round of prompt templates are the same as those corresponding to the previous round of prompt templates, ensuring that only the variables are different for each round of prompt templates, while the task samples combined with the prompt templates remain unchanged. The iterative process forms a closed-loop optimization by feeding back the evaluation results, generating a new round of prompt templates, and testing again to obtain the evaluation results. It no longer relies on manual adjustment of prompt templates based on experience, but discovers and fixes problems existing in the interaction between the prompt templates and the target large model through the actual output feedback of the target large model, such as the preference of the target large model for specific sentence patterns and the misjudgment tendency for vague instructions. According to the feedback evaluation results, the effect of the prompt templates is enhanced directionally. Through the cumulative effect of multiple rounds of iteration, the quality of the prompt templates is gradually improved, ensuring the adaptability and task completion degree of specific prompt templates on the target large model, and finally obtaining the first set of prompt templates that perform excellently on the target large model.

[0051] Optionally, based on the evaluation results, the large model for generating prompt templates generates a new round of prompt templates, which can be to adjust the prompt template generation strategy according to the feedback of the evaluation results, and semantic enhancement, structure adjustment, local rewriting, etc. can be adopted to generate a new round of prompt templates with better performance.

[0052] Furthermore, multiple different prompt templates are generated by the large model. The steps for the large model to generate multiple different prompt templates include: Rewriting and optimizing the existing prompt templates based on the large model to obtain multiple different prompt templates; And / or, inputting the generation instruction into the large model, and the large model generates prompt templates based on the generation instruction.

[0053] Understandably, by adopting the method of rewriting and optimizing the existing prompt templates, it is possible to improve on the basis of mature prompt templates, thereby expanding and generating more variants of prompt templates with different styles and strategies; while by inputting the generation instruction into the large model and the large model generating prompt templates based on the generation instruction, the generation ability of the large model can be fully utilized to achieve new creations according to requirements. Optionally, the generation instruction can include a structure output instruction, and combined with context information such as scene description and task type, it can guide the large model to generate new prompt templates that meet the specifications, ensuring from the source that the prompt words are applicable to specific task and framework requirements. The two prompt template generation methods can be flexibly selected or combined, and can generate high-quality prompt templates according to different task characteristics and optimization goals, improving the pertinence and effectiveness of prompt template generation, and at the same time enriching the sources and diversity of prompt templates.

[0054] Optionally, as a specific implementation, the large model generates multiple different prompt templates, including: obtaining multiple different prompt templates by rewriting and optimizing the existing prompt templates based on the large model, and inputting the generation instruction into the large model, and the large model generates prompt templates based on the generation instruction. As another specific implementation, the large model generating multiple different prompt templates only includes: obtaining multiple different prompt templates by rewriting and optimizing the existing prompt templates based on the large model. As another specific implementation, the large model generating multiple different prompt templates only includes: inputting the generation instruction into the large model, and the large model generates prompt templates based on the generation instruction.

[0055] Optionally, the existing prompt templates can be pre-designed prompt templates based on expert experience. These prompt templates can include the chain of thought and the one-step instruction structure. By performing optimization operations such as expanding, restructuring, and replacing words on the existing prompt templates through the large model, multiple different prompt templates are generated.

[0056] Optionally, inputting the generation instruction into the large model, and the large model generates prompt templates based on the generation instruction can be to input a clear output structure instruction into the large model. For example, the output result needs to include the structural specification of Thought-Action-Observation, and combined with context information such as scene description and task type, guide the large model to generate prompt templates that meet the specifications, ensuring from the source that the prompt templates are applicable to specific tasks and framework requirements. Furthermore, the large model includes a prompt template generation large model; And / or, the large model includes a target large model, and the prompt templates generated by the target large model are used to be input into the target large model.

[0057] It can be understood that the prompt template generation large model usually has stronger general generation ability and cross-domain transfer ability, which can improve the flexibility of prompt template generation; while using the target large model as the large model for generating prompt templates can avoid the errors caused by cross-model transfer, optimize the prompt templates according to the training data distribution of itself, and the generated prompt templates are also more in line with the parsing standards of its own large model, thus improving the stability of prompt template generation. The prompt template generation large model and the target large model for generating prompt templates can be flexibly selected or combined for use, which can improve the diversity of prompt template generation, solve the problem of limited adaptability of fixed template tasks, and also ensure the stable execution of diverse prompt templates on the target large model. The generated prompt templates have stability, flexibility, and diversity, thus better meeting the complex needs of the intelligent agent for multiple models and multiple tasks.

[0058] Optionally, as a specific implementation, the large model includes a prompt template generation large model and a target large model. The prompt template generated by the target large model is used as input to the target large model. As another specific implementation, the large model only includes the prompt template generation large model. As another specific implementation, the large model only includes the target large model, and the prompt template generated by the target large model is used as input to the target large model.

[0059] Optionally, the prompt template generation large model can be a large model with excellent performance such as Deep Seek V3, GPT-4, Claude 3, etc.

[0060] Furthermore, each prompt template undergoes template formatting processing before being input into the target large model.

[0061] It can be understood that different prompt templates may have inconsistent formats, such as differences in JSON structures and different natural language expression styles. These non-content differences may lead to deviations in the output results of the target large model, such as format parsing errors and instruction understanding ambiguities. Through template formatting processing, all prompt templates are unified into a preset format, such as filling placeholders, aligning structure requirements, embedding task content, etc., to ensure that the only variable input into the target large model is the different content of the prompt template rather than the format, so as to accurately screen out the first prompt template in subsequent evaluations.

[0062] Optionally, the template formatting processing includes filling placeholders, aligning structure requirements, embedding task content, etc., to ensure that the input to the large model is legal and valid.

[0063] Furthermore, after the prompt instance is input into the target large model, the target large model adopts the Thought-Action-Observation closed-loop execution process.

[0064] It can be understood that different target large models may have different built-in execution processes. For example, some large models directly generate results, and some large models need to call tools step by step. If the large model execution process, the differences in output results may stem from the model execution logic. By forcibly adopting the Thought-Action-Observation (TAO) closed-loop process, that is, the standardized steps of thinking-action-observation feedback, the model execution process is fixed as a constant, ensuring that all large models follow the same reasoning framework when processing prompts, only taking the differences in prompt templates as the only variable, avoiding the interference of irrelevant variables, and ensuring the consistency and comparability of evaluations. The Thought-Action-Observation (TAO) closed-loop refers to the closed-loop iteration of thinking-action-observation to achieve complex task solving. The content of Thought, Action, and Observation has been introduced above and will not be elaborated here.

[0065] Furthermore, collect the full-link data of the target large model running after the input of the prompt instance, and perform structured storage on the full-link data. The output result includes the full-link data stored in a structured manner.

[0066] Understandably, by collecting the full-link data and performing structured storage, all variables in the operation of the large model are quantitatively recorded, avoiding variable confusion caused by data loss.

[0067] It should be noted that the full-link data refers to the data generated in each step of the target large model running after the input of the prompt instance. Optionally, the full-link data includes the input template content, formatted parameters, operation records of each step in the TAO process, the final output result, etc., and may also include intermediate calls during the operation (such as external tool calls), large model response time, number of output tokens, and other operation meta-information. The full-link data is stored in a structured manner as the basis for subsequent evaluation scoring, error analysis, and optimization adjustment. Optionally, the full-link data can be stored in structured storage methods such as JSON, XML, CSV, etc.

[0068] Understandably, the template formatting process performed on each prompt template before inputting into the target large model, after the prompt instance is input into the target large model, the target large model adopts the Thought-Action-Observation (TAO) closed-loop execution process, and collecting the full-link data of the target large model running after the input of the prompt instance and performing structured storage on the full-link data are all to make the entire prompt optimization process satisfy the single variable principle, taking the difference of the prompt templates as the only variable and avoiding the interference of irrelevant variables. Finally, it is ensured that only the content of the prompt template is changed each time for optimization, while other factors that may affect the result, such as format, process, and data recording method, are fixed or standardized, ensuring that the improvement of the effect of the first prompt template is due to the optimization of the prompt template itself rather than the interference of irrelevant variables, so as to select the first prompt template that is precisely adapted.

[0069] Please refer to Figure 4 , the second embodiment of the present invention provides an agent 100, and the agent 100 includes the following modules: Input module 1, which is used to receive input information, and the input information is generated based on the labeled prompt template obtained by the prompt optimization method in the first embodiment of the present invention; Processing module 2, which is used to process the input information received by the input module 1 to obtain output information; Output module 3, which is used to output the output information of the processing module 2.

[0070] Understandably, when generating input information based on the label prompt word template obtained by the prompt word optimization method in the first embodiment of the present invention, the intelligent agent 100 has the same beneficial effects as the prompt word optimization method in the first embodiment of the present invention, which will not be elaborated here.

[0071] Please refer to Figure 5 , further, the generation of the input information includes the following steps: Step S51, obtain the user task request information; Step S52, determine the task type corresponding to the user task request information, and identify the large model type called by the intelligent agent 100 for the user task request information; Step S53, based on the task type and the large model type, retrieve a candidate prompt word template from the dataset of the label prompt word template; wherein, the first label corresponding to the candidate prompt word template is the same as the task type corresponding to the user task request information, and the second label corresponding to the candidate prompt word template is the same as the large model type called by the user task request information; Step S54, obtain the input information based on the user task request information and the candidate prompt word template.

[0072] Understandably, by obtaining the user task request information, determining the task type and identifying the called large model type, it is possible to accurately retrieve the candidate prompt word template that best matches the task type and the large model type from the label prompt word template dataset, dynamically achieve a high degree of adaptation between the selected candidate prompt word template and the user task and the called model, form a dual adaptation for the task type and the large model type, enable rapid and accurate matching of the prompt word template, improve the accuracy and effectiveness of the large model response, avoid the inability to fully utilize the performance of the large model due to insufficient adaptability of the prompt word template to the large model or the task type, and be able to output high-quality results that meet the specific task requirements of the user with the most matching prompt word template, significantly improve the generalization ability and execution effect of the intelligent agent 100 in multi-model and multi-task scenarios, contribute to the construction of a more intelligent intelligent agent 100, and effectively support the efficient operation of the intelligent agent 100 in dynamic multi-model and multi-task scenarios.

[0073] Optionally, as an implementation, when the user sends a task request message to the agent 100, the input content can be a natural language question, an operation instruction, a programming requirement, etc. After obtaining the user's task request message, the agent 100 first calls a lightweight task classifier to quickly semantically understand the content of the user's task request message, determine the task type corresponding to the user's task request message, and at the same time identify the underlying large model that the agent 100 is currently invoking to solve the user's request for the user's task request message, so as to determine the large model adaptation dimension of the prompt template. Based on the dual labels of the large model dimension and the task type, the agent 100 retrieves a candidate prompt template from the optimized labeled prompt database; the candidate prompt template will be formatted and loaded, and concatenated with the user's task request message to construct a complete prompt instance as input and sent to the large model for inference. The agent 100 drives task execution based on the Thought-Action-Observation decision process; after each generation of the large model, it parses its output structure, calls external tools (such as calculators, retrievers, APIs, etc.) according to the Action therein, and feeds back the Observation result to the large model, and continues to iterate until the task is completed; after the agent 100 completes the task execution, it beautifies the format and integrates the information of the final output of the large model, and outputs it to the user; at the same time, it records metadata such as the prompt template, large model, execution time, and call record used in this task execution as the basic data for subsequent online learning and prompt optimization.

[0074] The third embodiment of the present invention provides a computer-readable storage medium storing a computer program, and when the computer program is executed, it implements the prompt optimization method of the first embodiment of the present invention.

[0075] In the embodiments provided by the present invention, it should be understood that "B corresponding to A" means that B is associated with A, and B can be determined according to A. However, it should also be understood that determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information.

[0076] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures, or characteristics related to the embodiment are included in at least one embodiment of the present invention. Therefore, the appearances of "in one embodiment" or "in an embodiment" throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0077] In various embodiments of the present invention, it should be understood that the magnitudes of the serial numbers of the above processes do not necessarily imply the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

[0078] The flowcharts and block diagrams in the accompanying drawings of the present invention illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the boxes may occur in a different order than marked in the accompanying drawings. For example, two consecutive boxes shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, which is determined based on the functions involved. It should be particularly noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0079] Compared with the prior art, a prompting word optimization method, an intelligent agent, and a storage medium provided by the present invention have the following beneficial effects: 1. In an embodiment of the present invention, a method for optimizing prompt words is provided. By constructing multiple different prompt word instances based on multiple different prompt word templates and task samples of multiple different task types, and inputting each prompt word instance into multiple target large models respectively, a sufficient number of prompt word instances can be generated, avoiding the limitation of the optimization result caused by insufficient data diversity, and providing a guarantee for the base number for subsequent screening of label prompt word templates adapted to each target large model and each task type. Based on the output results of the target large model, multiple first prompt word templates obtained by a preset method have better performance. By setting a first label and a second label for the first prompt word template, a label prompt word template is obtained, where the first label represents the task type of the task sample corresponding to the first prompt word template; the second label represents the type of the target large model corresponding to the input of the first prompt word template. The dual labels of the first label and the second label realize the structuring and standardization of the output result of the prompt word optimization method, laying a foundation for providing a two-dimensional indexing mechanism for the task type and the large model type, enabling the most matching prompt word template to be retrieved more conveniently and quickly through the dual labels of the task type and the large model type, helping to achieve the fast and accurate matching of the prompt word template, and supporting the efficient operation of the intelligent agent in dynamic scenarios of different task types and different large models. Since each label prompt word template corresponds to an adapted task type and target large model type respectively, compared with the fixed prompt word templates written under the existing intelligent agent framework, the prompt word optimization method of the present invention enables different task types and target large model types to each correspond to a relatively adapted label prompt word template, thus avoiding compatibility problems caused by the mismatch between the fixed prompt word template and the large model type or task type.

[0080] 2. In an embodiment of the present invention, through the closed-loop process of evaluating, iterating, re-evaluating, and re-iterating the output result of the prompt word template in a cycle, the prompt word template can be continuously optimized. The evaluation link provides a clear guidance for iteration. By making targeted improvements based on the evaluation results, the first prompt word templates that meet the preset conditions are gradually screened out. Compared with single optimization, the quality and applicability of the prompt word template are greatly improved. Based on the preset conditions, it is judged whether to stop iteration, etc., to avoid waste of computing resources and balance the optimization effect and efficiency. Through the feedback-driven optimization mechanism, a prompt word template with excellent performance that matches the target large model and the task instruction type is finally obtained.

[0081] 3. In the embodiments of the present invention, scoring from the structural level can ensure the format standardization of the output results of the prompt template. When scoring based on the output format accuracy at the structural level, it ensures that the model output conforms to the expected structure, facilitating the parsing of the target large model; scoring from the content level can ensure the effectiveness of task completion. When scoring based on the task completion accuracy at the content level, it can ensure that the prompt template truly and accurately helps the target large model complete the task, improving the accuracy of task execution. Through the combination of scoring at the structural level and the content level, multi-dimensional evaluation is achieved, and the problem types existing in the prompt template can be more accurately located, that is, the structure is unreasonable or the content is inaccurate, thus providing a clear direction for subsequent iterative optimization and improving the iterative optimization efficiency.

[0082] 4. In the iterative process of the embodiments of the present invention, by feeding back the evaluation results, generating a new round of prompt templates, and testing again to obtain the evaluation results, a closed-loop optimization is formed. It no longer relies on manual adjustment of the prompt template, but discovers and fixes the problems existing in the interaction between the prompt template and the target large model through the actual output feedback of the target large model, such as the preference of the target large model for specific sentence patterns and the misjudgment tendency for vague instructions. According to the feedback evaluation results, the effect of the prompt template is enhanced directionally. Through the cumulative effect of multiple rounds of iteration, the quality of the prompt template is gradually improved, ensuring the adaptability and task completion degree of the specific prompt template on the target large model, and finally obtaining the first set of prompt templates with excellent performance on the target large model.

[0083] 5. In the embodiments of the present invention, by adopting the method of rewriting and optimizing the existing prompt template, improvements are made on the basis of the mature prompt template, thereby expanding and generating more variants of prompt templates with different styles and strategies; by inputting the generation instruction into the large model, the large model generates the prompt template based on the generation instruction, which can make full use of the generation ability of the large model and achieve new creation according to the requirements. The generation instruction can include the structure output instruction, and combined with context information such as scene description and task type, it guides the large model to generate a new prompt template that conforms to the specification, ensuring from the source that the prompt is applicable to specific task and framework requirements. The two prompt template generation methods can be flexibly selected or combined, and can generate high-quality prompt templates according to different task characteristics and optimization goals, improving the pertinence and effectiveness of prompt template generation, and at the same time enriching the source and diversity of prompt templates.

[0084] 6. The prompting template generation large model in the embodiments of the present invention, such as large models like DeepSeek-V3, usually has stronger general generation capabilities and cross-domain transfer capabilities, which can improve the flexibility of prompting template generation. The large model for generating prompts uses the target large model, which can avoid errors caused by cross-model transfer, optimize the prompting template according to the distribution of its own training data, and the generated prompting template also more conforms to the parsing standard of its own large model, thereby improving the stability of prompting template generation. The prompting template generation large model and the target large model for generating prompting templates can be flexibly selected or used in combination, which can not only improve the diversity of prompting template generation and solve the problem of limited adaptability of fixed template tasks, but also ensure the stable execution of diverse prompting templates on the target large model. The generated prompting templates have the characteristics of stability, flexibility, and diversity, so as to better meet the complex requirements of multi-model and multi-task of the intelligent agent.

[0085] 7. Each prompt template in the embodiments of the present invention undergoes template formatting processing before being input into the target large model. After the prompt instance is input into the target large model, the target large model adopts the Thought-Action-Observation (TAO) closed-loop execution process, and collects the full-link data of the target large model running after the prompt instance is input, and performs structured storage on the full-link data. All of these are to make the entire prompt optimization process meet the single-variable principle, taking the difference in prompt templates as the only variable and avoiding the interference of irrelevant variables. Different prompt templates may have inconsistent formats, such as differences in JSON structures and different natural language expression styles. These non-content differences may lead to deviations in the output results of the target large model, such as format parsing errors and instruction understanding ambiguities. Through template formatting processing, all prompt templates are unified into a preset format, such as filling placeholders, aligning structure requirements, embedding task content, etc. formatting processing, ensuring that the only variable input into the target large model is the difference in prompt template content rather than the format, so as to accurately screen out the first prompt template in subsequent evaluations. In addition, different target large models may have different built-in execution processes. For example, some large models directly generate results, and some large models need to call tools step by step. If the large model execution process, the difference in output results may stem from the model execution logic. By forcibly adopting the Thought-Action-Observation (TAO) closed-loop process, that is, the standardized steps of thinking-action-observation feedback, the model execution process is fixed as a constant, ensuring that all large models follow the same reasoning framework when processing prompts. By collecting full-link data, such as including the input template content, formatted parameters, operation records of each step in the TAO process, and the final output results, and performing structured storage, this quantifies and records all variables during the operation of the large model, avoiding variable confusion caused by data loss. Ultimately, it is ensured that each optimization only changes the prompt template content, while other factors that may affect the results, such as format, process, and data recording method, are fixed or standardized, ensuring that the improvement in the effect of the first prompt template is due to the optimization of the prompt template itself rather than the interference of irrelevant variables, so as to select the first prompt template that is precisely adapted.

[0086] 8. The embodiments of the present invention also provide an agent, and the agent has the same beneficial effects as the above-mentioned prompt optimization method, which will not be elaborated here.

[0087] 9. In the embodiments of the present invention, by obtaining user task request information, judging the task type and identifying the type of large model invoked, it is possible to accurately retrieve the candidate prompt templates that best match the task type and large model type from the label prompt template dataset, dynamically realizing that the selected candidate prompt templates are highly adapted to the user tasks and the invoked models, forming a dual adaptability for the task type and the large model type, being able to achieve fast and accurate matching of the prompt templates, improving the accuracy and effectiveness of the large model response, avoiding the inability to fully exert the performance of the large model due to insufficient adaptability of the prompt templates to the large model or task type, and being able to meet the specific task requirements of users with the most matching prompt templates to output high-quality results, significantly enhancing the generalization ability and execution effect of the intelligent agent in multi-model and multi-task scenarios, contributing to the construction of an intelligent agent with a higher intelligent level, and effectively supporting the efficient operation of the intelligent agent in dynamic multi-model and multi-task scenarios.

[0088] 10. The embodiments of the present invention also provide a storage medium, which has the same beneficial effects as the above-mentioned method for optimizing prompt words, and will not be elaborated here.

[0089] The above has introduced in detail a method for optimizing prompt words, an intelligent agent and a storage medium disclosed in the embodiments of the present invention. Specific examples are used in this article to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A prompt optimization method, characterized in that, Including the following steps: Obtain a prompt template dataset and a task sample dataset, where the prompt template dataset includes multiple different prompt templates, and the task sample dataset includes task samples of multiple different task types; Construct multiple different prompt instances based on each of the prompt templates and each of the task samples, and input each of the prompt instances into multiple target large models respectively; Construct a first set of prompt templates by a preset method based on the output results of the target large models, where the first set of prompt templates includes multiple first prompt templates; Set a first label and a second label for the first prompt template to obtain a labeled prompt template, where the first label represents the task type of the task sample corresponding to the first prompt template; the second label represents the type of the target large model corresponding to the input of the first prompt template.

2. The prompting word optimization method according to claim 1, wherein: The constructing a first set of prompt templates by a preset method based on the output results of the target large models includes the following steps: Evaluate the output result corresponding to the prompt template to obtain an evaluation result; Perform an iterative operation on the prompt template based on the evaluation result to obtain an evaluation result of a new round of prompt templates; Based on the evaluation result of the new round of prompt templates, determine whether the new round of prompt templates meets the preset conditions. If so, add the new round of prompt templates to the first set of prompt templates; if not, repeat the iterative operation on the new round of prompt templates.

3. The prompting word optimization method according to claim 2, characterized in that: The evaluating the output result corresponding to the prompt template includes the following steps: Score the output result corresponding to the prompt template at the structural level and / or the content level; Among them, the scoring at the structural level includes scoring based on the output format accuracy of the output result; the scoring at the content level includes scoring based on the task completion accuracy of the output result.

4. The prompting word optimization method according to claim 2, wherein: The performing an iterative operation on the prompt template based on the evaluation result to obtain an evaluation result of a new round of prompt templates includes the following steps: Feed back the evaluation result to a prompt template generation large model, and the prompt template generation large model generates a new round of prompt templates based on the evaluation result; Construct a new round of prompt instances by combining the new round of prompt templates with the corresponding task samples, and input the new round of prompt instances into the target large model; Evaluate the output result of the target large model to obtain the evaluation result of the new round.

5. The prompting word optimization method according to claim 1, wherein: The multiple different prompt templates are generated by a large model, and the large model generating the multiple different prompt templates includes the following steps: Rewrite and optimize the existing prompt templates based on the large model to obtain the multiple different prompt templates; And / or, input a generation instruction into the large model, and the large model generates the prompt template based on the generation instruction.

6. The prompting word optimization method according to claim 5, wherein: The large model includes a prompt template generation large model; And / or, the large model includes a target large model, and the prompt template generated by the target large model is used for input into the target large model.

7. The prompting word optimization method according to claim 1, wherein: Before each of the prompt templates is input into the target large model, template formatting processing is performed; and / or, after the prompt instance is input into the target large model, the target large model adopts a Thought-Action-Observation closed-loop execution process; and / or, collect the full-link data of the target large model running after the prompt instance is input, and perform structured storage on the full-link data, wherein the output result includes the full-link data of the structured storage.

8. An agent, characterized in that, The intelligent agent includes the following modules: An input module, configured to receive input information, where the input information is generated based on the labeled prompt template obtained by the prompt optimization method according to any one of claims 1 to 7; A processing module, configured to process the input information received by the input module to obtain output information; An output module, configured to output the output information of the processing module.

9. The agent according to claim 8, wherein: The generation of the input information includes the following steps: Obtain user task request information; Judge the task type corresponding to the user task request information, and identify the large model type called by the intelligent agent for the user task request information; Based on the task type and the large model type, retrieve candidate prompt templates from the dataset of the labeled prompt templates; wherein, the first label corresponding to the candidate prompt template is the same as the task type corresponding to the user task request information, and the second label corresponding to the candidate prompt template is the same as the large model type called by the user task request information; Obtain the input information based on the user task request information and the candidate prompt template.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed, it implements the prompt optimization method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Prompt word optimization method for processing multi-label classification task for large language model

    CN118350361A

  • Prompt word optimization method and device, equipment, medium and product

    CN119180351A

  • Model cue word automatic optimization method and device, equipment and storage medium

    CN119226476A

  • Large model cue word optimization method and system for city block emotion memory

    CN119378530A

  • Prompt word template generation method and device, electronic equipment and storage medium

    CN119443094A

Cited By

  • Image generation method and device, computer equipment, storage medium and program product

    CN121010661A

  • Intelligent cue word generation evaluation method and system based on multi-component collaboration

    CN121092653A

  • Strategy evaluation method

    CN121118884A

  • Strategy evaluation method

    CN121118884B

  • Multi-modal model training method and device based on thinking chain prompt pool

    CN121146070A