Prompt information optimization method and device, computer readable medium and electronic equipment

By using an automated optimization method based on language models to generate and filter multi-generational prompt messages, the problem of time-consuming and costly traditional manual optimization is solved, achieving efficient and stable prompt message optimization that is applicable to both terminals and servers.

CN121052384AActive Publication Date: 2025-12-02SHENZHEN KLOOK INTERNET TECHNOLOGY CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202511576123.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2025-12-02
Estimated Expiration
2045-10-31

AI Technical Summary

Technical Problem

Traditional message optimization relies on manual trial and error and experience, which is time-consuming, inefficient, and costly, making it difficult to achieve large-scale and systematic application.

Method used

By rewriting the initial prompts based on a predetermined language model, multiple first-generation prompts are generated. The optimization steps are repeated until the preset termination conditions are met. The target prompts are evaluated and filtered using performance scores, and the optimal prompt is finally selected.

Benefits of technology

It improves the efficiency of prompt message optimization, reduces costs and reliance on experience, enables large-scale and systematic application, reduces the possibility of getting trapped in local optima, and ensures the stability and accuracy of optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121052384A_ABST
    Figure CN121052384A_ABST
Patent Text Reader

Abstract

The invention provides a prompt information optimization method and device, a computer readable medium and electronic equipment, and the method comprises the steps: carrying out the rewriting of to-be-optimized initial prompt information based on a predetermined language model, and obtaining a plurality of pieces of first-generation prompt information; repeatedly executing the prompt information optimization step until a preset ending condition is met; the prompt information optimization step comprises the following steps: determining the performance score of each prompt information of the current generation; according to the performance score of each piece of current-generation prompt information, determining current-generation target prompt information in each piece of current-generation prompt information, and rewriting the current-generation target prompt information based on the predetermined language model to obtain a plurality of pieces of next-generation prompt information, re-executing the prompt information optimization step on the basis of the plurality of next-generation prompt information; and selecting final target prompt information from the target prompt information of each generation as an optimization result of the initial prompt information. According to the invention, the optimization efficiency of the prompt information is improved, and the optimization effect can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and more specifically, to a method, apparatus, computer-readable medium, and electronic device for optimizing prompting information. Background Technology

[0002] With the development of artificial intelligence technology, the optimization of prompt information has become a key technology for improving the output effect of models.

[0003] Traditional message optimization relies heavily on domain experts to conduct extensive manual trial and error adjustments. This method is not only time-consuming, inefficient, and costly, but also highly dependent on personal experience, making it difficult to scale up and systematically apply solutions. Summary of the Invention

[0004] The embodiments of this application provide a method, apparatus, computer-readable medium, and electronic device for optimizing prompt information, which at least to a certain extent improves the optimization efficiency of prompt information, reduces the optimization cost of prompt information and the reliance on personal experience, and can guarantee the optimization effect.

[0005] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.

[0006] According to one aspect of the embodiments of this application, a method for optimizing prompt information is provided. The method includes: rewriting initial prompt information to be optimized based on a predetermined language model to obtain multiple first-generation prompt information; repeatedly executing the prompt information optimization steps until a preset termination condition is met; the prompt information optimization steps include: determining the performance score of each prompt information of the current generation; wherein the performance score is used to measure the consistency between the output content generated by the prompt information guidance model and the expected target, and when the prompt information optimization steps are executed for the first time, the prompt information of the current generation is the first-generation prompt information; determining the target prompt information of the current generation from the prompt information of the current generation according to the performance score of each prompt information of the current generation; rewriting the target prompt information of the current generation based on the predetermined language model to obtain multiple next-generation prompt information, and re-executing the prompt information optimization steps based on the multiple next-generation prompt information; selecting the final target prompt information from the target prompt information of each generation as the optimization result of the initial prompt information.

[0007] According to one aspect of the embodiments of this application, a prompt information optimization apparatus is provided. The apparatus includes: a prompt information rewriting unit, configured to rewrite an initial prompt information to be optimized based on a predetermined language model to obtain a plurality of first-generation prompt information; a repetitive execution unit, configured to repeatedly execute the prompt information optimization steps until a preset termination condition is met; the prompt information optimization steps include: determining the performance score of each prompt information of the current generation; wherein the performance score is used to measure the consistency between the output content generated by the prompt information guidance model and the expected target, and when the prompt information optimization steps are executed for the first time, the prompt information of the current generation is the first-generation prompt information; determining the target prompt information of the current generation from the prompt information of the current generation according to the performance score of each prompt information of the current generation; rewriting the target prompt information of the current generation based on the predetermined language model to obtain a plurality of next-generation prompt information, so as to re-execute the prompt information optimization steps based on the plurality of next-generation prompt information; and a prompt information selection unit, configured to select the final target prompt information from the target prompt information of each generation as the optimization result of the initial prompt information.

[0008] In some embodiments of this application, based on the aforementioned scheme, the prompt information rewriting unit includes: a performance score determination subunit, used to determine the performance score of the initial prompt information to be optimized as a benchmark performance score; a rewriting subunit, used to input the initial prompt information to be optimized and the benchmark performance score into a predetermined language model, and the predetermined language model rewrites the initial prompt information to be optimized according to the benchmark performance score to obtain multiple first-generation prompt information; the repeated execution unit is configured to: input the current generation target prompt information and the performance score of the current generation target prompt information into the predetermined language model, and the predetermined language model rewrites the current generation target prompt information according to the performance score of the current generation target prompt information to obtain multiple next-generation prompt information.

[0009] In some embodiments of this application, based on the foregoing scheme, the device further includes a worst-case suggestion determination unit; before rewriting the target suggestion information of the current generation based on the predetermined language model, the worst-case suggestion determination unit is configured to: determine several worst-case suggestion information of the current generation among the suggestion information of the current generation according to the performance scores of each suggestion information of the current generation, wherein the performance score of the worst-case suggestion information is lower than the performance scores of other suggestion information of the current generation; the repeated execution unit is configured to: input the target suggestion information of the current generation and several worst-case suggestion information of the current generation into the predetermined language model, and have the predetermined language model rewrite the target suggestion information of the current generation according to the several worst-case suggestion information of the current generation to obtain multiple next-generation suggestion information.

[0010] In some embodiments of this application, based on the foregoing scheme, the performance score determination subunit includes: an information input module, used to input the initial prompt information to be optimized and the input text in the text pair into a benchmark language model, and the benchmark language model performs a target task on the input text based on the initial prompt information to be optimized to obtain the predicted text generated by the benchmark language model based on the input text, wherein the text pair includes the input text and the reference text corresponding to the input text; an indicator value determination module, used to determine the indicator value corresponding to at least one performance indicator based on the predicted text and the reference text, wherein the at least one performance indicator includes at least one of the following: semantic similarity, lexical overlap; and a score determination module, used to determine the performance score of the initial prompt information to be optimized according to the indicator value corresponding to each performance indicator.

[0011] In some embodiments of this application, based on the foregoing scheme, the information input module is configured to: for each text pair in the evaluation dataset, input the initial prompt information to be optimized and the input text in the text pair into a benchmark language model, and have the benchmark language model perform a target task on the input text based on the initial prompt information to be optimized, to obtain the predicted text generated by the benchmark language model based on the input text; the indicator value determination module is configured to: for each text pair in the evaluation dataset, determine an indicator value corresponding to at least one performance indicator based on the predicted text corresponding to the text pair and the reference text in the text pair; the score determination module is configured to: determine the performance score of the initial prompt information to be optimized based on the indicator values ​​corresponding to each performance indicator determined for each text pair in the evaluation dataset.

[0012] In some embodiments of this application, based on the aforementioned scheme, the prompt information selection unit is configured to: select the final target prompt information with the highest performance score from the target prompt information of each generation according to the performance score of the target prompt information of each generation, and use it as the optimization result of the initial prompt information.

[0013] In some embodiments of this application, based on the foregoing scheme, the preset termination condition includes at least one of the following: the prompt information optimization step has been completed for the prompt information of the predetermined number of generations; the difference between the performance score of the target prompt information of the current generation and the performance score of the target prompt information of the previous generation is less than a predetermined difference threshold.

[0014] According to one aspect of the embodiments of this application, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method for optimizing prompting information as described in the above embodiments.

[0015] According to one aspect of the embodiments of this application, an electronic device is provided, including: one or more processors; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the method for optimizing prompt information as described in the above embodiments.

[0016] According to one aspect of the embodiments of this application, a computer program product is provided, the computer program product including computer instructions stored in a computer-readable storage medium, a processor of a computer device reading the computer instructions from the computer-readable storage medium, and the processor executing the computer instructions, causing the computer device to perform the method for optimizing prompting information as described in the above embodiments.

[0017] In some embodiments of this application, the initial prompt information to be optimized is first rewritten based on a predetermined language model to obtain multiple first-generation prompt information. Then, the prompt information optimization steps are repeated until a preset termination condition is met. Since the target prompt information of the current generation is determined each time the prompt information optimization step is executed, the target prompt information of each generation can be determined. Finally, by selecting the final target prompt information from the target prompt information of each generation, the optimization result of the initial prompt information can be obtained. Therefore, this application provides a scheme for automatically optimizing prompts, which can significantly shorten the time required for optimizing prompts, improve the efficiency of prompt optimization, and reduce costs. Furthermore, it significantly reduces reliance on human experience and the threshold for optimizing prompts, enabling large-scale and systematic application. This application ensures the correctness of the optimization direction by directly evaluating the performance scores of each prompt in the current generation and selecting the target prompt from among the prompts in the current generation based on their performance scores. In addition, this application greatly improves the diversity of the exploration space and significantly reduces performance fluctuations by generating multiple rewritten prompts for each generation, rather than a single sample, enabling the stable and reliable finding of the globally optimal prompt.

[0018] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0020] Figure 1 A flowchart illustrating an optimization method for prompting information according to an embodiment of this application is shown.

[0021] Figure 2 A schematic flowchart of an optimization method for prompting information according to an embodiment of this application is shown.

[0022] Figure 3 A complete architecture diagram of a method for optimizing prompt information according to an embodiment of this application is shown.

[0023] Figure 4 A flowchart illustrating the determination of the performance score of the initial prompt information to be optimized according to one embodiment of this application is shown.

[0024] Figure 5 An embodiment according to this application is shown. Figure 1 The flowchart in the embodiment shows the steps before step 150 and the details of step 150.

[0025] Figure 6 An embodiment according to this application is shown. Figure 1 A flowchart detailing step 170 in the embodiment.

[0026] Figure 7 A block diagram of a prompt information optimization device according to an embodiment of this application is shown.

[0027] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation

[0028] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.

[0029] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.

[0030] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0031] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0032] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0033] As Large Language Models (LLMs) demonstrate their powerful capabilities across various fields of natural language processing, prompt engineering has become a key technique for effectively utilizing and controlling these models. A well-designed prompt can guide the model to produce more accurate and relevant outputs, while a poor-quality prompt can lead to a significant drop in model performance.

[0034] In related technologies, the optimization of prompt messages mainly relies on a lot of manual trial and error and adjustment by domain experts. This method is not only time-consuming, inefficient and costly, but also highly dependent on personal experience. The threshold for optimizing prompt messages is high, making it difficult to achieve large-scale and systematic application.

[0035] To address this, this application first provides a method for optimizing prompt information, which is essentially a method for configuring and executing rules. The optimization method for prompt information provided in this application's embodiments can overcome the above-mentioned shortcomings, improve the efficiency of prompt information optimization, reduce costs and reliance on human experience, and lower the threshold for optimizing prompt information, enabling scalable and systematic applications. Furthermore, it can systematically explore and discover higher-performing prompt information through multiple iterations. In addition, this application significantly improves the diversity of the generated next-generation prompt information by generating multiple rewritten prompts for each generation, reducing the possibility of getting trapped in local optima and avoiding problems such as large performance fluctuations and difficulty in stably converging to the global optimum.

[0036] Therefore, the embodiments of this application can be applied to terminals or servers. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. The terminal and server can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions.

[0037] The implementation details of the technical solutions in the embodiments of this application are described in detail below: Figure 1 A flowchart illustrating a method for optimizing prompt messages according to an embodiment of this application is shown. This method for optimizing prompt messages can be executed by various devices with processing and computing capabilities. Specifically, it can be executed by a target device, such as a user terminal or a cloud server. User terminals include, but are not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, smartwatches, etc. Please refer to... Figure 1 As shown, the method for optimizing this prompt message includes at least the following steps: In step 110, the initial prompt information to be optimized is rewritten based on a predetermined language model to obtain multiple first-generation prompt information.

[0038] The cue information, or cue words, is information used to tell the model "what you want it to do" or "how to generate content." The initial cue information to be optimized, or initial cue words, can include one or more of the following: task description, context, output format, constraints, and examples. The task description clarifies what the task is to do, such as summarizing or translating; the context provides background information such as the scenario; the output format specifies the structure of the answer, such as a list, JSON, or table; constraints can include length limits, tone, and content to avoid; and examples demonstrate the expected output.

[0039] A predefined language model can contain any number of language parameters, ranging from a billion to even more.

[0040] The predefined language model can be a high-level large language model with powerful reasoning capabilities, such as DeepSeek R1 or other reasoning models.

[0041] In this embodiment of the application, the initial prompt information to be optimized is rewritten using an inference model.

[0042] In one embodiment of this application, before rewriting the initial prompt information to be optimized based on a predetermined language model, the method for optimizing the prompt information further includes: obtaining basic parameters of the prompt information optimization task, wherein the basic parameters include the initial prompt information to be optimized and at least one of the following: an evaluation dataset for evaluating the performance score of the prompt information, the number of iterations N, and the number of variants K to be generated in each generation.

[0043] In this context, the iteration number N determines the total number of optimization rounds, which can be set between 5 and 10; the number of variants, i.e., the number of hints (hint word variants) generated in each generation, determines the breadth of exploration in each round, and the number of variants is generally chosen to be 5-15. The evaluation dataset can include multiple text pairs, each text pair can include input text and a corresponding reference text, where the input text can be question information, and the corresponding reference text can be standard answer information corresponding to the question information.

[0044] Figure 2 A schematic flowchart illustrating an optimization method for prompting information according to an embodiment of this application is shown. Please refer to... Figure 2 As shown, the overall process of optimizing this prompt message can include the following steps: Step 210, initialize parameter settings.

[0045] The initialization parameters are the basic parameters of the aforementioned prompt message optimization task. Users can customize the basic parameters of the prompt message optimization task in the system.

[0046] Figure 3 A complete architecture diagram of a method for optimizing prompt information according to an embodiment of this application is shown. Please refer to... Figure 3 As shown, first, the initial prompt word optimization process is executed, which first obtains the initial prompt words.

[0047] In one embodiment of this application, the step of rewriting the initial prompt information to be optimized based on a predetermined language model to obtain multiple first-generation prompt information includes: determining the performance score of the initial prompt information to be optimized as a benchmark performance score; inputting the initial prompt information to be optimized and the benchmark performance score into a predetermined language model, and having the predetermined language model rewrite the initial prompt information to be optimized according to the benchmark performance score to obtain multiple first-generation prompt information.

[0048] The baseline performance score is used to measure the degree of consistency between the output generated by the model guided by the initial prompts and the expected target.

[0049] The performance score of the initial prompt information to be optimized can be determined by model scoring, or it can be determined based on human scoring standards (such as manual scoring by relevant personnel according to human scoring standards).

[0050] In this embodiment of the application, when rewriting the initial prompt information, not only is the initial prompt information to be optimized itself input into the predetermined language model, but also the benchmark performance score obtained by evaluating the initial prompt information to be optimized is input into the predetermined language model. This allows the large model to understand the current benchmark quantification level, thereby making more scientific, reasonable and gradual optimizations, which can improve the effect of rewriting the initial prompt information.

[0051] In one embodiment of this application, inputting the initial prompt information to be optimized and the benchmark performance score into a predetermined language model includes: embedding the initial prompt information to be optimized and the benchmark performance score into a preset instruction template to obtain prompt text, wherein the prompt text is used to instruct the model to generate a preset number of different, possibly better, new versions of prompt information; and inputting the prompt text into the predetermined language model.

[0052] The prompt text can be obtained by populating or adding the initial prompt message to be optimized and the benchmark performance score to a preset instruction template. The prompt text or the preset instruction template can include information to instruct the model to generate a preset number of different, potentially better, new versions of the prompt message. The preset number is the aforementioned number of variants K, which can be between 5 and 15.

[0053] Figure 4A flowchart illustrating the performance score for determining the initial prompt information to be optimized, according to one embodiment of this application, is shown. See also... Figure 4 As shown, determining the performance score of the initial prompt information to be optimized can specifically include the following steps: In step 410, the initial prompt information to be optimized and the input text in the text pair are input into the benchmark language model. The benchmark language model performs the target task on the input text based on the initial prompt information to be optimized, and obtains the predicted text generated by the benchmark language model based on the input text. The text pair includes the input text and the reference text corresponding to the input text.

[0054] The baseline language model can be any type of large language model or multimodal model. The baseline language model can be the same as or different from the aforementioned predefined language model. To save costs, the baseline language model can have fewer parameters and lower performance than the predefined language model; for example, the baseline language model can be a model whose usage cost is only one-sixth or one-seventh of that of the predefined language model.

[0055] The initial prompts to be optimized are prompts used to guide the model to perform the target task, and they can correspond to the target task.

[0056] The target task can be a question-and-answer task, a translation task, etc.

[0057] When the target task is a question-and-answer task, the initial prompt information to be optimized corresponds to the question-and-answer task. The input text in the text pair can be the question information, and the reference text corresponding to the input text can be the standard answer information corresponding to the question information.

[0058] When the target task is a translation task, the initial prompt information to be optimized corresponds to the translation task. The input text in the text pair can be the text to be translated, and the reference text corresponding to the input text can be the standard translation result corresponding to the text to be translated.

[0059] In one embodiment of this application, the step of inputting the initial prompt information to be optimized and the input text in the text pair into a benchmark language model, and having the benchmark language model perform a target task on the input text based on the initial prompt information to be optimized, to obtain the predicted text generated by the benchmark language model based on the input text, includes: for each text pair in the evaluation dataset, inputting the initial prompt information to be optimized and the input text in the text pair into a benchmark language model, and having the benchmark language model perform a target task on the input text based on the initial prompt information to be optimized, to obtain the predicted text generated by the benchmark language model based on the input text.

[0060] The evaluation dataset can include multiple text pairs corresponding to the target task; for each text pair in the evaluation dataset, a reference text in the text pair and a predicted text generated by the benchmark language model based on the input text in the text pair can be obtained.

[0061] In step 420, at least one performance indicator value is determined based on the predicted text and the reference text. The at least one performance indicator includes at least one of the following: semantic similarity and lexical overlap.

[0062] At least one performance metric may include only semantic similarity, only word overlap, or both semantic similarity and word overlap.

[0063] In specific applications of this application, the semantic similarity metric can be replaced by two performance metrics: a basic semantic similarity metric and a more "fair" or "balanced" semantic similarity metric.

[0064] Therefore, at least one performance metric should include one or more of the following: basic semantic similarity metric, a more “fair” or “balanced” semantic similarity metric, and word overlap.

[0065] The basic semantic similarity metric can be BERT-Score, or BERT Score-Recall(R), which measures the degree to which information in the reference text is covered by the predicted text. It can be calculated through the following process: divide the reference text and the predicted text into tokens; obtain the context embedding vector of each token using the BERT model; calculate the cosine similarity between each token in the reference text and all tokens in the predicted text based on the context embedding vector, and obtain a similarity matrix; for each token in the reference text, find the maximum similarity value of the predicted text token that is most similar to that token in the reference text based on the similarity matrix; average the maximum similarity values ​​of all tokens in the reference text to obtain BERT Score-Recall(R).

[0066] Specifically, a more "fair" or "balanced" semantic similarity metric could be BERTScore-F1, which can be calculated based on BERTScore-Recall(R) and BERTScore-Precision(P). BERTScore-Precision(P) measures the degree to which words in the predicted text are semantically covered by the reference text. BERTScore-F1 can be the harmonic mean of BERTScore-Recall(R) and BERTScore-Precision(P).

[0067] BERTScore-Precision(P) can be calculated as follows: Divide the reference text and the predicted text into tokens; obtain the context embedding vector for each token using the BERT model; calculate the cosine similarity between each token in the predicted text and all tokens in the reference text based on the context embedding vectors, resulting in a similarity matrix; for each token in the predicted text, find the maximum similarity value of the reference text token that is most similar to that token in the predicted text based on the similarity matrix; average the maximum similarity values ​​of all tokens in the predicted text to obtain BERTScore-Precision(P).

[0068] BERTScore-F1 can be calculated using the following formula: BERTScore-F1= .

[0069] Lexical overlap can be measured by BLEU, which measures how many of the same words or phrases are used in two texts.

[0070] In one embodiment of this application, determining the index value corresponding to at least one performance index based on the predicted text and the reference text includes: for each text pair in the evaluation dataset, determining the index value corresponding to at least one performance index based on the predicted text corresponding to the text pair and the reference text in the text pair.

[0071] For each text pair in the evaluation dataset, a metric value corresponding to each performance metric can be calculated.

[0072] In step 430, the performance score of the initial prompt information to be optimized is determined based on the index values ​​corresponding to each performance index.

[0073] Based on the weights corresponding to each performance metric, a weighted sum of the metric values ​​can be calculated as the initial performance score for the prompt information to be optimized. The weights corresponding to each performance metric can be set as needed.

[0074] In one embodiment of this application, determining the performance score of the initial prompt information to be optimized based on the index values ​​corresponding to each performance index includes: determining the performance score of the initial prompt information to be optimized based on the index values ​​corresponding to each performance index determined for each text pair in the evaluation dataset.

[0075] In one embodiment of this application, determining the performance score of the initial prompt information to be optimized based on the index values ​​corresponding to each performance index determined for each text pair in the evaluation dataset includes: for each text pair in the evaluation dataset, determining the performance sub-score corresponding to the initial prompt information and the text pair based on the index values ​​corresponding to each performance index determined for the text pair; and determining the performance score of the initial prompt information to be optimized based on the performance sub-scores corresponding to the initial prompt information and each text pair.

[0076] The performance score of the initial prompt message to be optimized can be obtained by averaging the performance sub-scores of the initial prompt message and each text pair.

[0077] Specifically, BLEURT can be used as the scoring standard, and the performance score BLEURT can be calculated using the following formula:

[0078] in, This represents the i-th predicted text. This represents the i-th reference text. This represents the total number of samples in the evaluation dataset. express and Lexical overlap between express and The basic semantic similarity between them express and A more "fair" or "balanced" semantic similarity between them. , These are the weighting coefficients for each item, and + =1.

[0079] Please continue reading Figure 2 As shown, after step 210, the following steps may also be included: Step 220, Initial prompt word performance evaluation.

[0080] The performance score of the initial prompt words is evaluated.

[0081] Step 230, first-generation variant generation.

[0082] The initial prompt words and benchmark performance scores are input into a predefined language model, which then generates the first generation of prompt word variants.

[0083] Please continue reading Figure 3As shown, during the initial prompt optimization process, initial evaluation results for the initial prompts are also obtained. The initial prompts and initial evaluation results can be provided to the prompt optimizer, which generates multiple prompt variants for the first generation. The prompt optimizer can be any language model, such as the aforementioned predefined language model.

[0084] Next, the prompt message optimization steps need to be repeated until the preset termination conditions are met. The prompt message optimization steps may include steps 120-150.

[0085] In step 120, the performance score of each prompt message in the current generation is determined; wherein, the performance score is used to measure the degree of consistency between the output content generated by the prompt message-guided model and the expected target, and when the prompt message optimization step is executed for the first time, the prompt message of the current generation is the first generation prompt message.

[0086] For each prompt in the current generation, its performance score is evaluated using the same method as the method used to determine the performance score of the initial prompt to be optimized. That is, compared to the method used to determine the performance score of the initial prompt, the same model can be used for scoring to determine the performance score of each prompt in the current generation; the same human scoring standard can be used; or a benchmark language model and the same evaluation dataset can be used to determine the performance score of each prompt in the current generation.

[0087] Please continue reading Figure 2 As shown, after step 230, the following steps may also be included: Step 240, Variant performance evaluation.

[0088] Determine the performance scores of K first-generation cue word variants.

[0089] Please continue reading Figure 3 As shown, after obtaining the K cue word variants of the first generation, the evaluation results corresponding to each cue word variant will be obtained.

[0090] In step 130, the target prompt information for the current generation is determined from among the prompt information of the current generation based on the performance scores of each prompt information of the current generation.

[0091] The performance score is the performance evaluation value.

[0092] Determining the target prompt message for the current generation based on the performance scores of each prompt message in the current generation can include: determining the prompt message with the highest performance score among all prompt messages in the current generation, and using it as the target prompt message for the current generation.

[0093] Of course, multiple target prompts for the current generation can also be identified.

[0094] It can also select prompts with performance scores higher than a predetermined score threshold as target prompts for the current generation based on the performance scores of each prompt in the current generation. Alternatively, it can select a predetermined number or percentage of prompts with the highest performance scores from among the prompts in the current generation as target prompts for the current generation.

[0095] Specifically, the target hint information for the current generation can be determined using the following formula:

[0096] in, Representing the current generation, This is the i-th prompt message of the current generation. for Performance scores (such as BLEURT scores). Used to determine the prompt with the highest performance score from the prompts in the current generation.

[0097] Please continue reading Figure 2 As shown, after step 240, the following steps may also be included: Step 250, optimal variant selection.

[0098] The best-performing cue word variant was identified from among K first-generation cue word variants.

[0099] Please continue reading Figure 3 As shown, after obtaining the evaluation results for each variant of the first generation prompt word, variant selection is performed based on the evaluation results to obtain the optimal first generation prompt word and the optimal evaluation result.

[0100] Figure 5 An embodiment according to this application is shown. Figure 1 A flowchart detailing the steps preceding step 150 and step 150 itself is provided in this embodiment. Please refer to [link / reference needed]. Figure 5 As shown, before rewriting the target prompt information of the current generation based on the predetermined language model, the method may include the following steps: In step 140, based on the performance scores of each prompt message in the current generation, several worst prompt messages in the current generation are determined, wherein the performance score of the worst prompt messages is lower than the performance scores of other prompt messages in the current generation.

[0101] A specified number of the lowest-performing prompts from the current generation's prompts can be selected as the worst-performing prompts for that generation. The performance score of these worst-performing prompts is also lower than the performance score of the target prompts for the current generation.

[0102] The specified quantity can be 1 or 2, or other quantities.

[0103] In step 150, the target prompt information of the current generation is rewritten based on the predetermined language model to obtain multiple prompt information of the next generation, so as to re-execute the prompt information optimization step based on the multiple prompt information of the next generation.

[0104] The target prompt information for the current generation can be rewritten in the same way as the initial prompt information to be optimized.

[0105] Please see Figure 5 As shown, rewriting the target prompt information of the current generation based on the predetermined language model to obtain multiple next-generation prompt information may include the following steps: In step 150', the target hint information of the current generation and several worst-case hint information of the current generation are input into a predetermined language model. The predetermined language model rewrites the target hint information of the current generation according to the several worst-case hint information of the current generation to obtain hint information of multiple next generations.

[0106] In this embodiment, by inputting several worst-case scenarios from the current generation when rewriting the target hints, and using them as "negative feedback" cases, the generation direction of the next generation can be better guided, avoiding the shortcomings of the worst-case scenarios. Conversely, the target hints from the current generation can serve as "positive feedback" cases, guiding the positive aspects of the target hints in the next generation. In this way, the inference model can retain the advantages of the optimal variant, avoid past mistakes, and continue to explore diverse possibilities, generating a new generation of K variants.

[0107] In one embodiment of this application, the step of rewriting the target prompt information of the current generation based on the predetermined language model to obtain multiple next-generation prompt information includes: inputting the target prompt information of the current generation and the performance score of the target prompt information of the current generation into the predetermined language model, and having the predetermined language model rewrite the target prompt information of the current generation according to the performance score of the target prompt information of the current generation to obtain multiple next-generation prompt information.

[0108] When rewriting the target message for the current generation, you can also input the corresponding performance score, just like you would when rewriting the initial message for optimization.

[0109] The target hint information of the current generation, the performance score of the target hint information of the current generation, several worst hint information of the current generation, and the performance scores of each worst hint information of the current generation can be input into a predetermined language model, which will then rewrite the code based on all the information input into it.

[0110] Please continue reading Figure 2 As shown, after step 250, the following steps may also be included: Step 260, generation of the next-generation variant.

[0111] Generate the next generation of cue word variants based on the optimal cue word variants.

[0112] Please continue reading Figure 3 As shown, after obtaining the optimal first-generation prompt word and the optimal evaluation result, multiple second-generation prompt word variants will be generated based on the prompt word optimizer.

[0113] For each of the next generation of prompts, the performance score needs to be recalculated when re-executing the prompt optimization steps.

[0114] The newly generated prompt words can be calculated using the following formula. In evaluating the dataset The average score on the platform is used as the performance score for that prompt word:

[0115] in, The prompt words generated in generation t+1 The performance score, This indicates that the performance score is based on This overall indicator is calculated. To evaluate the dataset, To evaluate the number of text pairs in the dataset, It evaluates the j-th text pair in the dataset.

[0116] In step 160, it is determined whether the preset termination condition is met.

[0117] Determine whether the current condition for termination is met. If yes, proceed to step 170. If no, return to step 120 and repeat step 120 and subsequent steps.

[0118] In one embodiment of this application, the preset termination condition includes at least one of the following: the prompt information optimization step has been completed for the prompt information of a predetermined number of generations; the difference between the performance score of the target prompt information of the current generation and the performance score of the target prompt information of the previous generation is less than a predetermined difference threshold.

[0119] The prompt message optimization step has been completed for the prompt message of the predetermined number of generations, meaning the target prompt message for the predetermined number of generations has been determined. The predetermined number of generations is the Nth generation.

[0120] The difference between the performance score of the current generation of target prompt information and the performance score of the previous generation of target prompt information being less than a predetermined difference threshold can also be expressed as the absolute value of the difference between the performance score of the current generation of target prompt information and the performance score of the previous generation of target prompt information being less than a predetermined difference threshold.

[0121] The preset termination condition can include both of the above conditions simultaneously.

[0122] The pre-defined termination condition, or convergence condition, can be defined as:

[0123] in, It is a very small convergence threshold (e.g., 0.001). It is the maximum iterative algebra. It is the performance score of the optimal cue word variant in generation t.

[0124] Of course, the preset termination condition can also include other content. For example, the preset termination condition can include the absolute value of the difference between the performance score of the current generation's target prompt information and the average or maximum value of the performance scores of the target prompt information of all historical generations being less than a predetermined difference threshold.

[0125] Please continue reading Figure 2 As shown, after generating the next generation of prompt word variants, the following steps are performed: Step 270, iterative optimization process.

[0126] The above prompt word optimization process is executed iteratively.

[0127] Please continue reading Figure 3 As shown, after generating multiple next-generation cue word variants, the next-generation cue word optimization process is performed.

[0128] Please continue reading Figure 1 In step 170, the final target prompt information is selected from the target prompt information of each generation as the optimization result of the initial prompt information.

[0129] After selecting the final target prompt information, the final target prompt information and its corresponding performance score can be output.

[0130] The target prompt information of the last generation can be used as the final target prompt information. Alternatively, one can be selected from the target prompt information whose performance score is higher than a predetermined score threshold as the final target prompt information. Or, one can be selected from the target prompt information with the highest predetermined number or predetermined proportion of performance scores as the final target prompt information.

[0131] Figure 6 An embodiment according to this application is shown. Figure 1 A flowchart detailing step 170 in the embodiment is provided. Please refer to [link / reference]. Figure 6 As shown, selecting the final target prompt information from the target prompt information of each generation as the optimization result of the initial prompt information may include the following steps: In step 170', based on the performance scores of the target prompt information of each generation, the final target prompt information with the highest performance score is selected from the target prompt information of each generation as the optimization result of the initial prompt information.

[0132] Please continue reading Figure 2 After completing the iterative optimization process, the following steps can be performed: Step 280, output the optimal result.

[0133] After all N generations of iterations are completed, the performance scores of the "best individual" in each generation are compared, and the prompt word with the highest score is selected as the final result of the entire optimization process. Finally, the system outputs this globally optimal prompt word and its final performance evaluation result.

[0134] Please continue reading Figure 3 After completing the Nth generation of prompt word optimization, the final optimal prompt word will be selected from the optimal prompt words of the Nth generation and output.

[0135] In summary, the method for optimizing prompts provided in this application constructs an automatic, efficient, and locally optimal prompt optimization framework. This framework not only directly evaluates the performance scores of each prompt in the current generation and selects the target prompt from among them based on these scores, reducing the possibility of deviation from the optimization direction and ensuring its correctness, but also significantly increases the diversity of the exploration space by generating multiple rewritten prompts for each generation instead of a single sample. This reduces the possibility of premature convergence and getting trapped in local optima, significantly reducing performance fluctuations and ensuring a stable and reliable search for the globally optimal prompt.

[0136] The following describes an embodiment of the apparatus described in this application, which can be used to execute the method for optimizing the prompting information in the above embodiments of this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method for optimizing the prompting information described above.

[0137] Figure 7 A block diagram of a prompt information optimization device according to an embodiment of this application is shown. (Refer to...) Figure 7 As shown, a prompt information optimization device 700 according to an embodiment of this application includes: a prompt information rewriting unit 710, a repeat execution unit 720, and a prompt information selection unit 730. The system includes a prompt information rewriting unit 710, which rewrites the initial prompt information to be optimized based on a predetermined language model to obtain multiple first-generation prompt information; a repetitive execution unit 720, which repeatedly executes the prompt information optimization steps until a preset termination condition is met; the prompt information optimization steps include: determining the performance score of each prompt information in the current generation; wherein the performance score is used to measure the consistency between the output content generated by the prompt information-guided model and the expected target, and when the prompt information optimization steps are executed for the first time, the prompt information in the current generation is the first-generation prompt information; determining the target prompt information of the current generation from the prompt information in the current generation based on the performance score of each prompt information in the current generation; rewriting the target prompt information of the current generation based on the predetermined language model to obtain multiple next-generation prompt information, and re-executing the prompt information optimization steps based on the multiple next-generation prompt information; and a prompt information selection unit 730, which selects the final target prompt information from the target prompt information of each generation as the optimization result of the initial prompt information.

[0138] In some embodiments of this application, based on the aforementioned scheme, the prompt information rewriting unit 710 includes: a performance score determination subunit, used to determine the performance score of the initial prompt information to be optimized as a baseline performance score; a rewriting subunit, used to input the initial prompt information to be optimized and the baseline performance score into a predetermined language model, and the predetermined language model rewrites the initial prompt information to be optimized according to the baseline performance score to obtain multiple first-generation prompt information; and a repeat execution unit 720 configured to: input the current generation target prompt information and the performance score of the current generation target prompt information into the predetermined language model, and the predetermined language model rewrites the current generation target prompt information according to the performance score of the current generation target prompt information to obtain multiple next-generation prompt information.

[0139] In some embodiments of this application, based on the foregoing scheme, the device further includes a worst-case suggestion determination unit; before rewriting the target suggestion information of the current generation based on the predetermined language model, the worst-case suggestion determination unit is configured to: determine several worst-case suggestion information of the current generation among the various suggestion information of the current generation according to the performance scores of each suggestion information of the current generation, wherein the performance score of the worst-case suggestion information is lower than the performance scores of other suggestion information of the current generation; the repeat execution unit 720 is configured to: input the target suggestion information of the current generation and several worst-case suggestion information of the current generation into the predetermined language model, and have the predetermined language model rewrite the target suggestion information of the current generation according to the several worst-case suggestion information of the current generation to obtain multiple next-generation suggestion information.

[0140] In some embodiments of this application, based on the foregoing scheme, the performance score determination subunit includes: an information input module, used to input the initial prompt information to be optimized and the input text in the text pair into a benchmark language model, and the benchmark language model performs a target task on the input text based on the initial prompt information to be optimized to obtain the predicted text generated by the benchmark language model based on the input text, wherein the text pair includes the input text and the reference text corresponding to the input text; an indicator value determination module, used to determine the indicator value corresponding to at least one performance indicator based on the predicted text and the reference text, wherein the at least one performance indicator includes at least one of the following: semantic similarity, lexical overlap; and a score determination module, used to determine the performance score of the initial prompt information to be optimized according to the indicator value corresponding to each performance indicator.

[0141] In some embodiments of this application, based on the foregoing scheme, the information input module is configured to: for each text pair in the evaluation dataset, input the initial prompt information to be optimized and the input text in the text pair into a benchmark language model, and have the benchmark language model perform a target task on the input text based on the initial prompt information to be optimized, to obtain the predicted text generated by the benchmark language model based on the input text; the indicator value determination module is configured to: for each text pair in the evaluation dataset, determine an indicator value corresponding to at least one performance indicator based on the predicted text corresponding to the text pair and the reference text in the text pair; the score determination module is configured to: determine the performance score of the initial prompt information to be optimized based on the indicator values ​​corresponding to each performance indicator determined for each text pair in the evaluation dataset.

[0142] In some embodiments of this application, based on the aforementioned scheme, the prompt information selection unit 730 is configured to: select the final target prompt information with the highest performance score from the target prompt information of each generation according to the performance score of the target prompt information of each generation, and use it as the optimization result of the initial prompt information.

[0143] In some embodiments of this application, based on the foregoing scheme, the preset termination condition includes at least one of the following: the prompt information optimization step has been completed for the prompt information of the predetermined number of generations; the difference between the performance score of the target prompt information of the current generation and the performance score of the target prompt information of the previous generation is less than a predetermined difference threshold.

[0144] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown.

[0145] It should be noted that, Figure 8 The computer system 800 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0146] like Figure 8 As shown, the computer system 800 includes a CPU 801, which can perform various appropriate actions and processes according to a program stored in ROM 802 or a program loaded into RAM 803 from storage portion 808, such as performing the methods described in the above embodiments. The RAM 803 also stores various programs and data required for system operation. The CPU 801, ROM 802, and RAM 803 are interconnected via bus 804. An I / O interface 805 is also connected to bus 804.

[0147] The following components are connected to I / O interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to I / O interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 810 as needed so that computer programs read from it can be installed into storage section 808 as needed.

[0148] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by CPU 801, it performs various functions defined in the system of this application.

[0149] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0150] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0151] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.

[0152] In one aspect, this application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods described in the above embodiments.

[0153] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0154] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the methods according to the embodiments of this application.

[0155] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.

[0156] The data collection and processing plan outlined in this application must be implemented in strict accordance with the requirements of relevant national laws and regulations, obtaining the informed consent or separate consent of the data subject (or having a legal basis as stipulated by the relevant national laws and regulations), and conducting subsequent data use and processing within the scope authorized by laws and regulations and the data subject.

[0157] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A method for optimizing prompt information, characterized in that, The method includes: The initial prompt information to be optimized is rewritten based on the predetermined language model to obtain multiple first-generation prompt information; Repeat the prompt information optimization steps until a preset termination condition is met; the prompt information optimization steps include: determining the performance score of each prompt information in the current generation; wherein, the performance score is used to measure the consistency between the output content generated by the prompt information-guided model and the expected target, and when the prompt information optimization steps are executed for the first time, the prompt information of the current generation is the first generation prompt information; based on the performance score of each prompt information in the current generation, determine the target prompt information of the current generation from the prompt information of the current generation; rewrite the target prompt information of the current generation based on the predetermined language model to obtain multiple next-generation prompt information, and re-execute the prompt information optimization steps based on the multiple next-generation prompt information; The final target prompt information is selected from the target prompt information of each generation and used as the optimization result of the initial prompt information.

2. The method for optimizing prompt information according to claim 1, characterized in that, The initial prompt information to be optimized is rewritten based on a predetermined language model to obtain multiple first-generation prompt information, including: Determine the performance score of the initial prompt message to be optimized, and use it as the baseline performance score; The initial prompt information to be optimized and the benchmark performance score are input into a predetermined language model. The predetermined language model rewrites the initial prompt information to be optimized according to the benchmark performance score to obtain multiple first-generation prompt information. The current generation's target prompt information is rewritten based on the predetermined language model to obtain multiple next-generation prompt information, including: The target hint information of the current generation and its performance score are input into a predetermined language model. The predetermined language model then rewrites the target hint information of the current generation based on its performance score to obtain multiple next-generation hint information.

3. The method for optimizing prompt information according to claim 1, characterized in that, Before rewriting the target prompt information of the current generation based on the predetermined language model, the method further includes: Based on the performance scores of each prompt message in the current generation, several worst prompt messages in the current generation are identified, wherein the performance score of the worst prompt messages is lower than the performance scores of other prompt messages in the current generation. The current generation's target prompt information is rewritten based on the predetermined language model to obtain multiple next-generation prompt information, including: The target hint information of the current generation and several worst-case hint information of the current generation are input into a predetermined language model. The predetermined language model rewrites the target hint information of the current generation according to the several worst-case hint information of the current generation to obtain hint information of multiple next generation generations.

4. The method for optimizing prompt information according to claim 2, characterized in that, The process of determining the performance score of the initial prompt information to be optimized includes: The initial prompt information to be optimized and the input text in the text pair are input into the benchmark language model. The benchmark language model performs the target task on the input text based on the initial prompt information to be optimized, and obtains the predicted text generated by the benchmark language model based on the input text. The text pair includes the input text and the reference text corresponding to the input text. Based on the predicted text and the reference text, at least one performance indicator value is determined, wherein the at least one performance indicator includes at least one of the following: semantic similarity and word overlap. Based on the corresponding index values ​​of each performance indicator, determine the performance score of the initial prompt information to be optimized.

5. The method for optimizing prompt information according to claim 4, characterized in that, The process of inputting the initial prompt information to be optimized and the input text in the text pair into a baseline language model, and having the baseline language model perform a target task on the input text based on the initial prompt information to be optimized, to obtain the predicted text generated by the baseline language model based on the input text, includes: For each text pair in the evaluation dataset, the initial prompt information to be optimized and the input text in the text pair are input into the benchmark language model. The benchmark language model performs the target task on the input text based on the initial prompt information to be optimized, and obtains the predicted text generated by the benchmark language model based on the input text. Determining the value of at least one performance metric based on the predicted text and the reference text includes: For each text pair in the evaluation dataset, determine the index value corresponding to at least one performance index based on the predicted text corresponding to the text pair and the reference text in the text pair. The step of determining the performance score of the initial prompt information to be optimized based on the index values ​​corresponding to each performance index includes: Based on the index values ​​corresponding to each performance metric determined for each text pair in the evaluation dataset, the performance score of the initial prompt information to be optimized is determined.

6. The method for optimizing prompt information according to claim 1, characterized in that, The step of selecting the final target prompt information from the target prompt information of each generation as the optimization result of the initial prompt information includes: Based on the performance scores of the target prompt information of each generation, the final target prompt information with the highest performance score is selected from the target prompt information of each generation as the optimization result of the initial prompt information.

7. The method for optimizing prompt information according to any one of claims 1-6, characterized in that, The preset termination condition includes at least one of the following: the prompt information optimization step has been completed for the prompt information of the predetermined number of generations; the difference between the performance score of the target prompt information of the current generation and the performance score of the target prompt information of the previous generation is less than a predetermined difference threshold.

8. An optimization device for prompting information, characterized in that, The device includes: The prompt message rewriting unit is used to rewrite the initial prompt message to be optimized based on a predetermined language model to obtain multiple first-generation prompt messages; A repetitive execution unit is used to repeatedly execute the prompt information optimization steps until a preset termination condition is met. The prompt information optimization steps include: determining the performance score of each prompt information in the current generation; wherein the performance score is used to measure the consistency between the output content generated by the prompt information-guided model and the expected target; when the prompt information optimization steps are executed for the first time, the prompt information in the current generation is the first generation prompt information; determining the target prompt information of the current generation from the prompt information in the current generation based on the performance score of each prompt information in the current generation; rewriting the target prompt information of the current generation based on the predetermined language model to obtain multiple next-generation prompt information, and re-executing the prompt information optimization steps based on the multiple next-generation prompt information. The prompt information selection unit is used to select the final target prompt information from the target prompt information of each generation, as the optimization result of the initial prompt information.

9. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for optimizing the prompt information as described in any one of claims 1 to 7.

10. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the method for optimizing the prompt information as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Automatic optimization method and device for cue word, equipment and storage medium

    CN117520507A

  • Named entity identification method, device and equipment

    CN117574906A

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

    CN119180351A

  • Information processing method and device, product and equipment

    CN119670759A

  • Data processing method, device and equipment and readable storage medium

    CN120597877A