A prompt word optimization method, intelligent agent and storage medium

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

CN120278153BActive Publication Date: 2025-08-29BEIJING LANZHOU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510754281.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-06
Publication Date
2025-08-29
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 agent's performance and generalization capabilities in multi-model and multi-task scenarios.

Method used

By building multiple different prompt word instances, evaluating and iteratively optimized based on the output results of the target big model, setting the tags of task type and big model type, forming a tag prompt word template to achieve fast and accurate matching and dynamic adaptation.

Benefits of technology

The applicability and quality of prompt word templates are improved, ensuring efficient operation of agents in dynamic scenarios of different task types and large models is avoided, compatibility problems caused by mismatch between fixed templates and models or task types are improved, and the generalization ability and execution effect of agents are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120278153B_ABST
    Figure CN120278153B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of artificial intelligence technology, and more particularly to a prompt word optimization method, an intelligent agent, and a storage medium. The prompt word optimization method provided by the present invention generates multiple prompt word templates, combines different prompt word templates with different task samples and inputs them into different models. After continuous evaluation and feedback optimization, a first prompt word template adapted to each task and model type is ultimately selected. A first label representing the corresponding task type and a second label representing the corresponding model type are set for each first prompt word template to obtain and store labeled prompt word templates, making it easy to search based on task and model dimensions. This allows for rapid and accurate matching of prompt word templates, improves the adaptability of prompt word templates, supports the efficient operation of intelligent agents in dynamic scenarios with different tasks and models, enables the intelligent agent to adapt to the prompt word template that is most suitable for the task and model type, and improves the generalization ability and execution effect of the intelligent agent in multi-task scenarios and multi-models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a prompt word optimization method, an intelligent agent and a storage medium. Background Art

[0002] In recent years, the technology for building intelligent agents based on large language models (LLMs) has rapidly developed. An agent is a system capable of perceiving its environment, making decisions, and executing actions. In many cases, especially when handling complex or multimodal tasks, agents often utilize multiple large models to improve performance and functional diversity. The output of these large models relies on guidance from prompt word templates. However, in existing agent frameworks, prompt word templates are typically fixed. When an agent uses different large models to handle different types of tasks, the prompt word templates cannot dynamically adapt to the characteristics of the different large models or the task type, leading to adaptability issues. Summary of the Invention

[0003] In order to solve the above problems, the present invention provides a prompt word optimization method, an intelligent agent and a storage medium.

[0004] To solve the above technical problems, the present invention provides the following technical solutions: a prompt word optimization method, comprising the following steps: obtaining a prompt word template dataset and a task sample dataset, wherein the prompt word template dataset includes multiple different prompt word templates, and the task sample dataset includes multiple task samples of different task types; constructing multiple 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 multiple target large models; constructing a first prompt word template set based on the output results of the target large models using a preset method, wherein the first prompt word template set includes multiple first prompt word templates;

[0005] Setting a first label and a second label for the first prompt word template to obtain a label prompt word template, wherein the first label represents the task type of the task sample corresponding to the first prompt word template; and the second label represents the type of the target large model input corresponding to the first prompt word template;

[0006] The method of constructing a first prompt word template set based on the output result of the target large model using a preset method includes the following steps: evaluating the output result corresponding to the prompt word template to obtain an evaluation result; iteratively operating the prompt word template based on the evaluation result to obtain a new round of evaluation results of the prompt word template; judging whether the prompt word template of the new round meets the preset conditions based on the evaluation results of the prompt word template of the new round; if so, adding the prompt word template of the new round to the first prompt word template set; if not, repeating the iterative operation on the prompt word template of the new round.

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

[0008] Preferably, the iterative operation on the prompt word template based on the evaluation result to obtain a new round of evaluation results of the prompt word template includes the following steps: feeding back the evaluation result to the prompt word template generation big model, the prompt word template generation big model generates a new round of prompt word templates based on the evaluation result; constructing a new round of prompt word instances by combining the new round of prompt word templates with the corresponding task samples, and inputting the new round of prompt word instances into the target big model; evaluating the output result of the target big model to obtain the new round of evaluation results.

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

[0010] Preferably, the large model includes a prompt word template to generate the large model; and / or, the large model includes a target large model, and the prompt word template generated by the target large model is used to input the target large model.

[0011] Preferably, each of the prompt word templates is template formatted before being input into the target large model; and / or, after the prompt word instance is input into the target large model, the target large model adopts the Thought-Action-Observation closed-loop execution process; and / or, the full-link data of the target large model running after the prompt word instance is input is collected, and the full-link data is structured and stored, wherein the output result includes the structured stored full-link data.

[0012] In order 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, and the input information is generated based on the label prompt word template obtained by any of the prompt word optimization methods described above; 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.

[0013] 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 type of large model called by the intelligent agent for the user task request information; retrieving a candidate prompt word template from the data set of the label prompt word template based on the task type and the large model type; 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; and obtaining the input information based on the user task request information and the candidate prompt word template.

[0014] In order to solve the above technical problems, the present invention provides another technical solution as follows: a computer-readable storage medium, which implements any one of the above-mentioned prompt word optimization methods when the computer program is executed.

[0015] Compared with the prior art, the prompt word optimization method, intelligent agent, and storage medium provided by the present invention have the following beneficial effects:

[0016] 1. An embodiment of the present invention provides a prompt word optimization method. By constructing multiple different prompt word instances based on multiple different prompt word templates and multiple task samples of different task types, and inputting each prompt word instance into multiple target macro models, a sufficient number of prompt word instances can be generated, avoiding optimization result limitations caused by insufficient data diversity and providing a base number guarantee for the subsequent screening of label prompt word templates that are compatible with each target macro model and each task type. Based on the output of the target macro model, multiple first prompt word templates obtained using a preset method have better performance. A first label and a second label are assigned to the first prompt word template to obtain a label 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 target macro model type corresponding to the first prompt word template. The dual labeling of the first label and the second label achieves structured and standardized output results of the prompt word optimization method, laying the foundation for providing a two-dimensional indexing mechanism for task type and macro model type. This dual labeling enables more convenient and rapid retrieval of the most matching prompt word template using the task type and macro model type, facilitating rapid and accurate matching of prompt word templates and supporting efficient operation of intelligent agents in dynamic scenarios with different task types and different macro models. Since each label prompt word template corresponds to an adapted task type and target large model type, 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 correspond to more adapted label prompt word templates, thereby avoiding compatibility issues caused by the mismatch between the fixed prompt word template and the large model type or task type.

[0017] 2. In the embodiments of the present invention, a closed-loop process of evaluating, iterating, re-evaluating, and iterating the prompt word template output results is used to continuously optimize the prompt word template. The evaluation phase provides a clear guide for iteration. By making targeted improvements based on the evaluation results, the first prompt word template that meets the preset conditions is gradually selected. Compared to single-shot optimization, the quality and applicability of the prompt word template are significantly improved. Determining whether to stop iteration based on preset conditions avoids wasted computing resources and balances optimization effectiveness and efficiency. Through a feedback-driven optimization mechanism, a prompt word template with excellent performance that matches the target macromodel and task instruction type is ultimately obtained.

[0018] 3. In the embodiment of the present invention, scoring is performed at the structural level, which can ensure the format standardization of the prompt word template output result. When the structural level is scored based on the output format accuracy, it is ensured that the model output conforms to the expected structure, which is convenient for the target large model to analyze; scoring is performed at the content level, which can ensure the effectiveness of task completion. When the content level is scored based on the task completion accuracy, it can ensure that the prompt word template truly and accurately helps the target large model complete the task, thereby improving the accuracy of task execution. By combining scoring at the structural level and the content level, a multi-dimensional evaluation is achieved, which can more accurately locate the problem type of the prompt word template, which is an unreasonable structure or inaccurate content, thereby providing a clear direction for subsequent iterative optimization and improving the efficiency of iterative optimization.

[0019] 4. The iterative process in the embodiment of the present invention forms a closed-loop optimization by feeding back the evaluation results, generating a new round of prompt word templates, and testing again to obtain the evaluation results. It no longer relies on manual adjustment of the prompt word templates, but uses the actual output feedback of the target large model to discover and repair problems in the interaction between the prompt word templates and the target large model, such as the target large model's preference for specific sentence patterns and the tendency to misjudge ambiguous instructions. The effect of the prompt word template is enhanced in a targeted manner based on the feedback evaluation results. Through the cumulative effect of multiple rounds of iterations, the quality of the prompt word template is gradually improved to ensure the adaptability and task completion of the specific prompt word template on the target large model, and finally obtain the first prompt word template set with excellent performance on the target large model.

[0020] 5. In the embodiments of the present invention, by rewriting and optimizing existing prompt word templates, improvements are achieved based on mature prompt word templates, thereby expanding the generation of prompt word template variants with more styles and strategies. By inputting generation instructions into the large model, the large model generates prompt word templates based on the generation instructions, fully utilizing the large model's generation capabilities to achieve new creations based on demand. Generation instructions can include structural output instructions and, combined with contextual information such as scene descriptions and task types, guide the large model to generate new prompt word templates that meet specifications, ensuring from the source that prompt words are suitable for specific tasks and framework requirements. The two prompt word template generation methods can be flexibly selected or used in combination, and can generate high-quality prompt word templates based on different task characteristics and optimization goals, improving the pertinence and effectiveness of prompt word template generation, while also enriching the source and diversity of prompt word templates.

[0021] 6. The large model for generating prompt word templates in the embodiments of the present invention, such as DeepSeek-V3, typically has stronger general generation capabilities and cross-domain migration capabilities, which can improve the flexibility of prompt word template generation. The large model for generating prompt words uses the target large model, which can avoid errors caused by cross-model migration and optimize the prompt word template based on its own training data distribution. The generated prompt word template also better meets the parsing standards of its own large model, thereby improving the stability of prompt word template generation. The large model for generating prompt word templates and the target large model for generating prompt word templates can be flexibly selected or used in combination. This can not only improve the diversity of prompt word template generation and solve the problem of limited adaptability of fixed template tasks, but also ensure the stable execution of diverse prompt word templates on the target large model. The generated prompt word templates are stable, flexible, and diverse, thereby better meeting the complex multi-model and multi-task requirements of the intelligent agent.

[0022] 7. In the embodiment of the present invention, each prompt word template is formatted before being input into the target large model. After the prompt word 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 operation after the prompt word instance is input, and the full-link data is stored in a structured manner. This is to ensure that the entire prompt word optimization process meets the single variable principle, and the difference in prompt word templates is used as the only variable to avoid interference from irrelevant variables. Different prompt word templates may have inconsistent formats, such as JSON structure differences and different natural language expression styles. These non-content differences may cause deviations in the output results of the target large model, such as format parsing errors and ambiguous instruction understanding. Through template formatting processing, all prompt word templates are unified into a preset format, such as filling placeholders, aligning structural requirements, embedding task content, and other formatting processes, to ensure that the only variable input into the target large model is the different content of the prompt word template rather than the format, so as to accurately screen out the first prompt word template in subsequent evaluations. Furthermore, different target large models may have different built-in execution processes. For example, some large models generate results directly, while others require step-by-step tool invocation. If large models execute the process, differences in output results may stem from the model execution logic. By enforcing the Thought-Action-Observation (TAO) closed-loop process—a standardized process of thinking, action, and observation feedback—the model execution process is fixed as a constant, ensuring that all large models follow the same reasoning framework when processing prompt words. By collecting and storing full-link data, including input template content, formatted parameters, records of each step in the TAO process, and final output results, and quantifying all variables in the large model's execution, it avoids variable confusion caused by missing data. Ultimately, each optimization ensures that only the prompt word template content is changed, while other factors that may affect the results, such as format, process, and data recording method, are fixed or standardized. This ensures that the improved performance of the first prompt word template is due to optimization of the prompt word template itself, rather than interference from irrelevant variables, thereby selecting a precisely adapted first prompt word template.

[0023] 8. An embodiment of the present invention further provides an intelligent agent, which has the same beneficial effects as the above-mentioned prompt word optimization method, and will not be described in detail here.

[0024] 9. In the embodiment of the present invention, by obtaining user task request information, judging the task type and identifying the type of large model to be called, the candidate prompt word template that best matches the task type and large model type can be accurately retrieved from the label prompt word template data set, and the screened candidate prompt word template can be dynamically adapted to the user task and the called model, forming a dual adaptation for task type and large model type, which can achieve fast and accurate matching of prompt word templates, improve the accuracy and effectiveness of large model responses, 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 task type, and can output high-quality results with the most matching prompt word template to meet the user's specific task requirements, significantly improving the generalization ability and execution effect of the intelligent agent in multi-model and multi-task scenarios, helping to build an intelligent agent with a higher level of intelligence, and can effectively support the efficient operation of the intelligent agent in dynamic scenarios with multiple models and multiple tasks.

[0025] 10. An embodiment of the present invention further provides a storage medium, which has the same beneficial effects as the above-mentioned prompt word optimization method, and will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

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

[0028] Figure 2 This is a flowchart of step S3 of a prompt word optimization method provided by the first embodiment of the present invention.

[0029] Figure 3 This is a flowchart of step S32 of a prompt word optimization method provided by the first embodiment of the present invention.

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

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

[0032] Description of the accompanying drawings:

[0033] 100. Intelligent agent; 1. Input module; 2. Processing module; 3. Output module. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and implementation examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0035] See also Figure 1 The first embodiment of the present invention provides a prompt word optimization method, comprising the following steps:

[0036] Step S1, obtaining a prompt word template dataset and a task sample dataset, wherein the prompt word template dataset includes a plurality of different prompt word templates, and the task sample dataset includes a plurality of task samples of different task types;

[0037] It should be noted that a prompt template is a structured framework that can contain 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 prompt template, {source language}, {target language}, and {text} are placeholders, and the rest are fixed instructions. Task samples can be specific task instances or examples, including references to input data or expected outputs. For example, "Please translate the sentence "Today's weather is great" from Chinese to English."

[0038] Step S2: construct multiple different prompt word instances based on each prompt word template and each task sample, and input each prompt word instance into multiple target large models respectively;

[0039] It should be noted that constructing multiple different prompt word instances based on each prompt word template and each task sample refers to combining each prompt word template with each task sample to form a specific prompt word instance with complete context, that is, a complete prompt word. For example, if the prompt word template selects "Please translate the following {source language} text into {target language}: {text}" and the task sample selects "Please translate the sentence "Today's weather is great" from Chinese into English," this combination forms the prompt word instance "Please translate the following Chinese text into English: Today's weather is great." This allows the task samples to be converted into standardized prompt word instances using the fixed structure of the prompt word template, facilitating parsing by the target large model and improving the quality of the target large model's output results.

[0040] It should be noted that a large model refers to an artificial intelligence model that has been trained with massive amounts of data and has a large parameter scale. An intelligent agent is a system that can perceive the environment, make decisions, and perform actions. Since different large models may have their own advantages in different task areas, a single large model may not be able to meet the complex and diverse task requirements. Intelligent agents often integrate multiple large models. In many cases, especially when dealing with complex or multimodal tasks, intelligent agents often call on multiple large models to improve performance and functional diversity. Multiple target large models refer to different large models used to input prompt word instances. They can be multiple different large models integrated by the intelligent agent, and each prompt word instance is input into these target large models in order to subsequently screen out the most suitable prompt word template for each target large model.

[0041] Specifically, for ease of understanding, the following examples are given: each prompt word template includes a, b and c; each task sample includes 1, 2 and 3; each target large model includes model α, model β and model γ; then the prompt word instances a1, a2, a3, b1, b2, b3, c1, c2 and c3 constructed by each prompt word template and each task sample are input into model α, model β and model γ.

[0042] Step S3: constructing a first prompt word template set using a preset method based on the output result of the target large model, wherein the first prompt word template set includes a plurality of first prompt word templates;

[0043] It should be noted that the first prompt word template refers to a prompt word template with excellent performance that is ultimately selected based on a preset method. Optionally, the preset method can be based on evaluation indicators, control variable comparison experiments, effect feedback, or multiple rounds of iterative screening to select the first prompt word template.

[0044] Step S4, setting a first label and a second label for the first prompt word template to obtain a label 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 target large model type corresponding to the input of the first prompt word template.

[0045] It should be noted that when a prompt word template is combined with a task sample and input into a target macro model, and the prompt word template is ultimately selected as the first prompt word template, the first label represents the task type of the task sample, and the target macro model represented by the second label is precisely the target macro model that the prompt word template input when obtaining the first prompt word template screening result. Setting the first label and the second label for the first prompt word template to obtain a label prompt word template means that the label prompt word template corresponds to the specific first label and the second label. This corresponding information can be stored in a structured database, supporting the search for matching label prompt word templates according to the task type dimension and the macro model type dimension. This label prompt word template has better performance when the task type corresponding to the first label and the macro model corresponding to the second label are input.

[0046] Understandably, by constructing multiple different prompt word instances based on multiple different prompt word templates and multiple task samples of different task types, and inputting each prompt word instance into multiple target macro models, a sufficient number of prompt word instances can be generated, avoiding the limitations of optimization results caused by insufficient data diversity. This provides a base number guarantee for the subsequent screening of label prompt word templates that are compatible with each target macro model and each task type. Based on the output results of the target macro model, multiple first prompt word templates obtained using a preset method have better performance. A label prompt word template is obtained by assigning a first label and a second label to the first prompt word template, where the first label represents the task type of the task sample corresponding to the first prompt word template; the second label represents the target macro model type corresponding to the first prompt word template. This dual labeling of the first and second labels achieves structured and standardized output results of the prompt word optimization method, laying the foundation for providing a two-dimensional indexing mechanism for task type and macro model type. This dual labeling enables more convenient and rapid retrieval of the most matching prompt word template using the task type and macro model type, facilitating rapid and accurate matching of prompt word templates and fully supporting the efficient operation of intelligent agents in dynamic scenarios with different task types and different macro models. Since each label prompt word template corresponds to an adapted task type and target large model type, 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 correspond to more adapted label prompt word templates, thereby avoiding compatibility issues caused by the mismatch between the fixed prompt word template and the large model type or task type.

[0047] It's important to note that existing agent frameworks use fixed prompt templates, while agents often integrate multiple large models. In many cases, especially when handling complex or multimodal tasks, agents often call upon multiple large models to improve performance and functional diversity. This single prompt template severely mismatches the diversity of large models and task types, leading to insufficient and limited adaptability of large models. Different large models may respond significantly differently to the same prompt template. Some large models may perform well with a fixed template, while others may not. Fixed prompt templates fail to fully leverage the performance characteristics of individual large models, hindering the construction of a general agent framework with large model adaptability. Furthermore, different tasks have different requirements for prompt templates. Using a fixed prompt template to cover all task scenarios can lead to reduced generalization. For example, a prompt template may perform well in writing tasks but poorly in programming tasks. Therefore, prompt templates that lack task-type awareness and dynamic adaptation capabilities struggle to address diverse application needs. Each label prompt word template formed by the prompt word optimization method of the present invention corresponds to a first label and a second label, which helps to achieve rapid and accurate adaptation of the prompt word template and can effectively support the efficient operation of the intelligent agent in different task types and different large model dynamic scenarios.

[0048] Optionally, the identification of task types can be achieved by building a lightweight task classifier based on a large model. The classifier identifies the task type to which the input task sample belongs based on its content. Task types may include general question answering, code generation, logical reasoning, writing creation, information extraction, etc. Other task types are not limited here.

[0049] See also Figure 2 Furthermore, step S3 constructs a first prompt word template set based on the output result of the target large model using a preset method, including the following steps:

[0050] Step S31, evaluating the output result corresponding to the prompt word template to obtain an evaluation result;

[0051] Step S32, iterating the prompt word template based on the evaluation result to obtain a new round of prompt word template evaluation results;

[0052] Step S33: Based on the evaluation results of the new round of prompt word templates, determine whether the new round of prompt word templates meet the preset conditions. If so, add the new round of prompt word templates to the first prompt word template set; if not, repeat the iterative operation on the new round of prompt word templates.

[0053] It is understandable that the output results corresponding to the prompt word template are evaluated to obtain an evaluation result, and based on the evaluation result, the prompt word template is iterated to obtain the evaluation results of a new round of prompt word templates. The above steps mean that after the prompt word 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 word template, the output result is evaluated, and the prompt word template is iterated based on the evaluation result. The significance of the evaluation and iterative operations lies in the closed-loop process of evaluating the prompt word template output results, iterating, re-evaluating, and iterating again, continuously optimizing the prompt word template. The evaluation step provides a clear guide for the iterative operation. The iterative operation makes targeted improvements based on the evaluation results, gradually screening out the first prompt word template that meets the preset conditions. Compared with a single optimization, the quality and applicability of the prompt word template are greatly improved. Based on the preset conditions, the waste of computing resources is avoided, and the optimization effect and efficiency are balanced. 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 ultimately obtained.

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

[0055] Furthermore, the output result corresponding to the prompt word template is evaluated, including the following steps:

[0056] Scoring the output results corresponding to the prompt word template at the structural level and / or content level;

[0057] Among them, the scoring at the structural level includes scoring based on the output format accuracy of the output results; the scoring at the content level includes scoring based on the task completion accuracy of the output results.

[0058] Understandably, scoring at the structural level can ensure the format standardization of the prompt word template output results. When the structural level is scored based on the output format accuracy, it ensures that the model output conforms to the expected structure, which is convenient for the target large model to parse; scoring at the content level can ensure the effectiveness of task completion. When the content level is scored based on the task completion accuracy, it can ensure that the prompt word template truly and accurately helps the target large model complete the task and improve the accuracy of task execution. By combining scoring at the structural level and the content level, a multi-dimensional evaluation is achieved, which can more accurately locate the type of problem with the prompt word template, specifically whether it is an unreasonable structure or inaccurate content, thereby providing a clear direction for the optimization of subsequent iterative operations and improving the optimization efficiency of iterative operations.

[0059] Optionally, as a specific implementation manner, the output results corresponding to the prompt word template are evaluated, including scoring the output results corresponding to the prompt word template at the structural level and the content level; as another specific implementation manner, the output results corresponding to the prompt word template are evaluated, including only scoring the output results corresponding to the prompt word template at the structural level; as another specific implementation manner, the output results corresponding to the prompt word template are evaluated, including only scoring the output results corresponding to the prompt word template at the content level.

[0060] Optionally, scoring based on the output format accuracy of the output results includes determining whether the target large model's output conforms to the preset structure. For example, the preset structure must strictly follow the Thought-Action-Observation structure specification. Output format accuracy can be verified through methods 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 framework for enabling the large model's autonomous decision-making and interaction with the environment. The core concept is to improve the large model's reasoning ability and interpretability in complex tasks by simulating the human thought-action-feedback cycle. Thought refers to the large model's internal reasoning process for the current task, expressed as intermediate steps or logical chains described in natural language. Action refers to the specific operation generated by the large model based on Thought, including calling external tools, APIs, or performing internal calculations. Observation refers to the results or environmental feedback returned after the Action is executed, which is used to adjust subsequent decisions.

[0061] Optionally, scoring based on the task completion accuracy of the output results includes evaluating the correctness and effectiveness of the output content of the target large model when completing specific implementation examples, such as whether the questions and answers are correct, whether the code is executable, and whether the reasoning process is rigorous. Task completion accuracy can be evaluated by combining manually annotated data and reference answers through matching, execution verification, and other methods.

[0062] See also Figure 3 Furthermore, step S32 performs an iterative operation on the prompt word template based on the evaluation result to obtain a new round of evaluation results of the prompt word template, including the following steps:

[0063] Step S321: Feedback the evaluation results to the prompt word template generation model, and the prompt word template generation model generates a new round of prompt word templates based on the evaluation results;

[0064] Step S322: construct a new round of prompt word instances by combining the new round of prompt word templates with the corresponding task samples, and input the new round of prompt word instances into the target large model;

[0065] Step S323: Evaluate the output results of the target large model to obtain a new round of evaluation results.

[0066] It can be understood that the large model generated by the prompt word template refers to a large model specifically used to generate the prompt word template. The task samples corresponding to the prompt word templates in the new round are the same as the task samples corresponding to the prompt word templates in the previous round, thereby ensuring that the variables are only different in each round of prompt word templates, while the task samples combined with the prompt word templates remain unchanged. The iterative process forms a closed-loop optimization by feedback evaluation results, generating a new round of prompt word templates, and retesting to obtain evaluation results. It no longer relies on manual experience-based adjustment of the prompt word templates. Instead, it uses the actual output feedback of the target large model to discover and fix problems in the interaction between the prompt word template and the target large model, such as the target large model's preference for specific sentence patterns and the tendency to misjudge ambiguous instructions. Based on the feedback evaluation results, the effect of the prompt word template is targeted and enhanced. Through the cumulative effect of multiple rounds of iteration, the quality of the prompt word template is gradually improved, ensuring the adaptability and task completion of the specific prompt word template on the target large model, and ultimately obtaining the first prompt word template set that performs well on the target large model.

[0067] Optionally, the prompt word template generation model generates a new round of prompt word templates based on the evaluation results. The prompt word template generation strategy can be adjusted according to the feedback of the evaluation results. Semantic enhancement, structural adjustment, local rewriting, etc. can be used to generate a new round of prompt word templates with better performance.

[0068] Furthermore, multiple different prompt word templates are generated by the large model, and the large model generates multiple different prompt word templates including the following steps:

[0069] Rewrite and optimize the existing prompt word template based on the large model to obtain multiple different prompt word templates;

[0070] And / or, the generation instruction is input into the large model, and the large model generates a prompt word template based on the generation instruction.

[0071] Understandably, by rewriting and optimizing existing prompt word templates, improvements can be made based on mature prompt word templates, thereby expanding the generation of prompt word template variants with more styles and strategies. By inputting generation instructions into the large model, and the large model generating prompt word templates based on the generation instructions, the large model's generation capabilities can be fully utilized to achieve new creations based on demand. Optionally, the generation instructions can include structured output instructions and, combined with contextual information such as scene descriptions and task types, guide the large model to generate new prompt word templates that meet specifications, ensuring from the source that the prompt words are suitable for specific tasks and framework requirements. The two prompt word template generation methods can be flexibly selected or used in combination, and can generate high-quality prompt word templates based on different task characteristics and optimization goals, improving the pertinence and effectiveness of prompt word template generation, while also enriching the source and diversity of prompt word templates.

[0072] Optionally, as a specific embodiment, the large model generating multiple different prompt word templates includes: rewriting and optimizing an existing prompt word template based on the large model to obtain multiple different prompt word templates, and inputting a generation instruction into the large model, whereby the large model generates the prompt word templates based on the generation instruction. As another specific embodiment, the large model generating multiple different prompt word templates only includes: rewriting and optimizing an existing prompt word template based on the large model to obtain multiple different prompt word templates. As another specific embodiment, the large model generating multiple different prompt word templates only includes: inputting a generation instruction into the large model, whereby the large model generates the prompt word templates based on the generation instruction.

[0073] Optionally, the existing prompt word templates can be pre-designed prompt word templates based on expert experience. These prompt word templates can include thought chains and one-step instruction structures. The existing prompt word templates can be expanded, restructured, replaced with other words through the large model to generate multiple different prompt word templates.

[0074] Optionally, the generation instructions are input into the big model, and the big model generates a prompt word template based on the generation instructions. This can be to input clear output structure instructions into the big model. For example, the output result must include the structure specification of Thought-Action-Observation, and combined with contextual information such as scene description and task type, to guide the big model to generate a prompt word template that meets the specifications, ensuring from the source that the prompt word template is applicable to specific tasks and framework requirements.

[0075] Furthermore, the large model includes a prompt word template to generate the large model;

[0076] And / or, the large model includes a target large model, and the prompt word template generated by the target large model is used to input the target large model.

[0077] Understandably, large models for generating prompt word templates typically possess stronger general generation capabilities and cross-domain migration capabilities, which can improve the flexibility of prompt word template generation. Using a target large model for generating prompt words can avoid errors caused by cross-model migration, optimize prompt word templates based on their own training data distribution, and generate prompt word templates that are more consistent with the parsing standards of their own large model, thereby improving the stability of prompt word template generation. The large model for generating prompt word templates and the target large model for generating prompt word templates can be flexibly selected or used in combination, which can improve the diversity of prompt word template generation, address the limited adaptability of fixed template tasks, and ensure the stable execution of diverse prompt word templates on the target large model. The generated prompt word templates are stable, flexible, and diverse, thus better meeting the complex multi-model and multi-task requirements of intelligent agents.

[0078] Optionally, as a specific embodiment, the large model includes a large model generated by a prompt word template and a target large model, and the prompt word template generated by the target large model is used to input the target large model. As another specific embodiment, the large model only includes the large model generated by the prompt word template. As another specific embodiment, the large model only includes the target large model, and the prompt word template generated by the target large model is used to input the target large model.

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

[0080] Furthermore, each prompt word template is subjected to template formatting processing before being input into the target macro model.

[0081] Understandably, different prompt word templates may have formatting inconsistencies, such as differences in JSON structure or natural language expression styles. These non-content-related differences can lead to deviations in the output of the target large model, such as format parsing errors and ambiguous instruction interpretation. Through template formatting, all prompt word templates are unified into a preset format, such as filling placeholders, aligning structural requirements, and embedding task content. This ensures that the only variable input to the target large model is the content of the prompt word template, not the format. This allows accurate selection of the first prompt word template in subsequent evaluations.

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

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

[0084] Understandably, different target large models may have different built-in execution processes. For example, some large models generate results directly, while others require step-by-step tool invocation. If large models execute the process, differences in output results may stem from the model execution logic. By enforcing the Thought-Action-Observation (TAO) closed-loop process, that is, the standardized steps of thinking, action, observation and feedback, the model execution process is fixed as a constant, ensuring that all large models follow the same reasoning framework when processing prompt words. Only the difference in the prompt word template is treated as the only variable, avoiding interference from irrelevant variables and ensuring consistency and comparability of evaluations. The Thought-Action-Observation (TAO) closed-loop refers to the closed-loop iteration of thinking, action, and observation to achieve complex task solving. The content of Thought, Action, and Observation has been introduced in the previous article and will not be repeated here.

[0085] Furthermore, the full-link data of the target large model running after the prompt word instance is input is collected, and the full-link data is structured and stored, wherein the output result includes the structured stored full-link data.

[0086] It can be understood that by collecting full-link data and storing it in a structured manner, all variables in the operation of the large model can be quantified and recorded, avoiding variable confusion caused by missing data.

[0087] It should be noted that full-link data refers to the data generated at each step of the target large model operation after the prompt word instance is input. Optionally, the full-link data includes the input template content, formatted parameters, operation records of each step in the TAO process, final output results, etc. It can also include intermediate calls during the operation process (such as external tool calls), large model response time, output token number and other operation meta-information. The full-link data is stored in a structured manner as a 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, and CSV.

[0088] Understandably, the template formatting performed on each prompt word template before inputting into the target large model, the closed-loop Thought-Action-Observation (TAO) execution process adopted by the target large model after the prompt word instance is input, and the collection and structured storage of the full-link data from the target large model's operation after the prompt word instance is input are all intended to ensure that the entire prompt word optimization process adheres to the single variable principle, treating the different prompt word templates as the only variable and avoiding interference from irrelevant variables. Ultimately, this ensures that each optimization only changes the prompt word template content, while other factors that may affect the results, such as format, process, and data recording methods, are fixed or standardized. This ensures that the improved effectiveness of the first prompt word template is due to the optimization of the prompt word template itself, rather than interference from irrelevant variables, thereby selecting a precisely adapted first prompt word template.

[0089] See also Figure 4 The second embodiment of the present invention provides an intelligent agent 100, which includes the following modules:

[0090] Input module 1, for receiving input information, the input information is generated based on the label prompt word template obtained by the prompt word optimization method in the first embodiment of the present invention;

[0091] Processing module 2, configured to process the input information received by input module 1 to obtain output information;

[0092] The output module 3 is used to output the output information of the processing module 2.

[0093] It can be understood that when the label prompt word template obtained based on the prompt word optimization method in the first embodiment of the present invention generates input information, 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 repeated here.

[0094] See also Figure 5 ,Furthermore, the generation of input information includes the following steps:

[0095] Step S51, obtaining user task request information;

[0096] Step S52, determining the task type corresponding to the user task request information, and identifying the type of the macro model called by the agent 100 in response to the user task request information;

[0097] Step S53: Based on the task type and the macro model type, a candidate prompt word template is retrieved from the dataset of label prompt word templates; 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 macro model type called by the user task request information;

[0098] Step S54: obtaining input information based on the user task request information and the candidate prompt word templates.

[0099] It can be understood that by obtaining user task request information, judging the task type and identifying the type of large model to be called, the candidate prompt word template that best matches the task type and large model type can be accurately retrieved from the label prompt word template data set, and the screened candidate prompt word template can be dynamically made highly adaptable to the user task and the called model, forming a dual adaptation for task type and large model type, which can achieve fast and accurate matching of prompt word templates, improve the accuracy and effectiveness of large model responses, 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 task type, and can output high-quality results with the most matching prompt word template to meet the user's specific task requirements, significantly improving the generalization ability and execution effect of the intelligent agent 100 in multi-model, multi-task scenarios, helping to build an intelligent agent 100 with a higher level of intelligence, and can effectively support the efficient operation of the intelligent agent 100 in dynamic scenarios with multiple models and multiple tasks.

[0100] Optionally, as an implementation method, when a user initiates 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 understand the semantics of the user's task request message content, determine the task type corresponding to the user's task request message, and simultaneously identify the underlying large model currently called by the agent 100 to solve the user's request in response to the user's task request message, so as to determine the large model adaptation dimension of the prompt word template. Based on the dual labels of the large model dimension and the task type, the agent 100 retrieves a candidate prompt word template from the optimized label prompt word database; the candidate prompt word template will be formatted and loaded, and spliced ​​with the user's task request message to construct a complete prompt word instance as input, which is then sent to the large model for reasoning. Intelligent agent 100 drives task execution based on the Thought-Action-Observation decision-making process; after each round of generation of the large model, it parses its output structure, calls external tools (such as calculators, retrievers, APIs, etc.) according to the Action, and feeds the Observation results back to the large model, and continues to iterate until the task is completed; after completing the task execution, intelligent agent 100 formats and integrates the final output of the large model and outputs it to the user; at the same time, it records the metadata such as the prompt word template, large model, execution time, call records, etc. used in the execution of the task as basic data for subsequent online learning and prompt optimization.

[0101] A third embodiment of the present invention provides a computer-readable storage medium storing a computer program. When the computer program is executed, the prompt word optimization method of the first embodiment of the present invention is implemented.

[0102] In the embodiments provided herein, it should be understood that "B corresponding to A" means that B is associated with A and B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B based solely on A; B can also be determined based on A and / or other information.

[0103] It should be understood that references to "one embodiment" or "an embodiment" throughout this specification mean that specific features, structures, or characteristics associated with the embodiment are included in at least one embodiment of the present invention. Therefore, the phrases "in one embodiment" or "in an embodiment" appearing throughout this specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. Those skilled in the art should also be aware that the embodiments described in this specification are all optional embodiments, and the actions and modules involved are not necessarily required for the present invention.

[0104] In various embodiments of the present invention, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0105] The flow charts and block diagrams in the accompanying drawings of the present invention illustrate the possible implementation architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementation schemes, the functions marked in the box can also occur in a different order than those marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which is determined based on the functions involved. It should be noted that each box in the block diagram and / or flow chart, the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.

[0106] Compared with the prior art, the prompt word optimization method, intelligent agent, and storage medium provided by the present invention have the following beneficial effects:

[0107] 1. An embodiment of the present invention provides a prompt word optimization method. By constructing multiple different prompt word instances based on multiple different prompt word templates and multiple task samples of different task types, and inputting each prompt word instance into multiple target macro models, a sufficient number of prompt word instances can be generated, avoiding optimization result limitations caused by insufficient data diversity and providing a base number guarantee for the subsequent screening of label prompt word templates that are compatible with each target macro model and each task type. Based on the output of the target macro model, multiple first prompt word templates obtained using a preset method have better performance. A first label and a second label are assigned to the first prompt word template to obtain a label 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 target macro model type corresponding to the first prompt word template. The dual labeling of the first label and the second label achieves structured and standardized output results of the prompt word optimization method, laying the foundation for providing a two-dimensional indexing mechanism for task type and macro model type. This dual labeling enables more convenient and rapid retrieval of the most matching prompt word template using the task type and macro model type, facilitating rapid and accurate matching of prompt word templates and supporting efficient operation of intelligent agents in dynamic scenarios with different task types and different macro models. Since each label prompt word template corresponds to an adapted task type and target large model type, 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 correspond to more adapted label prompt word templates, thereby avoiding compatibility issues caused by the mismatch between the fixed prompt word template and the large model type or task type.

[0108] 2. In the embodiments of the present invention, a closed-loop process of evaluating, iterating, re-evaluating, and iterating the prompt word template output results is used to continuously optimize the prompt word template. The evaluation phase provides a clear guide for iteration. By making targeted improvements based on the evaluation results, the first prompt word template that meets the preset conditions is gradually selected. Compared to single-shot optimization, the quality and applicability of the prompt word template are significantly improved. Determining whether to stop iteration based on preset conditions avoids wasted computing resources and balances optimization effectiveness and efficiency. Through a feedback-driven optimization mechanism, a prompt word template with excellent performance that matches the target macromodel and task instruction type is ultimately obtained.

[0109] 3. In the embodiment of the present invention, scoring is performed at the structural level, which can ensure the format standardization of the prompt word template output result. When the structural level is scored based on the output format accuracy, it is ensured that the model output conforms to the expected structure, which is convenient for the target large model to analyze; scoring is performed at the content level, which can ensure the effectiveness of task completion. When the content level is scored based on the task completion accuracy, it can ensure that the prompt word template truly and accurately helps the target large model complete the task, thereby improving the accuracy of task execution. By combining scoring at the structural level and the content level, a multi-dimensional evaluation is achieved, which can more accurately locate the problem type of the prompt word template, which is an unreasonable structure or inaccurate content, thereby providing a clear direction for subsequent iterative optimization and improving the efficiency of iterative optimization.

[0110] 4. The iterative process in the embodiment of the present invention forms a closed-loop optimization by feeding back the evaluation results, generating a new round of prompt word templates, and testing again to obtain the evaluation results. It no longer relies on manual adjustment of the prompt word templates, but uses the actual output feedback of the target large model to discover and repair problems in the interaction between the prompt word templates and the target large model, such as the target large model's preference for specific sentence patterns and the tendency to misjudge ambiguous instructions. The effect of the prompt word template is enhanced in a targeted manner based on the feedback evaluation results. Through the cumulative effect of multiple rounds of iterations, the quality of the prompt word template is gradually improved to ensure the adaptability and task completion of the specific prompt word template on the target large model, and finally obtain the first prompt word template set with excellent performance on the target large model.

[0111] 5. In the embodiments of the present invention, by rewriting and optimizing existing prompt word templates, improvements are achieved based on mature prompt word templates, thereby expanding the generation of prompt word template variants with more styles and strategies. By inputting generation instructions into the large model, the large model generates prompt word templates based on the generation instructions, fully utilizing the large model's generation capabilities to achieve new creations based on demand. Generation instructions can include structural output instructions and, combined with contextual information such as scene descriptions and task types, guide the large model to generate new prompt word templates that meet specifications, ensuring from the source that prompt words are suitable for specific tasks and framework requirements. The two prompt word template generation methods can be flexibly selected or used in combination, and can generate high-quality prompt word templates based on different task characteristics and optimization goals, improving the pertinence and effectiveness of prompt word template generation, while also enriching the source and diversity of prompt word templates.

[0112] 6. The large model for generating prompt word templates in the embodiments of the present invention, such as DeepSeek-V3, typically has stronger general generation capabilities and cross-domain migration capabilities, which can improve the flexibility of prompt word template generation. The large model for generating prompt words uses the target large model, which can avoid errors caused by cross-model migration and optimize the prompt word template based on its own training data distribution. The generated prompt word template also better meets the parsing standards of its own large model, thereby improving the stability of prompt word template generation. The large model for generating prompt word templates and the target large model for generating prompt word templates can be flexibly selected or used in combination. This can not only improve the diversity of prompt word template generation and solve the problem of limited adaptability of fixed template tasks, but also ensure the stable execution of diverse prompt word templates on the target large model. The generated prompt word templates are stable, flexible, and diverse, thereby better meeting the complex multi-model and multi-task requirements of the intelligent agent.

[0113] 7. In the embodiment of the present invention, each prompt word template is formatted before being input into the target large model. After the prompt word 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 operation after the prompt word instance is input, and the full-link data is stored in a structured manner. This is to ensure that the entire prompt word optimization process meets the single variable principle, and the difference in prompt word templates is used as the only variable to avoid interference from irrelevant variables. Different prompt word templates may have inconsistent formats, such as JSON structure differences and different natural language expression styles. These non-content differences may cause deviations in the output results of the target large model, such as format parsing errors and ambiguous instruction understanding. Through template formatting processing, all prompt word templates are unified into a preset format, such as filling placeholders, aligning structural requirements, embedding task content, and other formatting processes, to ensure that the only variable input into the target large model is the different content of the prompt word template rather than the format, so as to accurately screen out the first prompt word template in subsequent evaluations. Furthermore, different target large models may have different built-in execution processes. For example, some large models generate results directly, while others require step-by-step tool invocation. If large models execute the process, differences in output results may stem from the model execution logic. By enforcing the Thought-Action-Observation (TAO) closed-loop process—a standardized process of thinking, action, and observation feedback—the model execution process is fixed as a constant, ensuring that all large models follow the same reasoning framework when processing prompt words. By collecting and storing full-link data, including input template content, formatted parameters, records of each step in the TAO process, and final output results, and quantifying all variables in the large model's execution, it avoids variable confusion caused by missing data. Ultimately, each optimization ensures that only the prompt word template content is changed, while other factors that may affect the results, such as format, process, and data recording method, are fixed or standardized. This ensures that the improved performance of the first prompt word template is due to optimization of the prompt word template itself, rather than interference from irrelevant variables, thereby selecting a precisely adapted first prompt word template.

[0114] 8. An embodiment of the present invention further provides an intelligent agent, which has the same beneficial effects as the above-mentioned prompt word optimization method, and will not be described in detail here.

[0115] 9. In the embodiment of the present invention, by obtaining user task request information, judging the task type and identifying the type of large model to be called, the candidate prompt word template that best matches the task type and large model type can be accurately retrieved from the label prompt word template data set, and the screened candidate prompt word template can be dynamically adapted to the user task and the called model, forming a dual adaptation for task type and large model type, which can achieve fast and accurate matching of prompt word templates, improve the accuracy and effectiveness of large model responses, 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 task type, and can output high-quality results with the most matching prompt word template to meet the user's specific task requirements, significantly improving the generalization ability and execution effect of the intelligent agent in multi-model and multi-task scenarios, helping to build an intelligent agent with a higher level of intelligence, and can effectively support the efficient operation of the intelligent agent in dynamic scenarios with multiple models and multiple tasks.

[0116] 10. An embodiment of the present invention further provides a storage medium, which has the same beneficial effects as the above-mentioned prompt word optimization method, and will not be described in detail here.

[0117] The above is a detailed introduction to a prompt word optimization method, intelligent agent and storage medium disclosed in an embodiment of the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention. Any modifications, equivalent replacements and improvements made within the principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A prompt word optimization method, characterized in that: The following steps are involved: Acquire a prompt word template dataset and a task sample dataset, wherein the prompt word template dataset includes a plurality of different prompt word templates, and the task sample dataset includes a plurality of task samples 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 respectively; Based on the output result of the target large model, constructing a first prompt word template set using a preset method, 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 label prompt word template, wherein the first label represents the task type of the task sample corresponding to the first prompt word template; and the second label represents the type of the target large model input corresponding to the first prompt word template; The step of constructing a first prompt word template set based on the output result of the target large model using a preset method includes the following steps: Evaluating the output result corresponding to the prompt word template to obtain an evaluation result; performing an iterative operation on the prompt word template based on the evaluation result to obtain a new round of prompt word template evaluation results; Based on the evaluation results of the new round of prompt word templates, determine whether the new round of prompt word templates meet the preset conditions. If so, add the new round of prompt word templates to the first prompt word template set; if not, repeat the iterative operation on the new round of prompt word templates.

2. The method for optimizing prompt words according to claim 1, wherein: The step of evaluating the output result corresponding to the prompt word template includes the following steps: Scoring the output result corresponding to the prompt word template at the structural level and / or content level; The scoring at the structure level includes scoring based on the output format accuracy of the output result; and the scoring at the content level includes scoring based on the task completion accuracy of the output result.

3. The prompt word optimization method according to claim 1, wherein: The iterative operation on the prompt word template based on the evaluation result to obtain a new round of prompt word template evaluation results includes the following steps: Feeding back the evaluation results to the prompt word template generation model, and the prompt word template generation model generates a new round of prompt word templates based on the evaluation results; Constructing a new round of prompt word instances using the new round of prompt word templates and the corresponding task samples, and inputting the new round of prompt word instances into the target large model; The output results of the target large model are evaluated to obtain the new round of evaluation results.

4. The prompt word optimization method according to claim 1, wherein: The multiple different prompt word templates are generated by a large model, and the large model generates the multiple different prompt word templates including the following steps: rewriting and optimizing the existing prompt word template based on the large model to obtain the multiple different prompt word templates; And / or, a generation instruction is input into the large model, and the large model generates the prompt word template based on the generation instruction.

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

6. The prompt word optimization method according to claim 1, wherein: Each of the prompt word templates is subjected to template formatting processing before being input into the target macro model; and / or, after the prompt word instance is input into the target macro model, the target macro 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 word instance is input, and store the full-link data in a structured manner, wherein the output result includes the structured stored full-link data.

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

8. The intelligent agent according to claim 7, wherein: The generation of the input information includes the following steps: Get user task request information; Determine the task type corresponding to the user task request information, and identify the large model type called by the agent in response to the user task request information; Based on the task type and the large model type, a candidate prompt word template is retrieved from the dataset of the label prompt word templates; 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; The input information is obtained based on the user task request information and the candidate prompt word template.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed, the prompt word optimization method according to any one of claims 1 to 6 is implemented.

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