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

The method automates prompt word optimization in LLMs by using feedback to identify and iteratively refine prompt words, addressing inefficiencies in existing methods and improving model output accuracy and efficiency.

CN119226476APending Publication Date: 2024-12-31PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 14 Cited by

Patent Information

Application Number
CN202411363585.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

Current methods for optimizing model prompts in large language models (LLMs) are laborious, require deep understanding of the model's internal mechanisms, and lack computational efficiency, especially when using pre-trained black-box models.

Method used

A method for automatically optimizing model prompt words using feedback prompt words to identify defects in initial prompt words, followed by iterative optimization through techniques like random sampling, genetic algorithms, and beam search to generate high-quality target prompt words.

Benefits of technology

Reduces the manual effort in prompt optimization, enhances accuracy and consistency of model output, and improves computational efficiency by iteratively refining prompt words based on feedback mechanisms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226476A_ABST
    Figure CN119226476A_ABST
Patent Text Reader

Abstract

The invention relates to an automatic optimization method for a model cue word, which comprises the following steps of: acquiring an initial cue word and a corresponding training data set which comprises input data and a corresponding real label; and then, inputting the initial cue word and the input data into a target model together to generate a corresponding prediction label. And on the basis, guiding a target model by using a feedback prompt word, and generating language prompt feedback by comparing the predicted tag with the real tag. The feedback is used for identifying potential defects in the initial cue word, optimizing the initial cue word based on the feedback, and finally generating a target cue word. The cumbersome process of manually adjusting the cue words is reduced, gradual improvement of the cue words is achieved through a feedback mechanism, and high accuracy and consistency of model output are ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a method, device, equipment and storage medium for automatic optimization of model prompt words. Background Art

[0002] Large language models (LLMs) have demonstrated their power as general-purpose agents in a variety of tasks, capable of handling complex tasks such as natural language understanding, generation, and reasoning. However, the performance of LLMs relies heavily on hand-crafted prompts, which often require a lot of trial and error to find the best form. This laborious process is not only time-consuming, but also limits the application of the model in a wider range of scenarios.

[0003] Some existing techniques try to improve the effect of prompts in various ways. For example, auxiliary models or differentiable prompts are used to automatically optimize the generation of prompts, thereby reducing the need for human intervention. However, these methods usually assume that the internal state variables of the LLM can be accessed, which means that they require a deep understanding and control of the underlying mechanism of the model. This requirement is difficult to achieve in many practical applications, especially when using pre-trained black-box models.

[0004] In addition, there are also studies that use reinforcement learning or feedback mechanisms based on LLM itself to optimize prompts. These algorithms perform discrete operations on prompts to improve the effectiveness of prompts. However, these methods usually require low-level access to LLM and may generate incomprehensible outputs. In addition, some algorithms rely on undirected Monte Carlo search. Although this method can explore a large search space, it may lead to a large waste of computing resources due to the lack of clear directionality, and it may not necessarily find the optimal prompt.

[0005] Therefore, current technologies face many challenges in the prompt optimization process, such as dependence on the internal mechanisms of the model, complexity of generating outputs, and lack of computational efficiency. Summary of the invention

[0006] The main purpose of the present invention is to provide a method, device, equipment and storage medium for automatic optimization of model prompt words, aiming to solve the technical problem of how to achieve automatic optimization of prompt words and improve the efficiency and accuracy of prompt word generation.

[0007] To achieve the above object, the present invention provides a method for automatically optimizing model prompt words, comprising:

[0008] Obtaining an initial prompt word and a training data set, wherein the training data set includes input data and corresponding true labels;

[0009] Input the initial prompt word and the input data into the target model to obtain a predicted label;

[0010] Using feedback prompt words to guide the target model to generate language prompt feedback based on the predicted label and the true label, wherein the language prompt feedback is used to identify defects in the initial prompt words;

[0011] The initial prompt word is optimized based on the generated language prompt feedback to obtain a target prompt word.

[0012] In one embodiment, after optimizing the initial prompt word based on the generated language prompt feedback to obtain the target prompt word, the method further includes:

[0013] Generate multiple candidate prompt words based on the target prompt word by using a prompt word expansion method, wherein the prompt word expansion method includes a random sampling method and / or a genetic algorithm;

[0014] Constructing a prompt word candidate set according to the generated multiple candidate prompt words, and selecting and eliminating the candidate prompt words in the prompt word candidate set through multiple rounds of iterations;

[0015] In each round of iteration, a candidate subset is randomly sampled from the prompt word candidate set, a score of each candidate prompt word in the prompt word candidate set on the candidate subset is calculated using a metric function, and the candidate prompt word with the lowest score is eliminated from the prompt word candidate set;

[0016] After multiple rounds of iterations, only the last candidate prompt word remains in the prompt word candidate set, and the optimized target prompt word is obtained.

[0017] In one embodiment, after optimizing the initial prompt word based on the generated language prompt feedback to obtain the target prompt word, the method further includes:

[0018] Setting a preset selection number and a preset number of iteration rounds, setting and initializing a beam set, wherein the initialized beam set uses the target prompt word as an initial value;

[0019] Iterate the beam set for a preset number of iterations, initialize an empty candidate prompt word set in each iteration, expand each prompt word in the beam set, generate multiple candidate prompt words and add them to the candidate prompt word set, score each candidate prompt word in the candidate prompt word set using a metric function, select a preset number of candidate prompt words with the highest scores and add them to the beam set to form a beam set for the next iteration;

[0020] After the preset number of iterations is completed, the candidate prompt word with the highest score is selected from the beam set of the last round to obtain the optimized target prompt word.

[0021] In one embodiment, each prompt word of the beam set is expanded to generate multiple candidate prompt words and add them to the candidate prompt word set, including:

[0022] Randomly replace the keywords of each prompt word in the beam set from a preset vocabulary to generate multiple diversified prompt words for each prompt word;

[0023] Randomly change the sentence structure of the diversified prompt words, including changing words or introducing clauses, to obtain variant prompt words;

[0024] According to the context information of the task corresponding to the target prompt word, the background description of the variant prompt word is added or adjusted to generate multiple candidate prompt words, and the multiple candidate prompt words are added to the candidate prompt word set.

[0025] In one embodiment, before using the feedback prompt word to guide the target model to generate language prompt feedback based on the predicted label and the real label, it also includes:

[0026] Collecting user demand data and historical performance data of the target model;

[0027] Determining task requirements that the target model needs to meet, wherein the task requirements include a specific output form;

[0028] The feedback prompt words are generated according to the user demand data, historical performance data and task requirements of the target model.

[0029] In one embodiment, before using the feedback prompt word to guide the target model to generate language prompt feedback based on the predicted label and the real label, it also includes:

[0030] Analyzing the semantics and structure of the initial prompt word, and generating preliminary feedback prompt words based on the initial prompt word by semantic expansion and structural adjustment;

[0031] Introducing a set of guiding sentences for the preliminary feedback prompt words, so that the preliminary feedback prompt words can guide the model to generate feedback information, thereby obtaining guiding feedback prompt words;

[0032] The target model is used to perform multiple rounds of testing on the guided feedback prompt word, feedback information output by the target model is collected, and the guided feedback prompt word is adjusted according to the feedback information to obtain a final feedback prompt word.

[0033] In one embodiment, the initial prompt word is optimized based on the generated language prompt feedback to obtain a target prompt word, including:

[0034] Identifying problems in the language prompt feedback and determining specific optimization goals, wherein the specific optimization goals include improving semantic accuracy, enhancing contextual relevance, or improving logical structure;

[0035] Selecting a target optimization strategy from an optimization strategy library according to the specific optimization target, optimizing the initial prompt word according to the target optimization strategy, and obtaining a plurality of pending prompt words;

[0036] The target model and the metric function are used to score multiple pending prompt words, and the pending prompt word with the highest score is selected as the target prompt word.

[0037] Furthermore, to achieve the above-mentioned purpose, the present invention also provides a model prompt word automatic optimization device, comprising:

[0038] A data acquisition module, which acquires an initial prompt word and a training data set, wherein the training data set includes input data and corresponding true labels;

[0039] A model prediction module inputs the initial prompt word and the input data into a target model to obtain a predicted label;

[0040] A feedback generation module, using feedback prompt words to guide the target model to generate language prompt feedback based on the predicted label and the true label, wherein the language prompt feedback is used to identify defects in the initial prompt words;

[0041] The prompt word optimization module optimizes the initial prompt word based on the generated language prompt feedback to obtain a target prompt word.

[0042] Furthermore, to achieve the above-mentioned purpose, the present invention also provides a model prompt word automatic optimization device, which includes a memory, a processor, and a model prompt word automatic optimization program stored in the memory and executable on the processor, and the model prompt word automatic optimization program, when executed by the processor, implements the steps of the model prompt word automatic optimization method as described above.

[0043] Furthermore, to achieve the above-mentioned purpose, the present invention also provides a computer storage medium, on which a model prompt word automatic optimization program is stored, and when the model prompt word automatic optimization program is executed by a processor, the steps of the model prompt word automatic optimization method as described above are implemented.

[0044] Beneficial effects: The present invention relates to a method for automatically optimizing model prompt words, which obtains initial prompt words and corresponding training data sets, and the data sets contain input data and corresponding true labels. Subsequently, the initial prompt words are input into the target model together with the input data to generate corresponding predicted labels. On this basis, the target model is guided by feedback prompt words, and language prompt feedback is generated by comparing the predicted labels with the true labels. The feedback is used to identify potential defects in the initial prompt words, and based on this, the initial prompt words are optimized to finally generate target prompt words. The present invention not only reduces the tedious process of manually adjusting the prompt words, but also realizes the gradual improvement of the prompt words through the feedback mechanism, thereby ensuring the high accuracy and consistency of the model output. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:

[0046] Figure 1 It is a flow chart of an embodiment of a method for automatically optimizing model prompt words of the present invention;

[0047] Figure 2 This is a functional module diagram of a preferred embodiment of the automatic optimization device for model prompt words of the present invention;

[0048] Figure 3 It is a structural schematic diagram of the equipment hardware operating environment involved in the embodiment scheme of the model prompt word automatic optimization equipment of the present invention. DETAILED DESCRIPTION

[0049] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0050] It should be noted that large language models (LLMs) have demonstrated strong capabilities as general agents in a variety of tasks, capable of handling complex tasks such as natural language understanding, generation, and reasoning. However, the performance of LLMs relies heavily on manually written prompts, which often require a lot of trial and error to find the best form. This laborious process is not only time-consuming, but also limits the application of the model in a wider range of scenarios.

[0051] Some existing techniques try to improve the effect of prompts in various ways. For example, auxiliary models or differentiable prompts are used to automatically optimize the generation of prompts, thereby reducing the need for human intervention. However, these methods usually assume that the internal state variables of the LLM can be accessed, which means that they require a deep understanding and control of the underlying mechanism of the model. This requirement is difficult to achieve in many practical applications, especially when using pre-trained black-box models.

[0052] In addition, there are also studies that use reinforcement learning or feedback mechanisms based on LLM itself to optimize prompts. These algorithms perform discrete operations on prompts to improve the effectiveness of prompts. However, these methods usually require low-level access to LLM and may generate incomprehensible outputs. In addition, some algorithms rely on undirected Monte Carlo search. Although this method can explore a large search space, it may lead to a large waste of computing resources due to the lack of clear directionality, and it may not necessarily find the optimal prompt.

[0053] Therefore, current technologies face many challenges in the prompt optimization process, such as dependence on the internal mechanisms of the model, complexity of generating outputs, and lack of computational efficiency.

[0054] See also Figure 1 , Figure 1 This is a flow chart of an embodiment of the automatic optimization method for model prompt words provided by the present invention. It should be noted that although the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order than that here.

[0055] like Figure 1 As shown, the model prompt word automatic optimization method proposed by the present invention includes the following steps:

[0056] S10, obtaining an initial prompt word and a training data set, wherein the training data set includes input data and corresponding true labels;

[0057] In this embodiment, the initial prompt word is the starting point of the automatic optimization process of the model prompt word. The initial prompt word can be manually designed, automatically generated, or standardized input based on a pre-trained model. The initial prompt word is intended to guide the large language model (LLM) to generate relevant outputs, and its quality and accuracy directly affect the effect of subsequent steps.

[0058] The training dataset contains input data and corresponding true labels. The input data can be natural language text, structured data, or other types of data, and the true label is the expected output corresponding to these input data. The quality of the training dataset determines the learning effect of the model and is directly related to the optimization effect of the prompt words.

[0059] In one specific implementation, when obtaining the initial prompt word, the system can call a pre-designed prompt word template library, which covers common language task types, such as question answering, translation, summary, etc. According to the specific requirements of the task, a suitable prompt word is selected from the template library as the initial prompt word.

[0060] The training dataset can consist of user inputs and model-generated output pairs from historical tasks. The true labels can be manually annotated or automatically generated by a pre-trained model. The system will regularly update the training dataset to ensure the timeliness and coverage of the data.

[0061] In another specific implementation, the initial prompt word can be manually input by the user, especially in scenarios that require a high degree of customization. The user writes a suitable initial prompt word according to the specific needs of the current task, and the system directly uses the prompt word for subsequent optimization.

[0062] The training dataset can include multimodal data across domains, such as a dataset that combines text and images. The true label includes not only natural language, but also descriptions or classification labels of the image. Such a multimodal training dataset can enhance the generalization ability of the model.

[0063] In other specific implementations, the system automatically generates initial prompt words by analyzing the user's historical behavior. By analyzing the user's past interaction data with the system, the user's preferred language expression is identified, and the initial prompt words are automatically generated to ensure that the prompt words are more in line with the user's habits.

[0064] Training data sets can be dynamically acquired from multiple data sources, such as public data sets on the Internet, internal company data, and user-generated content. Real labels are generated by combining multiple rounds of manual review and machine automatic labeling to ensure the accuracy and diversity of the data.

[0065] By automatically acquiring the initial prompt words and training data sets, the development process is simplified, manual intervention is reduced, the efficiency and accuracy of prompt word optimization are improved, and the learning ability and adaptability of the model are enhanced, thereby improving the performance of the model and the stability of the system.

[0066] S20, inputting the initial prompt word and the input data into the target model to obtain a predicted label;

[0067] In this embodiment, the initial prompt word is a piece of text used to guide the model to generate output. After being combined with input data (such as a natural language sentence or context provided by the user), it is submitted to the target model as input. The role of the initial prompt word is to provide context or task instructions for the model, thereby helping the model to generate output that is more in line with expectations.

[0068] The target model is usually a large language model (LLM), such as GPT, which can generate predicted labels based on the input text data. The predicted label is the result generated by the model based on the initial prompt word and input data, usually an inference, answer or classification label of the input data.

[0069] After receiving the initial prompt word and input data, the model outputs one or more predicted labels through its internal language understanding and generation mechanism. These labels may be natural language sentences, classification results, or other types of model outputs, depending on the nature of the task.

[0070] In one specific implementation, the initial prompt word is a query description or question description provided by the user, and the input data is context information or text fragments related to the query. The target model combines the two to generate a predicted label, which can be an answer to the user's question or a classification result.

[0071] In another specific embodiment, the initial prompt word is automatically generated by the system and includes the instructions or goals of the task. The input data is real-time data from the user, such as input text content or voice transcription. The target model generates a predicted label based on the prompt word and the input data, such as the result of sentiment analysis or a topic label.

[0072] In other embodiments, such as in the case of multimodal data, the initial prompt word may be used in combination with text, image or audio data. The input data includes multiple types of inputs (such as text and images), and the target model generates a predicted label, such as an image description or a classification result, in combination with these input data.

[0073] By combining the initial prompt words with the input data and inputting them into the target model, the model can better understand the task requirements and generate more accurate and relevant prediction labels. This process improves the accuracy and adaptability of the model output, simplifies the user's interactive experience, and significantly improves the performance of the overall system.

[0074] S30, using the feedback prompt word to guide the target model to generate language prompt feedback based on the predicted label and the true label, wherein the language prompt feedback is used to identify defects in the initial prompt word;

[0075] In this embodiment, the feedback prompt words are optimized or specially designed inputs used to guide the target model to generate feedback information. These prompt words guide the model to focus on specific input and output relationships, prompting the model to generate targeted feedback.

[0076] After processing the initial cue words and input data, the target model generates predicted labels. By comparing these predicted labels with the corresponding true labels, the language cue feedback generated by the model can reveal possible flaws or deficiencies in the initial cue words. This feedback is usually in the form of natural language, pointing out parts that the model may have misunderstood or processed improperly.

[0077] The goal of language prompt feedback is to help identify flaws in the initial prompt words that may lead to errors or inaccurate predictions. By analyzing the feedback, the system can find problems in the prompt words, such as unclear semantics, insufficient context, or inconsistent logic, thus providing a basis for subsequent optimization.

[0078] In one embodiment, the feedback prompt words are automatically generated by the system to guide the model to focus on certain key input features or output patterns. The generated language prompt feedback will detail the differences between the predicted labels and the true labels, and identify the reasons in the initial prompt words that may have caused these differences.

[0079] In another specific embodiment, the user can manually write feedback prompts to guide the model to generate feedback based on experience or specific needs. For example, in a text classification task, the user can use prompts containing specific keywords to determine the impact of these keywords in the classification results. The feedback generated by the model will point out which words or structures may cause classification errors based on these prompts.

[0080] In other specific embodiments, in the prompt word optimization process, the system can carry out multiple rounds of iterations. Multiple rounds of iterations refer to that the system constantly generates and uses different feedback prompt words to guide the model to generate feedback in each cycle of prompt word optimization. In each round of iteration, the system uses different feedback prompt words to trigger the model to generate different language prompt feedback. By analyzing the feedback of each round, the system can identify the various problems in the initial prompt word. For example, the first round of iteration may use a prompt word that focuses on contextual relevance, and the second round of iteration may use another prompt word that focuses on semantic accuracy. Through this iteration of multiple rounds, the system progressively optimizes the initial prompt word and finally generates a more accurate target prompt word.

[0081] Alternatively, in each iteration of prompt word optimization, the system dynamically generates feedback prompt words. Based on the information fed back in the previous iteration, the system adjusts and generates new feedback prompt words, and continues to guide the model to generate the next round of feedback. The goal of each iteration is to gradually improve the prompt words through the feedback from the previous round, making them closer and closer to the optimal state. This iterative process continues until the system generates a final, fully optimized target prompt word.

[0082] By using feedback prompt words to guide the model to generate language prompt feedback, defects in the initial prompt words can be accurately identified, thereby providing a clear direction for prompt word optimization, improving optimization efficiency, and enhancing the interpretability and performance of the model.

[0083] S40, optimizing the initial prompt word based on the generated language prompt feedback to obtain a target prompt word.

[0084] In this embodiment, the language prompt feedback is generated by the target model based on the difference between the predicted label and the true label, guided by the feedback prompt words. These feedbacks point out problems in the initial prompt words, such as semantic ambiguity, logical inconsistency, or contextual incoherence.

[0085] Based on the generated language prompt feedback, the system analyzes and identifies defects in the initial prompt words, and then adjusts and improves them. The optimization process can involve modifying the semantics, structure, or content of the prompt words to ensure that the prompt words can more effectively guide the model to generate accurate output.

[0086] Through the optimized initial prompt words, the system finally generates the target prompt words. After multiple iterations and feedback optimization, the target prompt words have eliminated the original defects and can better meet the needs of the model and improve the output quality of the model.

[0087] In one embodiment, after generating language prompt feedback, the system first analyzes the feedback content to determine the main problems in the initial prompt words. For example, the feedback may indicate that some words in the prompt words are not accurate or easy to cause misunderstanding. Based on these feedbacks, the system fine-tunes the initial prompt words, and may optimize the prompt words by replacing words, adjusting sentence structure, etc. The optimized prompt words are further tested to ensure that the improved prompt words can better guide the model to generate correct output.

[0088] In another specific implementation, after the feedback is generated, the system introduces an automated optimization strategy, analyzes the feedback through a natural language processing algorithm, and automatically generates a set of candidate optimization solutions. These solutions may include adding context information to the prompt word, refining the semantic orientation of the prompt word, or simplifying the expression structure of the prompt word. The system evaluates and screens these candidate solutions and finally selects the optimal solution to generate the target prompt word.

[0089] In other specific embodiments, in multiple rounds of iterations, the system uses the previously generated language prompt feedback to gradually optimize the initial prompt words. After each round of optimization, the system inputs the newly generated prompt words into the model again for testing and collects new feedback. Through rounds of feedback-optimization process, the system continuously improves the quality of the prompt words, and the target prompt words finally generated can guide the model to generate high-quality output in many situations.

[0090] Through the guidance of language prompt feedback, the system can accurately optimize the initial prompt words, improve the quality of model output, and ensure that the generated target prompt words show higher adaptability and accuracy in various tasks and contexts.

[0091] The present invention relates to a method for automatically optimizing model prompt words, which obtains initial prompt words and corresponding training data sets, and the data sets include input data and corresponding real labels. Subsequently, the initial prompt words and the input data are input into a target model together to generate corresponding predicted labels. On this basis, feedback prompt words are used to guide the target model, and language prompt feedback is generated by comparing the predicted labels with the real labels. The feedback is used to identify potential defects in the initial prompt words, and based on this, the initial prompt words are optimized to finally generate target prompt words. The present invention not only reduces the tedious process of manually adjusting the prompt words, but also realizes the gradual improvement of the prompt words through the feedback mechanism, thereby ensuring the high accuracy and consistency of the model output.

[0092] In one embodiment, after the above S40, the method further includes:

[0093] S401, generating a plurality of candidate prompt words based on the target prompt word by a prompt word expansion method, wherein the prompt word expansion method includes a random sampling method and / or a genetic algorithm;

[0094] S402, constructing a prompt word candidate set according to the generated multiple candidate prompt words, and selecting and eliminating the candidate prompt words in the prompt word candidate set through multiple rounds of iterations;

[0095] S403, in each round of iteration, randomly sampling a candidate subset from the prompt word candidate set, using a metric function to calculate the score of each candidate prompt word in the prompt word candidate set on the candidate subset, and eliminating the candidate prompt word with the lowest score from the prompt word candidate set;

[0096] S404, until only the last candidate prompt word remains in the prompt word candidate set after multiple rounds of iterations, and the optimized target prompt word is obtained.

[0097] In this embodiment, after optimizing the initial prompt words and generating the target prompt words, the system further generates multiple candidate prompt words through a prompt word expansion method. These expansion methods may include technologies such as random sampling and genetic algorithms. Random sampling can generate candidate prompt words with diversity and randomness, while the genetic algorithm gradually optimizes the quality of the candidate prompt words by simulating the way of biological evolution.

[0098] Through the generated multiple candidate prompt words, the system constructs a prompt word candidate set. This candidate set contains multiple different prompt word versions, each of which has the potential to become the final optimization target prompt word.

[0099] In each iteration, the system randomly samples a subset from the candidate set and evaluates each candidate prompt word in it. These prompt words are scored using a metric function, and the candidate prompt words with the lowest scores are eliminated from the candidate set. This process is repeated for multiple rounds to gradually select the optimal prompt word.

[0100] The metric function is an indicator or standard used to evaluate the performance of candidate prompt words, including but not limited to accuracy, recall, BLEU score, ROUGE score, semantic similarity, etc.

[0101] After multiple rounds of iterations, only the last cue word remains in the candidate set, which is considered to be the fully optimized optimization target cue word with the highest quality and applicability.

[0102] In one specific implementation, the system first generates multiple candidate prompt words with diverse features based on the target prompt word by a random sampling method. Then, by constructing a prompt word candidate set, the system randomly extracts a portion of the candidate prompt words from the candidate set in each iteration and scores them using a preset metric function. The candidate prompt word with the lowest score is eliminated in each iteration until only one optimal prompt word remains.

[0103] In another specific embodiment, a genetic algorithm is used to generate multiple candidate prompt words based on the target prompt word. The genetic algorithm simulates natural selection and generates new candidate prompt words through crossover and mutation. The candidate prompt word set undergoes multiple rounds of iterations, and a metric function is used in each round of iteration to evaluate and eliminate the candidate prompt words, and finally the best candidate prompt word is retained as the final target prompt word.

[0104] In other specific embodiments, the system combines random sampling and genetic algorithm to generate candidate prompt words and construct a candidate set. Through multiple rounds of iterations, random sampling is performed from the candidate set and evaluated in each round. The use of the metric function ensures that the worst prompt words are eliminated in each round of iteration, and the prompt words with the highest quality are finally retained as the final optimization target.

[0105] In this embodiment, through the expansion of prompt words and multiple rounds of iterative selection, the system can effectively screen and optimize prompt words and generate target prompt words with the highest quality. This method ensures the diversity and applicability of prompt words and significantly improves the accuracy and stability of the model.

[0106] In one embodiment, after the above S40, the method further includes:

[0107] S405, setting a preset selection number and a preset number of iteration rounds, setting and initializing a beam set, wherein the initialized beam set uses the target prompt word as an initial value;

[0108] S406, performing a preset number of iterations on the beam set, initializing an empty candidate prompt word set in each iteration, expanding each prompt word in the beam set, generating multiple candidate prompt words and adding them to the candidate prompt word set, scoring each candidate prompt word in the candidate prompt word set using a metric function, selecting a preset number of candidate prompt words with the highest scores and adding them to the beam set to form a beam set for the next iteration;

[0109] S407, until the preset number of iterations is completed, the candidate prompt word with the highest score is selected from the beam set of the last round to obtain the optimized target prompt word.

[0110] In this embodiment, the preset selection number refers to the number of prompt words retained from the candidate prompt word set after each round of iteration. This number determines which prompt words will continue to be optimized in the next round of iteration. The preset number of iterations refers to the number of iterations that will be performed in the entire optimization process. This parameter determines the depth of optimization, and prompt words are gradually screened and optimized through multiple iterations.

[0111] The beam set is a set of candidate cue words that retains a limited number in each iteration. The initialized beam set uses the target cue word as the initial value, which means that the optimization process starts from the cue word that has been preliminarily optimized.

[0112] In each iteration, the system initializes an empty candidate cue word set and expands each cue word in the beam set to generate multiple candidate cue words, which will be added to the candidate cue word set.

[0113] Each cue word in the candidate cue word set is scored using a metric function. Metric functions may include precision, recall, F1 score, etc. These scores are used to judge the quality of the cue words. A preset number of cue words with the highest scores are selected and added to the beam set to form the basis for the next round of iterations.

[0114] After a preset number of iterations, the candidate prompt word with the highest score is finally selected from the beam set of the last round as the final optimization target prompt word.

[0115] In one specific implementation, the system first sets a preset number of selections and number of iterations. Assuming the number of selections is 5 and the number of iterations is 10, the system will retain 5 prompt words in each iteration and perform a total of 10 rounds of iterative optimization.

[0116] The initial value of the beam set is the target cue word. In each iteration, the system semantically expands each cue word, generates candidate cue words, and scores them using precision and recall as metric functions.

[0117] After each round of iteration, the system retains the top five prompt words for the next round of iteration. After the iteration, the prompt word with the highest score from the last round is selected as the final optimization target prompt word.

[0118] In another specific embodiment, the system can use different metric functions, such as F1 score or BLEU score, to capture the performance of the prompt word in a specific task. In each iteration, in addition to semantic expansion, the system can also combine random sampling methods to generate more diverse prompt words.

[0119] In each round of iteration, the system will further evaluate the generalization ability of the prompt words through cross-validation to ensure that the final selected prompt words not only perform well in the current task, but can also adapt to possible future scenarios.

[0120] In other specific implementations, the system can use a genetic algorithm in each iteration to generate a new round of candidate prompt words through selection, crossover and mutation operations. Through the genetic algorithm, the system can explore more possibilities of prompt words and gradually optimize the quality of prompt words in combination with the scoring of the metric function.

[0121] In addition, the target prompt word can be further optimized to obtain the optimized prompt word based on the UCB Bandits algorithm:

[0122] Initialize the prompt word set, which contains multiple candidate prompt words. These prompt words are generated based on the target prompt word with slight modification or expansion. Perform multiple rounds of iterative selection. In each round of iteration, use the UCB Bandits algorithm to select several prompt words from the prompt word set as candidate prompt words for this round.

[0123] Each candidate cue word is scored based on its performance on the test dataset, such as precision, recall, F1 score, etc. Based on the scoring results, the UCB Bandits algorithm will give priority to the cue words with higher scores in the next round for further testing and optimization.

[0124] According to the feedback results of the UCB Bandits algorithm, the prompt word set is updated, the prompt words with excellent performance are retained, and new variant prompt words are generated for further testing.

[0125] The target prompt word can be further optimized to obtain the optimized prompt word based on the Successive Rejects algorithm:

[0126] Initialize the candidate prompt word set, and apply the Successive Rejects algorithm to the initially screened prompt word set to perform more stringent screening on each prompt word.

[0127] After each iteration, the candidate prompt words are scored based on the performance of the target model on the test dataset, and the worst performing prompt words are eliminated.

[0128] The Successive Rejects algorithm gradually reduces the number of candidate prompt words through multiple rounds of iterations and finally retains the optimal prompt word.

[0129] After the last round of iterations, the remaining prompt words are the final optimized prompt words. These prompt words have undergone multiple rounds of screening and optimization and have higher adaptability and effectiveness.

[0130] In this embodiment, by setting the beam set and performing multiple rounds of iterative optimization, the system can effectively screen and optimize the prompt words, and the generated target prompt words have higher quality and adaptability. This method continuously improves the accuracy of the prompt words through multiple iterations, ensuring that the final prompt words can better guide the model to output accurately and stably.

[0131] In one embodiment, in the above S406, each prompt word of the beam set is expanded to generate multiple candidate prompt words and add them to the candidate prompt word set, including:

[0132] S4061, randomly replacing the keyword of each prompt word in the beam set from a preset vocabulary to generate multiple diversified prompt words for each prompt word;

[0133] S4062, randomly changing the sentence structure of the diversified prompt words, including changing words or introducing clauses, to obtain variant prompt words;

[0134] S4063: According to the context information of the task corresponding to the target prompt word, add or adjust the background description of the variant prompt word, generate multiple candidate prompt words, and add the multiple candidate prompt words to the candidate prompt word set.

[0135] In this embodiment, the system performs semantic and structural expansion on each prompt word in the beam set to generate multiple candidate prompt words. These expansions can be achieved in the following ways:

[0136] Randomly replace keywords from a preset vocabulary: The system uses a preset vocabulary to randomly replace keywords with the prompt words in the beam set. In this way, the system can generate multiple prompt words with diverse characteristics. This step increases the diversity of candidate prompt words by introducing vocabulary variation, thereby expanding the search space for prompt words.

[0137] Randomly transform the syntactic structure: After generating diversified prompt words, the system further randomly transforms the syntactic structure of these prompt words. This includes changing the word order in the prompt words, introducing clauses, etc., so that the generated variant prompt words are different in structure from the original prompt words, thereby enhancing the semantic diversity of the prompt words.

[0138] Adjusting the background description: The system adds or adjusts the background description of the prompt word based on the contextual information of the task corresponding to the target prompt word. This step generates candidate prompt words that are more relevant to the task by adding additional background information or adjusting existing descriptions, further enhancing the applicability and accuracy of the prompt word.

[0139] In one specific implementation, in the beam set, the system first applies the replacement rules in the preset vocabulary to each prompt word, randomly selects and replaces keywords, and generates a diverse set of candidate prompt words. Then, the system transforms the syntactic structure of these prompt words, such as changing active sentences to passive sentences, or introducing more clauses. Finally, the system adjusts the background description of the prompt word according to the context of the specific task to make it more suitable for the task requirements.

[0140] In another specific implementation, the system first generates preliminary diversified prompt words, and then uses natural language processing technology to adjust their syntax. This may include using dependency grammar analysis tools to automatically identify and adjust sentence structures to generate variant prompt words that conform to specific grammatical rules. The adjustment of the background description is completed through a context-aware model to ensure that the prompt words can more accurately reflect the specific needs of the task.

[0141] By expanding the prompt words in the beam set, the system can generate a large number of diverse candidate prompt words. These prompt words can explore a wider prompt word space through keyword replacement, syntactic structure transformation and background description adjustment, ensuring that the final selected prompt words have high applicability and accuracy in various tasks and scenarios. This method significantly improves the flexibility of prompt words and the stability of model output.

[0142] In one embodiment, in the above S30, before using the feedback prompt word to guide the target model to generate language prompt feedback based on the predicted label and the real label, it also includes:

[0143] S301, collecting user demand data and historical performance data of the target model;

[0144] S302, determining the task requirements that the target model needs to meet, wherein the task requirements include a specific output form;

[0145] S303: Generate the feedback prompt words according to the user demand data, historical performance data and task requirements of the target model.

[0146] In this embodiment, the system needs to collect various data related to the target model. This data includes the user's needs and expectations for the model (such as task type, output preference) and the model's past performance data (such as the model's performance on different tasks, user feedback, etc.). This data is used to accurately understand the model's performance in different tasks and help generate feedback prompts suitable for the current task.

[0147] Based on the collected user needs and historical performance data, the system will analyze and determine the specific task requirements that the target model needs to meet in the current task. These requirements may include specific output forms (such as the format of the answer, language style) or specific functional requirements (such as high accuracy, fast response, etc.). Determining these requirements helps generate more accurate and demand-oriented feedback prompts.

[0148] Based on the above collection and analysis results, the system generates one or more feedback prompts. These prompts are tailored to the specific needs and historical performance of the target model, and can more effectively guide the model to generate expected output content.

[0149] In one specific implementation, the system first collects user demand data and historical performance data of the model through an interface. User demand data may include user expectations for model output, such as simplicity, formatting requirements, etc. Historical performance data may include the accuracy of the model in past tasks, user feedback scores, etc.

[0150] After analyzing this data, the system identifies the task requirements of the target model in the current task, such as the need to generate short answers or use specific terms. Based on these requirements, the system generates a set of feedback prompts, such as "Please answer in a short sentence" or "Please use professional terms to describe."

[0151] Ultimately, these feedback prompts are used to guide the target model to ensure that the generated output meets user needs and the model's optimal performance.

[0152] In another specific implementation, in a chatbot application, the system can regularly collect user-bot interaction data, including the types of questions asked by the user, the language style used, and the robot's past response time and accuracy. These data will help the system determine that the robot needs to respond quickly and use informal language in the current task.

[0153] Based on this, the system generates feedback prompts, such as "Quickly answer the following questions" or "Please keep the conversation informal." These prompts guide the model in subsequent processing to ensure that the generated answers meet the user's immediate needs and tone preferences.

[0154] By collecting and analyzing the user demand data and historical performance data of the target model, the system can generate more accurate feedback prompts. These prompts help guide the model to generate expected outputs in specific tasks, improve the response quality of the model and user satisfaction. This method ensures that the generated prompts are not only suitable for the current task, but also can be optimized based on the past performance of the model, thereby improving the overall performance of the model and user experience.

[0155] In one embodiment, in the above S30, before using the feedback prompt word to guide the target model to generate language prompt feedback based on the predicted label and the real label, it also includes:

[0156] S304, analyzing the semantics and structure of the initial prompt word, and generating a preliminary feedback prompt word based on the initial prompt word by semantic expansion and structural adjustment;

[0157] S305, introducing a set of guiding sentences for the preliminary feedback prompt words, so that the preliminary feedback prompt words can guide the model to generate feedback information, and obtain guiding feedback prompt words;

[0158] S306, using the target model to perform multiple rounds of testing on the guided feedback prompt word, collecting feedback information output by the target model, and adjusting the guided feedback prompt word according to the feedback information to obtain a final feedback prompt word.

[0159] In this embodiment, the system first analyzes the initial prompt word in detail to understand its semantic content and syntactic structure. This step is intended to identify the core meaning of the initial prompt word and possible structural weaknesses or imperfections.

[0160] Based on the analysis, the system performs semantic expansion and structural adjustment. Semantic expansion may include the introduction of synonyms or related concepts to enhance the expressive power of the prompt word. Structural adjustment may involve sentence transformation, the introduction of clauses or other syntactic adjustments to generate preliminary feedback prompt words.

[0161] The system introduces a set of guiding sentences for the generated preliminary feedback prompt words. The role of these guiding sentences is to enable the feedback prompt words to clearly guide the model to generate the required feedback information. The design of the guiding sentences is based on the expected output form of the model to ensure the accuracy and relevance of the feedback information.

[0162] The system uses the target model to conduct multiple rounds of testing on the generated guided feedback prompt words. Through repeated testing, the system collects feedback information generated by the target model. This feedback information is used to evaluate the effectiveness of the feedback prompt words.

[0163] The system adjusts the guiding feedback prompt words based on the feedback information collected in multiple rounds of testing. The adjustments may include semantic refinement, structural optimization, or improvement of guiding sentences, and ultimately generate feedback prompt words that can effectively guide the model.

[0164] In one specific implementation, in a natural language processing task, the system first analyzes the vocabulary and syntactic structure of the initial prompt word and identifies its core semantic unit. Then, the system semantically expands it by introducing synonyms, related concepts or extended background information, and makes syntactic adjustments. The generated preliminary feedback prompt word may include multiple versions with different expressions or grammatical structures.

[0165] The system has designed a set of guiding sentences for these preliminary feedback prompts, such as "Please generate relevant feedback based on the following prompts" or "Describe the potential shortcomings of the prompts" to ensure that the model can generate useful feedback information.

[0166] These guided feedback prompts are tested multiple times using the target model to collect useful feedback information by comparing the quality and relevance of the model output.

[0167] Finally, based on the collected feedback, the system optimizes these prompt words and generates the final feedback prompt words. These prompt words can effectively guide the model and perform better in actual tasks.

[0168] In another specific embodiment, during the optimization process of a chatbot, the system analyzes the semantics and structure of the initial prompt words and finds that they lack sufficient context information. The system generates a set of preliminary feedback prompt words by expanding the context description of the prompt words and introducing clauses or additional information.

[0169] The system introduces a “why” or “how” guide for each feedback prompt word, allowing the model to provide more in-depth analysis when generating feedback information.

[0170] By repeatedly testing these prompt words with the target model, the system gradually optimizes the prompt words so that they can effectively trigger the model to generate useful feedback information and make adjustments based on the feedback.

[0171] Ultimately, the system generated a set of feedback prompts that maximized the quality of the model’s output, significantly improving the chatbot’s response quality.

[0172] This embodiment analyzes the semantics and structure of the initial prompt words, and generates feedback prompt words in combination with semantic expansion and structural adjustment. The system can generate more guiding and targeted prompt words. Through multiple rounds of testing and feedback optimization, the feedback prompt words finally generated not only improve the response quality of the model, but also effectively solve the defects of the initial prompt words, ensuring the efficient performance of the model in different tasks and scenarios.

[0173] In one embodiment, the above S40 includes:

[0174] S4001, identifying problems in the language prompt feedback and determining specific optimization goals, wherein the specific optimization goals include improving semantic accuracy, enhancing context relevance, or improving logical structure;

[0175] S4002, selecting a target optimization strategy from an optimization strategy library according to the specific optimization target, optimizing the initial prompt word according to the target optimization strategy, and obtaining a plurality of pending prompt words;

[0176] S4003, using the target model and the metric function to score multiple pending prompt words, and selecting the pending prompt word with the highest score as the target prompt word.

[0177] In this embodiment, the system first analyzes the generated language prompt feedback to identify problems with the initial prompt words reflected in the feedback. These problems may be related to semantic accuracy, contextual relevance, or logical structure. Based on the analysis results, the system determines specific optimization goals, such as improving semantic accuracy, enhancing contextual relevance, or improving the logical structure of the prompt words.

[0178] Based on the determined optimization goal, the system selects the appropriate optimization strategy from the pre-set optimization strategy library. The optimization strategy library contains a variety of optimization methods for different types of problems, such as vocabulary replacement strategies for semantic problems, syntactic adjustment strategies for contextual relevance problems, etc.

[0179] The system applies the selected optimization strategy to adjust and optimize the initial prompt words and generate multiple versions of pending prompt words. These pending prompt words are generated through different optimization strategies to increase diversity and selection space.

[0180] The system uses the target model to test the generated multiple pending prompt words and uses a metric function to score the performance of each prompt word. The metric function may include multiple indicators such as accuracy, relevance, fluency, etc. The system selects the pending prompt word with the highest score as the final target prompt word.

[0181] In one specific implementation, when processing a specific task, the system analyzes the language prompt feedback and identifies that the initial prompt word has a semantic inaccuracy problem. The system uses this as an optimization target, selects relevant vocabulary replacement strategies and context enhancement strategies from the optimization strategy library, optimizes the initial prompt word, and generates multiple pending prompt words.

[0182] The system then tests these candidate cues with the target model and scores them based on accuracy and relevance. Finally, the system selects the cues with the highest scores as the target cues.

[0183] In another specific implementation, in a dialogue system, the system analyzes the language prompt feedback and finds that there are problems with the logical structure of the initial prompt word. The system takes "improving the logical structure" as the optimization goal and selects a syntactic reconstruction strategy from the optimization strategy library. The system reconstructs the initial prompt word and generates multiple pending prompt words with more rigorous logical structures.

[0184] These pending cue words are evaluated through the target model, and the system scores them based on accuracy and fluency, and finally selects the cue word with the best performance as the target cue word.

[0185] By identifying problems in the language prompt feedback and applying targeted optimization strategies, the system can effectively improve the initial prompt words, making the target prompt words generated in the end more accurate and in line with the task requirements. Through multiple rounds of evaluation and optimization, the system can generate the optimal target prompt words, thereby significantly improving the overall performance and output quality of the model.

[0186] The present invention also provides a model prompt word automatic optimization device, referring to Figure 2 , Figure 2 This is a functional module diagram of a preferred embodiment of the automatic optimization device for model prompt words of the present invention. The automatic optimization device for model prompt words includes:

[0187] A data acquisition module, used to acquire an initial prompt word and a training data set, wherein the training data set includes input data and corresponding true labels;

[0188] A model prediction module, used to input the initial prompt word and the input data into the target model to obtain a predicted label;

[0189] A feedback generation module, used for using feedback prompt words to guide the target model to generate language prompt feedback based on the predicted label and the true label, wherein the language prompt feedback is used to identify defects in the initial prompt words;

[0190] The prompt word optimization module is used to optimize the initial prompt word based on the generated language prompt feedback to obtain a target prompt word.

[0191] The specific implementation of the model prompt word automatic optimization device of the present invention is basically the same as the various embodiments of the above-mentioned model prompt word automatic optimization method, and will not be repeated here.

[0192] The present invention also provides a model prompt word automatic optimization device, such as Figure 3 As shown, the model prompt word automatic optimization device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0193] Those skilled in the art will understand that Figure 3 The hardware structure of the model prompt word automatic optimization device shown in does not constitute a limitation of the model prompt word automatic optimization device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0194] like Figure 3 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a model prompt word automatic optimization program. The operating system is a program for managing and controlling the model prompt word automatic optimization device and software resources, and supports the operation of the network communication module, the user interface module, the model prompt word automatic optimization program, and other programs or software; the network communication module is used to manage and control the network interface 1004; the user interface module is used to manage and control the user interface 1003.

[0195] exist Figure 3 In the hardware structure of the model prompt word automatic optimization device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client and communicate data with the client; the processor 1001 can call the model prompt word automatic optimization program stored in the memory 1005, and perform the same operations as the model prompt word automatic optimization method.

[0196] The specific implementation of the model prompt word automatic optimization device of the present invention is basically the same as the various embodiments of the above-mentioned model prompt word automatic optimization method, and will not be repeated here.

[0197] In addition, an embodiment of the present invention further proposes a computer storage medium on which a model prompt word automatic optimization program is stored. When the model prompt word automatic optimization program is executed by a processor, the steps of the model prompt word automatic optimization method described above are implemented.

[0198] The specific implementation of the computer storage medium of the present invention is basically the same as the embodiments of the above-mentioned model prompt word automatic optimization method, and will not be repeated here.

[0199] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims. All equivalent structures or equivalent process changes made using the contents of the specification and drawings of the present invention, or directly or indirectly used in other related technical fields, are protected by the present invention.

[0200] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0201] In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, RandomAccess Memory), a disk or an optical disk.

[0202] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0203] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0204] It should be noted that if software tools or components other than those of our company appear in the embodiments of the present application, they are only used for illustrative purposes and do not represent actual use.

Claims

1. A method for automatically optimizing model prompt words, characterized in that: The following steps are involved: Obtaining an initial prompt word and a training data set, wherein the training data set includes input data and corresponding true labels; Input the initial prompt word and the input data into the target model to obtain a predicted label; Using feedback prompt words to guide the target model to generate language prompt feedback based on the predicted label and the true label, wherein the language prompt feedback is used to identify defects in the initial prompt words; The initial prompt word is optimized based on the generated language prompt feedback to obtain a target prompt word.

2. The automatic optimization method for model prompt words according to claim 1, characterized in that: After optimizing the initial prompt word based on the generated language prompt feedback to obtain the target prompt word, the method further includes: Generate multiple candidate prompt words based on the target prompt word by using a prompt word expansion method, wherein the prompt word expansion method includes a random sampling method and / or a genetic algorithm; Constructing a prompt word candidate set according to the generated multiple candidate prompt words, and selecting and eliminating the candidate prompt words in the prompt word candidate set through multiple rounds of iterations; In each round of iteration, a candidate subset is randomly sampled from the prompt word candidate set, a score of each candidate prompt word in the prompt word candidate set on the candidate subset is calculated using a metric function, and the candidate prompt word with the lowest score is eliminated from the prompt word candidate set; After multiple rounds of iterations, only the last candidate prompt word remains in the prompt word candidate set, and the optimized target prompt word is obtained.

3. The automatic optimization method for model prompt words according to claim 1, characterized in that: After optimizing the initial prompt word based on the generated language prompt feedback to obtain the target prompt word, the method further includes: Setting a preset selection number and a preset number of iteration rounds, setting and initializing a beam set, wherein the initialized beam set uses the target prompt word as an initial value; Iterate the beam set for a preset number of iterations, initialize an empty candidate prompt word set in each iteration, expand each prompt word in the beam set, generate multiple candidate prompt words and add them to the candidate prompt word set, score each candidate prompt word in the candidate prompt word set using a metric function, select a preset number of candidate prompt words with the highest scores and add them to the beam set to form a beam set for the next iteration; After the preset number of iterations is completed, the candidate prompt word with the highest score is selected from the beam set of the last round to obtain the optimized target prompt word.

4. The automatic optimization method for model prompt words according to claim 3, characterized in that: Each cue word in the beam set is expanded to generate multiple candidate cue words and add them to the candidate cue word set, including: Randomly replace the keywords of each prompt word in the beam set from a preset vocabulary to generate multiple diversified prompt words for each prompt word; Randomly change the sentence structure of the diversified prompt words, including changing words or introducing clauses, to obtain variant prompt words; According to the context information of the task corresponding to the target prompt word, the background description of the variant prompt word is added or adjusted to generate multiple candidate prompt words, and the multiple candidate prompt words are added to the candidate prompt word set.

5. The automatic optimization method for model prompt words according to claim 1, characterized in that: Before using the feedback prompt word to guide the target model to generate language prompt feedback based on the predicted label and the real label, it also includes: Collecting user demand data and historical performance data of the target model; Determining task requirements that the target model needs to meet, wherein the task requirements include a specific output form; The feedback prompt words are generated according to the user demand data, historical performance data and task requirements of the target model.

6. The automatic optimization method for model prompt words according to claim 1, characterized in that: Before using the feedback prompt word to guide the target model to generate language prompt feedback based on the predicted label and the real label, it also includes: Analyzing the semantics and structure of the initial prompt word, and generating preliminary feedback prompt words based on the initial prompt word by semantic expansion and structural adjustment; Introducing a set of guiding sentences for the preliminary feedback prompt words, so that the preliminary feedback prompt words can guide the model to generate feedback information, thereby obtaining guiding feedback prompt words; The target model is used to perform multiple rounds of testing on the guided feedback prompt word, feedback information output by the target model is collected, and the guided feedback prompt word is adjusted according to the feedback information to obtain a final feedback prompt word.

7. The automatic optimization method for model prompt words as claimed in claim 1, characterized in that: Optimizing the initial prompt word based on the generated language prompt feedback to obtain a target prompt word includes: Identifying problems in the language prompt feedback and determining specific optimization goals, wherein the specific optimization goals include improving semantic accuracy, enhancing contextual relevance, or improving logical structure; Selecting a target optimization strategy from an optimization strategy library according to the specific optimization target, optimizing the initial prompt word according to the target optimization strategy, and obtaining a plurality of pending prompt words; The target model and the metric function are used to score multiple pending prompt words, and the pending prompt word with the highest score is selected as the target prompt word.

8. A model prompt word automatic optimization device, characterized in that: The model prompt word automatic optimization device comprises: A data acquisition module, used to acquire an initial prompt word and a training data set, wherein the training data set includes input data and corresponding true labels; A model prediction module, used to input the initial prompt word and the input data into the target model to obtain a predicted label; A feedback generation module, used for using feedback prompt words to guide the target model to generate language prompt feedback based on the predicted label and the true label, wherein the language prompt feedback is used to identify defects in the initial prompt words; The prompt word optimization module is used to optimize the initial prompt word based on the generated language prompt feedback to obtain a target prompt word.

9. A model prompt word automatic optimization device, characterized in that: The model prompt word automatic optimization device includes a memory, a processor, and a model prompt word automatic optimization program stored in the memory and executable on the processor. When the model prompt word automatic optimization program is executed by the processor, the steps of the model prompt word automatic optimization method as described in any one of claims 1 to 7 are implemented.

10. A computer storage medium, characterized in that: The storage medium stores a model prompt word automatic optimization program, and when the model prompt word automatic optimization program is executed by the processor, the steps of the model prompt word automatic optimization method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Process data link intelligent construction method based on large model

    CN119782437A

  • Large model data labeling method and device, equipment, medium and product

    CN119848555A

  • Conversational analysis retrieval method and device and medium

    CN119938890A

  • Large model automatic prompt tuning method and device using gradient optimization and medium

    CN119962681A

  • Prompt word optimization method, intelligent agent and storage medium

    CN120278153A