Prompt word optimization method and device for large language model, storage medium and product
By constructing a method based on similarity retrieval and small prompt word optimization model, the problem of low efficiency in prompt word optimization for large language models is solved, and the generalization ability across models and tasks is achieved, thereby improving the performance and output quality of large language models.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ALIBABA CLOUD COMPUTING CO LTD
- Filing Date
- 2024-10-18
- Publication Date
- 2026-04-21
AI Technical Summary
Existing auto-suggestion engineering lacks generalization ability across models and tasks, and requires a large amount of manually labeled data, resulting in low efficiency in optimizing suggestion words for large language models.
By acquiring the original prompt word datasets corresponding to various tasks, selecting a portion of the original prompt words and their optimized prompt words, using a small prompt word optimization model to train a large language model, retrieving and matching the optimized prompt words based on similarity, and constructing a prompt word optimization model with strong generalization ability.
It improves the efficiency and quality of prompt word optimization, ensuring the high-efficiency reasoning performance of large language models under various tasks, and outputting more accurate and detailed answer results.
Smart Images

Figure CN121902801A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, device, storage medium, and product for optimizing prompt words in a large language model. Background Technology
[0002] The quality of prompts directly impacts the performance of large language models. However, when ordinary users write prompts, the output of large language models often suffers from poor results due to unclear intent, lack of detail, or insufficient skills.
[0003] To address the quality issues of user-generated suggestions, auto-suggestion engineering can be employed to optimize user-inputted suggestions. However, existing auto-suggestion engineering methods often lack generalization capabilities across models and tasks, and require a large amount of manually labeled data for each task's corresponding large language model, resulting in low efficiency. Summary of the Invention
[0004] This invention provides a method, device, storage medium, and product for optimizing prompt words in a large language model, in order to improve the optimization efficiency of prompt words.
[0005] In a first aspect, embodiments of the present invention provide a method for optimizing prompt words in a large language model, the method comprising:
[0006] Obtain the original prompt word dataset, which corresponds to various tasks;
[0007] Obtain an optimized dataset corresponding to a portion of the original prompt words in the original prompt word dataset, wherein the optimized dataset includes the portion of the original prompt words and the first optimized prompt words corresponding to each portion of the original prompt words;
[0008] For a target original prompt word in the original prompt word dataset, based on the similarity between it and a portion of the original prompt words in the optimized dataset, a matching first optimized prompt word is retrieved from the optimized dataset, wherein the target original prompt word is any one of the original prompt word datasets;
[0009] The target original prompt word and the first optimized prompt word are input into the first large language model to output the second optimized prompt word corresponding to the target original prompt word;
[0010] A prompt word optimization model is trained using the target original prompt word and the second optimized prompt word, wherein the parameter size of the prompt word optimization model is smaller than that of the first large language model.
[0011] Secondly, embodiments of the present invention provide a prompt word optimization device for a large language model, the device comprising:
[0012] The first acquisition module is used to acquire the original prompt word dataset, which corresponds to various tasks;
[0013] The second acquisition module is used to acquire an optimized dataset corresponding to a portion of the original prompt words in the original prompt word dataset. The optimized dataset includes the portion of the original prompt words and the first optimized prompt words corresponding to each of the portion of the original prompt words.
[0014] The retrieval module is used to retrieve a first optimized prompt word that matches a target original prompt word in the original prompt word dataset based on the similarity between the target original prompt word and a portion of the original prompt words in the optimized dataset. The target original prompt word is any one of the original prompt word datasets.
[0015] The input module is used to input the target original prompt word and the first optimized prompt word into the first large language model to output the second optimized prompt word corresponding to the target original prompt word;
[0016] The training module is used to train a prompt word optimization model using the target original prompt word and the second optimized prompt word, wherein the parameter size of the prompt word optimization model is smaller than that of the first large language model.
[0017] Thirdly, embodiments of the present invention provide an electronic device, including: a memory, a processor, and a communication interface; wherein, the memory stores executable code, and when the executable code is executed by the processor, the processor executes the prompt word optimization method for a large language model as described in the first aspect.
[0018] Fourthly, embodiments of the present invention provide a non-transitory machine-readable storage medium storing executable code, wherein when the executable code is executed by a processor of an electronic device, the processor is able to at least implement the prompt word optimization method for a large language model as described in the first aspect.
[0019] Fifthly, embodiments of the present invention provide a computer program product, the computer program product including a computer program, which, when executed by a processor, can implement the prompt word optimization method for a large language model as described in the first aspect.
[0020] In the prompt word optimization scheme of the large language model provided in this embodiment of the invention, firstly, an original prompt word dataset is obtained, which includes original prompt words corresponding to various tasks. Then, a portion of the original prompt words is selected from the original prompt word dataset, and an optimized dataset corresponding to this portion of the original prompt words is obtained. The optimized dataset includes the selected portion of the original prompt words and the first optimized prompt words corresponding to each of the selected portion of the original prompt words. Next, for a target original prompt word in the original prompt word dataset, a matching first optimized prompt word is retrieved from the optimized dataset based on the similarity between the target original prompt word and the selected portion of the original prompt words in the optimized dataset. The target original prompt word can be any one of the original prompt word datasets. Then, the target original prompt word and the first optimized prompt word are input into a first large language model to output a second optimized prompt word corresponding to the target original prompt word. Finally, a prompt word optimization model is trained using the target original prompt word and the second optimized prompt word, and the parameter size of the prompt word optimization model is smaller than that of the first large language model.
[0021] In the above scheme, a subset of original prompt words is selected from the original prompt word dataset covering several tasks, and an optimized dataset corresponding to this subset is obtained. Based on this, when optimizing each target original prompt word in the original prompt word dataset, the first optimized prompt word in the optimized dataset that matches the target original prompt word can be used to guide the first large language model to optimize the target original prompt word based on the matched first optimized prompt word. This ensures the optimization quality of the second optimized prompt word. Then, a prompt word optimization model is trained based on the target original prompt word and the second optimized prompt word. This efficiently yields a prompt word optimization model with strong application generalization ability, which can be combined with large language models for various tasks to complete efficient inference for corresponding tasks. Furthermore, the parameter size of the prompt word optimization model is smaller than that of the first large language model, allowing it to be used as a plug-and-play module inserted into various large language models to improve their performance and make the output answers more accurate and detailed. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 A flowchart illustrating a method for optimizing prompt words in a large language model, as provided in an embodiment of the present invention;
[0024] Figure 2This is a schematic diagram of the structure of the prompt word template corresponding to the first large language model provided in this embodiment of the invention;
[0025] Figure 3 A schematic diagram of the prompt words corresponding to the first large language model provided in the embodiments of the present invention;
[0026] Figure 4 A flowchart illustrating another method for optimizing prompt words in a large language model, as provided in an embodiment of the present invention;
[0027] Figure 5 This is a schematic diagram of the structure of a prompt word template corresponding to a fourth major language model provided in an embodiment of the present invention;
[0028] Figure 6 A flowchart illustrating another method for optimizing prompt words in a large language model, as provided in an embodiment of the present invention;
[0029] Figure 7a and Figure 7b This is a schematic diagram of the prompt words before and after optimization provided in an embodiment of the present invention;
[0030] Figure 8 This is a schematic diagram of the structure of a prompt word optimization device for a large language model provided in an embodiment of the present invention;
[0031] Figure 9 This is a schematic diagram of the structure of an electronic device provided in this embodiment. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. In addition, the timing of the steps in the following method embodiments is only an example and not a strict limitation.
[0033] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0034] The following is a brief introduction to some concepts involved in the embodiments of the present invention.
[0035] Prompt: When using a large language model, a piece of text is input to guide the model in generating specific text content. Prompts can include descriptions, questions, commands, etc., to clarify the expected topic or form of the generated content.
[0036] Prompt engineering refers to the techniques and methods used to improve the output quality of generative AI (such as chatbots or text generation models) by carefully designing and optimizing input prompts.
[0037] Plug-and-Play: refers to components that can be easily added or removed, which can extend the functionality or improve the performance of the main model without interrupting or significantly modifying it.
[0038] This invention provides a novel suggestion word optimization scheme for a large language model. In this scheme, diverse original suggestion word datasets are collected, and an optimized dataset is generated based on a subset of the original suggestion words. For each original suggestion word in the original dataset, a matching optimized suggestion word is retrieved from the optimized dataset. Both are then input into a first large language model to guide it in optimizing the original suggestion word based on the optimized suggestion word. This not only yields a high-quality training dataset but also ensures the diversity and broad coverage of task types. The suggestion word optimization model is trained based on this training dataset. Since the optimized suggestion words in the training dataset are the optimized results output by the first large language model after processing the original suggestion words, a suggestion word optimization model with strong generalization ability can be efficiently obtained. Furthermore, the parameter size of this optimized model is smaller than that of the first large language model, allowing for plug-and-play integration with large language models for various tasks to achieve efficient inference.
[0039] The following detailed description of some embodiments of the present invention is provided in conjunction with the accompanying drawings. Where there is no conflict between the embodiments, the following embodiments and features thereof can be combined with each other.
[0040] Figure 1 A flowchart of a prompt word optimization method for a large language model provided in an embodiment of the present invention is shown below. Figure 1 As shown, the method includes the following steps:
[0041] 101. Obtain the original prompt word dataset, which corresponds to various tasks.
[0042] 102. Obtain the optimized dataset corresponding to a portion of the original prompt words in the original prompt word dataset. The optimized dataset includes a portion of the original prompt words and the first optimized prompt words corresponding to each portion of the original prompt words.
[0043] 103. For the target original prompt word in the original prompt word dataset, based on the similarity between it and some original prompt words in the optimized dataset, retrieve the first optimized prompt word that matches it from the optimized dataset.
[0044] 104. Input the target original prompt word and the first optimized prompt word into the first large language model to output the second optimized prompt word corresponding to the target original prompt word.
[0045] 105. Train the prompt optimization model using the original target prompt words and the second optimized prompt words.
[0046] The prompt word optimization scheme provided in this invention can be used to optimize prompt words for any type of large language model, so as to better stimulate the performance of the large language model and generate output that is more in line with expectations or of higher quality. In practical applications, a prompt word optimization model can be pre-trained to complete the task of optimizing prompt words.
[0047] In practical applications, the quality of the training dataset directly determines the performance of the prompt word optimization model. In order to obtain a prompt word optimization model with better performance, in this embodiment of the invention, a high-quality training dataset can be constructed first when training the prompt word optimization model.
[0048] In practice, the first step is to acquire raw prompt word datasets corresponding to various tasks. These raw prompt word datasets include multiple raw prompt words. Raw prompt words refer to the prompt word data used to trigger the large language model to generate specific responses, before any optimization processing.
[0049] Because large language models handle a wide variety of tasks across various application scenarios, including but not limited to text classification, sentiment analysis, named entity recognition, question answering systems, machine translation, text summarization, and text generation, each task presents unique challenges and requirements. Therefore, the corresponding prompts also need to be adjusted and optimized. Thus, to ensure the trained prompt optimization model has good generalization ability, it's beneficial to acquire original prompt datasets from multiple tasks. This means the original prompt dataset should include prompts from various task types. By collecting original prompt datasets from multiple tasks, a wider range of application scenarios can be covered, thereby improving the generalization ability and practicality of the prompt optimization model.
[0050] Among them, the task types corresponding to various tasks can be mathematics, reasoning, code generation, code debugging, writing, computer science, complex formatting, common sense, hypothetical problems, multilingual translation, role-playing, biology, engineering technology, ethics, sports, law, medicine, literature, entertainment, art, music, malicious attacks, economics, physics, history, academic writing, chemistry, philosophy, health, ecology, grammar, rewriting, and other task types.
[0051] Furthermore, due to significant differences in the length, distribution, scale, and quality of prompt words across different tasks, and the fact that the number of data samples for one type of task far exceeds that of other types, the prompt word optimization model may be overly influenced, leading to overfitting on specific tasks and underfitting on others. Therefore, when acquiring original prompt words for multiple tasks, a diverse range of original prompt words should be collected to ensure that the original prompt word dataset covers as many tasks as possible and includes original prompt words of varying lengths, languages, and difficulty levels.
[0052] However, in practice, the quality of the original prompt word dataset is uneven and cannot meet the above requirements. Therefore, in an optional embodiment, a large number of original prompt words can be obtained first, and then the original prompt words can be processed by expanding the data language, expanding the data difficulty, and processing the data length of the original prompt words to a long tail distribution to generate the original prompt word dataset. In this way, a raw prompt word dataset with balanced data distribution and diversity can be obtained.
[0053] In order to generate a high-quality training dataset, after obtaining the original prompt word dataset, multiple reference examples can be constructed. These reference examples can be used to provide a reference for the optimization of each original prompt word in the original prompt word dataset.
[0054] Furthermore, to better guide the optimization of each original prompt word in the original prompt word dataset, when constructing multiple reference examples, a subset of original prompt words can be selected from the dataset, and the corresponding optimized dataset can be obtained as multiple reference examples. In other words, since the original prompt words in the original dataset and the selected subset are from the same task set, selecting reference examples based on similarity allows for the selection of more relevant examples, thus providing better reference examples for the optimization of each original prompt word in the original dataset.
[0055] Specifically, a small portion of the original prompt words can be selected from the original prompt word dataset, and the corresponding optimized dataset can be obtained. The optimized dataset includes a portion of the original prompt words and their corresponding first optimized prompt words, with several first optimized prompt words used as reference examples.
[0056] For ease of description, each prompt word in this section of the original prompt words can be referred to as the first original prompt word. That is, multiple first original prompt words are selected from the original prompt word dataset; these multiple first original prompt words represent only a small sample of the original prompt word dataset. For example, if the original prompt word dataset is a very large dataset, the multiple first original prompt words may be a very small subset of that dataset.
[0057] Multiple original prompt words are optimized to determine their corresponding optimized prompt words. An optimized dataset is then generated based on these original prompt words and their respective optimized prompt words. The optimized dataset includes the original prompt words and their corresponding optimized prompt words.
[0058] The first optimized prompt word is the optimized result corresponding to the first original prompt word, and can be used as a reference example for optimizing the first original prompt word. In other words, the optimized dataset includes multiple reference examples corresponding to the first original prompt word. Each reference example demonstrates how to optimize the original prompt word, and can provide a reference for subsequent optimization of each original prompt word in the original prompt word dataset.
[0059] The original prompt word dataset contains a large number of original prompt words for different task types. In order to better provide optimization references for each original prompt word in the original prompt word dataset, when selecting the first original prompt word from the original prompt word dataset, we can try to ensure that the selected first original prompt words include prompt words corresponding to multiple task types, and that the number of data, data length, language type, and data difficulty of the first original prompt words corresponding to each task type are relatively balanced. This can cover a wide range of prompt word types, so as to provide optimization guidance for different types of tasks.
[0060] After selecting multiple initial prompt words, an optimized dataset corresponding to each initial prompt word is obtained. Specifically, this optimized dataset can be obtained by collecting optimized prompt words from user interaction records, historical session data, or other sources. Alternatively, it can be obtained directly from open-source datasets. It can also be manually created. Specifically, each initial prompt word can be optimized to determine its corresponding optimized prompt word, and an optimized dataset can be generated based on the initial prompt words.
[0061] In this embodiment of the invention, to ensure the quality of each reference example, the determination of the first optimized prompt word in each reference example can preferably be achieved through manual annotation. Multiple original prompt words are optimized to obtain the first optimized prompt words corresponding to each original prompt word. The manual annotation process can mainly follow these principles: breaking down the problem reflected by the original prompt words into more detailed sub-problems; and annotating based on task characteristics, such as requiring code comments for coding tasks and listing the reasoning steps for reasoning tasks.
[0062] For example, if the first original prompt is: painting, music—choose the correct pairing for the given words. Then the first optimized prompt after annotation would be: Choose appropriate collocations for the terms "painting" and "music". Or, if the first original prompt is: Analyze the structure of the following news article. #{news}. Here, # represents a placeholder used to indicate where specific news content should be inserted in actual use. The first optimized prompt after annotation would be: Please analyze the title and subtitle of the following news article, specifically pointing out how they establish the theme and attract readers' interest. Please explain in detail how the keywords and structures used in the title and subtitle effectively convey the core information of the news, and explain how these elements provide background information and set the tone of the article. #{news}.
[0063] Furthermore, existing auto-completion engineering models rely on a large amount of manually labeled data. This extensive manual annotation requires significant time and human resources, increasing the cost of developing and maintaining the model. Moreover, the process of manually labeling data is time-consuming, especially when dealing with large datasets, making it inefficient for rapid iteration.
[0064] To address this issue, in this embodiment of the invention, a small number of representative first original prompt words are selected, and these original prompt words are manually annotated to obtain corresponding first optimized prompt words. These optimized prompt words are then used as reference examples to provide optimization processing demonstrations for each original prompt word in the original prompt word dataset. Instead of directly using the reference examples as the training dataset, the number of manually annotated prompt words is significantly smaller than that in existing automatic prompt engineering models. This not only reduces manual input and improves processing efficiency but also provides optimization processing references for each original prompt word in the original prompt word dataset.
[0065] As described above, when constructing multiple reference examples, a small number of initial prompt words can be selected from the original prompt word dataset. These initial prompt words can then be manually annotated and optimized to obtain optimized prompt words for each initial prompt word. These optimized prompt words can then be used as multiple reference examples. This method of obtaining multiple reference examples can cover a wide range of task types, providing good guidance for prompt word optimization for different types of tasks.
[0066] Next, each original prompt word in the original prompt word dataset can be optimized to obtain its corresponding optimized prompt word. Since the specific implementation process for optimizing each original prompt word is largely the same, this embodiment of the invention will only illustrate the optimization process of any one original prompt word in the original prompt word dataset. For ease of description, any one original prompt word in the original prompt word dataset will be referred to as the target original prompt word. The optimization process of the target original prompt word will be described in detail below.
[0067] Specifically, for a target original prompt word, a matching first optimized prompt word can be retrieved from the optimized dataset based on the similarity between the target original prompt word and multiple first original prompt words in the optimized dataset. In other words, for each target original prompt word, a matching first optimized prompt word can be retrieved from the optimized dataset based on the similarity between the target original prompt word and multiple first original prompt words in the optimized dataset.
[0068] In one optional embodiment, the specific implementation for retrieving the matching first optimized prompt word from the optimized dataset involves first determining the first embedding vectors corresponding to multiple first original prompt words and the second embedding vector corresponding to the target original prompt word, and then determining the similarity between the second embedding vectors and the multiple first embedding vectors. Next, at least one first original prompt word is identified as corresponding to at least one first embedding vector whose similarity to the second embedding vector meets a set requirement. Finally, the first optimized prompt word corresponding to at least one first original prompt word is determined to be the first optimized prompt word that matches the target original prompt word.
[0069] The first embedding vector is a numerical vector that represents the semantic information of the first original prompt word. The second embedding vector is also a numerical vector that represents the semantic information of the target original prompt word. Converting multiple first and target original prompt words into numerical vectors allows for a better understanding and processing of these original prompt words.
[0070] In one optional implementation, to determine the first and second embedding vectors, a word embedding model can be used to encode multiple first original prompt words and the target original prompt word separately, thereby generating first embedding vectors corresponding to the multiple first original prompt words and second embedding vectors corresponding to the target original prompt word. The word embedding model can be an all-MiniLM-L6-v2 model, a Word2Vec model, a GloVe model, a FastText model, etc.
[0071] After determining the first embedding vectors corresponding to multiple first original prompt words and the second embedding vector corresponding to the target original prompt word, at least one first embedding vector whose similarity to the second embedding vector meets the set requirements can be determined by comparing the cosine similarity between the second embedding vector and the multiple first embedding vectors. After determining at least one first embedding vector, the first original prompt word corresponding to the at least one first embedding vector is then determined, and the first optimized prompt word corresponding to the at least one first original prompt word is determined as the first optimized prompt word that matches the target original prompt word.
[0072] These first optimized prompts, which match the original target prompts, can serve as a reference example for optimizing the original target prompts, demonstrating how to optimize this type of original prompt. Next, the original target prompts and the first optimized prompts can be integrated into a prompt corresponding to a first large language model, which is then input into the first large language model. This allows the first large language model to optimize the original target prompts based on the first optimized prompts in the input prompts, obtaining the second optimized prompts corresponding to the original target prompts.
[0073] The first large language model can be a large language model such as the Qwen-max model or the GPT-4 model. When optimizing the original target prompt words, a large language model can be used to optimize them. This can take advantage of the strong performance of the large language model to obtain better optimization results, so that the quality of the second optimized prompt words corresponding to the original target prompt words is better. In this way, the quality of the training dataset can be improved, and the trained prompt word optimization model can have better optimization performance.
[0074] After obtaining the second optimized prompt word using the first large language model, the original target prompt word and the second optimized prompt word can be used as training samples to obtain high-quality training samples. Then, the prompt word optimization model is trained based on these training samples to obtain a well-trained prompt word optimization model. This prompt word optimization model can be a small model with a parameter scale much smaller than the first large language model. For example, this prompt word optimization model can be a small language model such as the Qwen2-7B model or the Qwen2-1.8B model.
[0075] As described above, the second optimized prompt word in the training sample is the optimized result output by the first large language model after optimizing the original target prompt word. Then, based on the original target prompt word and the second optimized prompt word, the prompt word optimization model is trained, which can efficiently obtain a prompt word optimization model with strong application generalization ability. It can be combined with large language models under various tasks to complete the corresponding tasks' efficient reasoning.
[0076] In this embodiment of the invention, by acquiring diverse datasets of original prompt words and combining them with first optimized prompt words that match the target original prompt words in the optimized dataset, a first large language model is used to optimize the target original prompt words to obtain second optimized prompt words. This ensures the optimization quality of the second optimized prompt words. The prompt word optimization model is then trained using the target original prompt words and the second optimized prompt words. This not only constructs a high-quality training dataset for training the prompt word optimization model, but also efficiently yields a prompt word optimization model with strong application generalization capabilities. This model can be combined with large language models for various tasks to complete efficient reasoning for corresponding tasks. Furthermore, the parameter size of the prompt word optimization model is smaller than that of the first large language model, allowing it to be used as a plug-and-play module inserted into various large language models to improve their performance and make the output answers more accurate and detailed.
[0077] The above embodiments describe the process of inputting the target original prompt word and a first optimized prompt word matching the target original prompt word into a first large language model to guide the first large language model to optimize the target original prompt word based on the first optimized prompt word, thereby obtaining a second optimized prompt word. The quality of the prompt words input into the first large language model directly determines the quality of the second optimized prompt word that the first large language model can output. Therefore, in order for the first large language model to better understand and process the task, the target original prompt word is optimized according to the first optimized prompt word in the input prompt words, thereby obtaining a second optimized prompt word of better quality.
[0078] In one optional embodiment, a prompt word template corresponding to a first large language model can be pre-designed. Using the prompt word template, prompt words corresponding to the first large language model can be generated, making the generated prompt words corresponding to the first large language model more suitable for input into the first large language model.
[0079] The prompt word template corresponding to the first major language model can include task description, contextual information, format specifications, constraints, and guiding questions or statements, as well as placeholders that can be adjusted and expanded according to specific application scenarios.
[0080] The following is combined Figure 2 The prompt word template shown provides a detailed explanation of each component in the prompt word template corresponding to the first major language model. Figure 2 In this prompt template, the task description includes a role setting: "As a skilled prompt engineer, your expertise lies in refining prompts to improve efficiency." This clarifies who the task's subject is, along with their role and capabilities. The task description is: "Your task is to refine the given user prompts, ensuring the generated prompts are clearer and more logically structured." The constraint is: "The refined prompts must faithfully reflect the user's original intent."
[0081] The output format is specified as follows: "The language of the refined prompt should match the language of the user prompt. Please only output the refined prompt, excluding irrelevant content such as 'Refined Prompt'." Below are some examples: "#{user prompt word}; #{refined prompt}; #{user prompt word}; #{refined prompt}; #{user prompt word}; #{refined prompt}".
[0082] The example section can be represented as placeholders. In practical applications, the first optimized prompt word matched with the original target prompt word can be dynamically filled into this section to obtain a specific example. It can also include: #{User prompt word to be refined}; #{Refined prompt}. Here, "User prompt word to be refined" and "Refined prompt" can be represented as placeholders. In practical applications, the corresponding original target prompt words can be dynamically filled into this section to obtain a specific prompt word.
[0083] After designing the prompt word template corresponding to the first large language model, the prompt word corresponding to the first large language model is generated based on the target original prompt word, the first optimized prompt word, and the prompt word template corresponding to the first large language model. This is then input into the first large language model to obtain the second optimized prompt word corresponding to the target original prompt word.
[0084] Specifically, in combination Figure 3 The generated prompt words corresponding to the first large language model shown illustrate the process of generating prompt words. The target original prompt words are three matching first optimized prompt words retrieved from the optimized dataset. The first matching original prompt word is: painting, music; select the correct pair for the given words. The corresponding first optimized prompt word is: select appropriate matches for the terms "painting" and "music". The second matching original prompt word is: analyze the structure of the following news article #{news}. The corresponding first optimized prompt word is: analyze the headline and subheading of the following news article, detailing how they establish the theme, attract reader interest, and provide background information. Discuss how the selection and structure of specific words in the headline and subheading effectively convey the core information of the news. #{news}.
[0085] The third matching first original prompt is: If a customer inquires about product specifications but does not specify a product, prompt them to provide more details. Answer fully using the document content; avoid over-interpreting. The corresponding first optimized prompt is: "When answering a customer's question about product specifications, if the customer does not mention a specific product, ask the customer to provide more details. Response format: Use a formal and professional customer service tone, and answer based on the product information in the manual. Considerations: If the customer does not specify product details, please use this template to reply: 'Hello! To provide accurate product specifications, could you please specify which product you are referring to?' Once the customer provides details for a specific product, reply with accurate and comprehensive specification data."
[0086] After obtaining the target original prompt word and the first optimized prompt word that matches the target original prompt word, the three matching first original prompt words and the first optimized prompt words corresponding to the first original prompt words are used as examples to fill the placeholders in the example part of the prompt word template corresponding to the first large language model. At the same time, the target original prompt word is filled into the placeholders in the prompt word template corresponding to the user prompt word to be refined in the first large language model, so as to obtain the prompt word corresponding to the first large language model, such as... Figure 3 As shown.
[0087] As described above, by designing a prompt word template corresponding to the first major language model, the first major language model can be effectively guided to optimize the target original prompt word based on the first optimized prompt word in the prompt words input into the model, so as to generate the expected result.
[0088] Building upon this, to further enhance the performance of the prompt word optimization model, post-training optimization can be performed to ensure its superior performance in real-world applications. The post-training optimization process of the prompt word optimization model will be explained in detail below with reference to the following embodiments.
[0089] Figure 4 A flowchart of another method for optimizing prompt words in a large language model provided in an embodiment of the present invention is shown below. Figure 4 As shown, in order to further improve the performance of the prompt word optimization model, based on the above embodiments, the method further includes the following steps:
[0090] 401. Combine different system prompt words with the target original prompt word, and input them into the trained prompt word optimization model to obtain multiple third optimized prompt words corresponding to the target original prompt word.
[0091] 402. Based on multiple third-optimized prompt words and second-optimized prompt words, optimize and train the prompt word optimization model.
[0092] When performing post-training optimization on the prompt word optimization model, in order to make the post-trained optimized prompt word optimization model perform more stably and reliably in different real-world application scenarios, each target original prompt word can be sampled to obtain multiple optimization results corresponding to the target original prompt word. This ensures the diversity and comprehensiveness of the sampling results as much as possible, which can help the prompt word optimization model learn more diverse outputs and improve its robustness and generalization ability.
[0093] Specifically, multiple system prompts can be combined with the original target prompt to obtain multiple combined prompts. These combined prompts are then input into a pre-trained prompt optimization model to obtain multiple third-order optimized prompts corresponding to the original target prompt. Each of the multiple system prompts uses a different descriptive prompt optimization model to optimize and rewrite the original target prompt.
[0094] System prompts are typically used to set the context of a dialogue, provide guidance, or define rules to help the prompt optimization model better rewrite the original prompts based on different descriptions. System prompts can include role descriptions, task requirements, goal descriptions, and other necessary information, enabling the prompt optimization model to work under clearer task guidance and generate more accurate third-party optimized prompts.
[0095] Furthermore, the multiple optimized third-order prompts obtained through the above method may not meet specific constraints. Therefore, in another optional embodiment, a rejection sampling method can be used to generate multiple optimized third-order prompts that meet specific constraints. Specifically, multiple different system prompts and the target original prompt are paired and input into a trained prompt optimization model to obtain multiple optimized third-order prompts corresponding to the target original prompt. Rejection sampling is then used to filter the multiple optimized third-order prompts to determine those that meet the constraints.
[0096] Next, the prompt optimization model is trained using multiple third-optimized prompt words and second-optimized prompt words. The second-optimized prompt words are obtained by optimizing the original target prompt word using a high-performance first language model and combining it with first-optimized prompt words that match the original target prompt word. Therefore, the quality of the second-optimized prompt words obtained in this way is relatively good. Thus, when training the prompt optimization model using multiple third-optimized prompt words, the second-optimized prompt words can be used as supervised information for supervised training, resulting in a higher-performance prompt optimization model.
[0097] Furthermore, to enable the prompt word optimization model to understand the subtle differences in user preferences and ensure that the final output better matches user expectations and practical application needs, in an optional embodiment, preference pairs can be constructed and used, for example, with an algorithm such as DPO (Direct Preference Optimization), to optimize the training of the prompt word optimization model.
[0098] When constructing preference pairs, the quality of multiple optimized third-party prompts can be evaluated. Preference pairs are constructed from two third-party prompts with significantly different quality levels. The quality of these optimized third-party prompts directly impacts the accuracy and detail of the responses output by the large language model paired with the prompt optimization model. Therefore, evaluating the quality of multiple optimized third-party prompts can be done by combining the responses obtained from inputting these prompts into the large language model.
[0099] The specific implementation process can be as follows: input multiple third-optimized prompt words into the third language model to obtain the answer results corresponding to the multiple third-optimized prompt words respectively; determine the difference degree of the answer results corresponding to the multiple third-optimized prompt words respectively, and take two third-optimized prompt words with a difference degree greater than a set threshold as a preference pair, thereby forming at least one preference pair corresponding to multiple third-optimized prompt words; use the second-optimized prompt words as supervision information, and optimize and train the prompt word optimization model with at least one preference pair respectively.
[0100] The third major language model can be the same as the first and second major language models in the above embodiments, or it can be a different major language model. In other words, in practical applications, the same major language model can be used for multiple task processing.
[0101] When determining preference pairs, the quality of multiple optimized third-party suggestions can be determined based on the degree of difference in the answer results corresponding to each suggestion. If the degree of difference in the answer results corresponding to two optimized third-party suggestions is greater than a set threshold, then these two suggestions are considered as a preference pair. Furthermore, the size of the set threshold can be adjusted according to actual needs.
[0102] For example, after sampling the optimized results of the original target prompts in various ways, three optimized prompts (A, B, and C) are obtained. Prompt A is input into the third language model, outputting response 1. Prompt B is input into the third language model, outputting response 2. Prompt C is input into the third language model, outputting response 3. The difference between response 1 and response 2 is set to 1, the difference between response 1 and response 3 to 5, and the difference between response 2 and response 3 to 9. A threshold of 2 is set; if the difference between response 1 and response 3 is greater than 2, then prompts A and C are identified as a preference pair. Similarly, if the difference between response 2 and response 3 is greater than the predetermined threshold of 2, then prompts B and C are identified as a preference pair.
[0103] In practical applications, directly determining the degree of difference in the answer results corresponding to multiple third-optimized prompts manually is inefficient and cannot guarantee the accuracy of the evaluation. Therefore, in an optional embodiment, a large language model can be used to determine the degree of difference in the answer results corresponding to multiple third-optimized prompts.
[0104] Specifically, based on the answer results corresponding to multiple third-optimized prompt words and the prompt word template corresponding to the fourth language model, prompt words corresponding to the fourth language model are generated. This allows the fourth language model to output a detail score for the answer results corresponding to the multiple third-optimized prompt words based on the input prompt words. The degree of difference between the answer results corresponding to the multiple third-optimized prompt words is determined based on the detail scores. The fourth language model can be the same as or different from the first, second, and third language models; there are no restrictions on this.
[0105] When using the fourth language model to determine the detail scores of the answers corresponding to multiple third-optimized prompt words, in order to improve the accuracy of the detail scores of the answers corresponding to multiple third-optimized prompt words output by the fourth language model, the multiple third-optimized prompt words can be converted into prompt words suitable for the fourth language model.
[0106] When converting multiple third-optimized prompt words, a prompt word template corresponding to the fourth language model can be designed first. This can not only better convert multiple third-optimized prompt words into prompt words suitable for the fourth language model, but also improve conversion efficiency.
[0107] The fourth language model is mainly used to score the level of detail of the answers corresponding to multiple third-optimized prompt words. The prompt word template corresponding to the fourth language model can include a description of the scoring task, placeholders for the answers corresponding to multiple third-optimized prompt words, and placeholders for the level of detail score results.
[0108] Combination Figure 5 The prompt word template corresponding to the fourth language model shown is explained below, illustrating the prompt word template used for scoring processing. The prompt word template includes a system prompt word: "You are a useful and accurate assistant in evaluating the quality of the answer results." The prompt word template includes multiple placeholders corresponding to answer results, which can be represented as #{Assistant 1's answer result}, {Assistant 2's answer result}. It should be noted that Assistant 1's answer result here can be the answer result corresponding to the third optimized prompt word in the above embodiment. In practical applications, after obtaining the answer results corresponding to multiple third optimized prompt words, these answer results can be filled into the placeholders corresponding to the answer results of multiple assistants.
[0109] The prompt template also includes a task description: "We would like to receive your evaluation of the level of detail in the responses of the two AI assistants to the user's instructions or input above." The constraints are: "Please rate the level of detail in their responses. Each AI assistant will receive a detail score ranging from 1 to 10, with higher scores indicating better detail." The output format is: "Please first provide a comprehensive explanation of your evaluation, avoiding any potential bias and ensuring that the order of responses does not affect your judgment. Then, output two lines representing the scores for AI Assistant 1 and AI Assistant 2, respectively."
[0110] Furthermore, the prompt template also includes an output placeholder. This output placeholder can be represented in the following format: Evaluation reason: {Your evaluation description}; Assistant 1's score: {score}; Assistant 2's score: {score}.
[0111] After designing the prompt word template corresponding to the fourth language model, the answer results corresponding to multiple third-optimized prompt words can be filled into the prompt word template corresponding to the fourth language model to obtain the corresponding prompt words. These prompt words are then input into the fourth language model to guide it in outputting a detail score corresponding to multiple answer results based on the prompt words. Furthermore, based on the relationship between the degree of difference of the answer results corresponding to multiple third-optimized prompt words and a set threshold, at least one preference pair is constructed.
[0112] Next, using the second optimized prompt word as supervised learning, the prompt word optimization model is trained with at least one preference pair. Since the parameter scale in the prompt word optimization model is relatively small and its accuracy is lower than that of large language models, the second optimized prompt word corresponding to the target original prompt word output by the first large language model can be used as supervised information during optimization training. This supervised training of the prompt word optimization model allows it to achieve better performance and be applicable to more application scenarios.
[0113] In this embodiment of the invention, multiple different system prompts and target original prompts are paired and input into a trained prompt optimization model to obtain multiple third-optimized prompts corresponding to the target original prompts. Based on the multiple third-optimized prompts and the second-optimized prompts, the prompt optimization model is optimized and trained. This enables the prompt optimization model to have better generalization ability and to better understand subtle differences in user preferences. As a result, the prompts optimized by the prompt optimization model are optimized, and the final answer results obtained are more in line with user expectations and practical application needs.
[0114] After obtaining the trained prompt word optimization model, it can be designed as a plug-and-play module. When using different large language model services, it can be directly inserted into the corresponding large language model, eliminating the need for custom training of the prompt word optimization model for each large language model. This eliminates the need for users to perform additional cumbersome configuration or training, allowing direct application to various large language models and providing significant convenience. The following embodiments will detail the specific implementation process of using the prompt word optimization model to provide prompt word optimization services for the input data corresponding to various large language models.
[0115] Figure 6 A flowchart of another method for optimizing prompt words in a large language model provided in an embodiment of the present invention is shown below. Figure 6 As shown, based on the above embodiments, the method further includes the following steps:
[0116] 601. Obtain the input data corresponding to the target task and the prompt words to be optimized corresponding to the second largest language model.
[0117] 602. The prompt words to be optimized are optimized using the prompt word optimization model to obtain the optimized prompt words.
[0118] 603. Input the input data and optimized prompts into the second language model to obtain the corresponding answer results.
[0119] In practical applications, users can invoke the second language model service to process the target task. To improve the detail and accuracy of the second language model's answers, in this embodiment of the invention, a prompt word optimization model can be used to first optimize the input data corresponding to the target task input to the second language model before inputting it back into the second language model to obtain the corresponding answer. The target task is encompassed within the various tasks corresponding to the original prompt word dataset mentioned above. It should be noted that the second language model here can be the same as or different from the first language model in the above embodiments; this is not limited.
[0120] First, we need to obtain the input data corresponding to the target task and the suggestion words to be optimized for the second language model. The target task refers to the task to be processed and input into the second language model; it can be various tasks such as text generation, intelligent question answering, code generation, mathematical calculation, etc. Input data refers to the original input information corresponding to the target task, which can be text, questions, or other forms of data. Suggestion words to be optimized refer to the suggestion words currently used by the second language model; these may be unoptimized original suggestion words or suggestion words that have undergone preliminary processing but still require further improvement.
[0121] Next, the prompt word optimization model is used to optimize the prompt words to obtain optimized prompt words. These optimized prompt words are more accurate and clearer, and are more likely to guide the second language model to generate high-quality answers. Then, the input data and optimized prompt words are input into the second language model to obtain the corresponding answer results. Specifically, the input data can be integrated into the optimized prompt words to obtain prompt word text, which is then input into the second language model.
[0122] This invention involves acquiring input data corresponding to the target task and the prompt words to be optimized corresponding to a second language model. The prompt words are then optimized using a prompt word optimization model to obtain optimized prompt words. Finally, the input data and optimized prompt words are input into the second language model to obtain the corresponding answer result. This effectively utilizes the prompt word optimization model to improve the input prompt words corresponding to the second language model, thereby obtaining higher quality answer results, improving the accuracy and detail of the answer results, and also enhancing processing efficiency and generalization ability.
[0123] The specific implementation process involved in the embodiments of the present invention can be referred to the content of the above embodiments, and will not be repeated here.
[0124] To more intuitively illustrate the optimization results of the prompt word optimization method provided in this embodiment of the invention, and the differences in the response content generated based on the prompt words before and after optimization, combined with... Figure 7a and Figure 7b Illustrative illustration. In Figure 7a and Figure 7b In the table, the first and third columns are the prompt words (i.e., instructions) before optimization and the prompt words after optimization, respectively. The second and fourth columns correspond to the response content generated based on the prompt words before optimization and the response content generated based on the prompt words after optimization, respectively.
[0125] The prompt word optimization apparatus of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will understand that these apparatuses can all be configured using commercially available hardware components through the steps taught in this solution.
[0126] Figure 8 This is a schematic diagram of the structure of a prompt word optimization device for a large language model provided in an embodiment of the present invention, as shown below. Figure 8 As shown, the device includes: a first acquisition module 11, a second acquisition module 12, a retrieval module 13, an input module 14, and a training module 15.
[0127] The first acquisition module 11 is used to acquire the original prompt word dataset, which corresponds to various tasks.
[0128] The second acquisition module 12 is used to acquire an optimized dataset corresponding to a portion of the original prompt words in the original prompt word dataset. The optimized dataset includes the portion of the original prompt words and the first optimized prompt words corresponding to each of the portion of the original prompt words.
[0129] The retrieval module 13 is used to retrieve a matching first optimized prompt word from the optimized dataset based on the similarity between the target original prompt word in the original prompt word dataset and the plurality of first original prompt words in the optimized dataset. The target original prompt word is any one of the original prompt word datasets.
[0130] The input module 14 is used to input the target original prompt word and the first optimized prompt word into the first large language model to output the second optimized prompt word corresponding to the target original prompt word.
[0131] Training module 15 is used to train a prompt word optimization model using the target original prompt word and the second optimized prompt word.
[0132] Optionally, the training module 15 is further configured to: acquire input data corresponding to the target task and prompt words to be optimized corresponding to the second language model, wherein the target task is included in the multiple tasks; optimize the prompt words to be optimized through the prompt word optimization model to obtain optimized prompt words; and input the input data and the optimized prompt words into the second language model to obtain the corresponding answer result.
[0133] Optionally, the retrieval module 13 is specifically configured to: determine the first embedding vectors corresponding to the partial original prompt words, and the second embedding vector corresponding to the target original prompt word; determine the similarity between the second embedding vector and multiple first embedding vectors; determine at least one original prompt word corresponding to at least one first embedding vector whose similarity with the second embedding vector meets the set requirements; and determine that the first optimized prompt word corresponding to the at least one original prompt word is a first optimized prompt word that matches the target original prompt word.
[0134] Optionally, the input module 14 is specifically used to: generate a prompt word corresponding to the first large language model based on the target original prompt word, the first optimized prompt word, and the prompt word template corresponding to the first large language model, so as to input the prompt word into the first large language model.
[0135] Optionally, the training module 15 is further configured to: pair different system prompt words with the target original prompt word, and input them into the trained prompt word optimization model to obtain multiple third optimized prompt words corresponding to the target original prompt word; the multiple system prompt words respectively prompt the prompt word optimization model to optimize and rewrite the target original prompt word with different descriptions; and optimize and train the prompt word optimization model based on the multiple third optimized prompt words and the second optimized prompt words.
[0136] Optionally, the training module 15 is further configured to: input the plurality of third optimized prompt words into a third language model respectively to obtain the answer results corresponding to the plurality of third optimized prompt words respectively; determine the difference degree of the answer results corresponding to the plurality of third optimized prompt words respectively, so as to form a preference pair of two third optimized prompt words with a difference degree greater than a set threshold, thereby forming at least one preference pair corresponding to the plurality of third optimized prompt words; and use the second optimized prompt word as supervision information to optimize and train the prompt word optimization model with the at least one preference pair respectively.
[0137] Optionally, the training module 15 is further configured to: generate prompt words corresponding to the fourth language model based on the answer results corresponding to the plurality of third optimized prompt words and the prompt word template corresponding to the fourth language model, so that the fourth language model outputs a detail score of the answer results corresponding to the plurality of third optimized prompt words based on the input prompt words; and determine the degree of difference of the answer results corresponding to the plurality of third optimized prompt words based on the detail score of the answer results corresponding to the plurality of third optimized prompt words.
[0138] Figure 8 The device shown can perform the steps in the prompt word optimization method of the large language model in the foregoing embodiments. For detailed execution process and technical effects, please refer to the description in the foregoing embodiments, which will not be repeated here.
[0139] This invention also provides an electronic device, such as... Figure 9 As shown, the electronic device may include: a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable code, which, when executed by the processor 21, enables the processor 21 to implement the prompt word optimization method for the large language model as described in the previous embodiment.
[0140] In addition, embodiments of the present invention provide a non-transitory machine-readable storage medium storing executable code, which, when executed by a processor of an electronic device, enables the processor to at least implement the prompt word optimization method for a large language model as provided in the foregoing embodiments.
[0141] The invention also provides a computer program product, which includes a computer program that, when executed by a processor, enables the processor to at least implement the prompt word optimization method for a large language model as provided in the foregoing embodiments.
[0142] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0143] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of a necessary general-purpose hardware platform, or by a combination of hardware and software. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0144] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for optimizing prompt words, characterized in that, include: Obtain the original prompt word dataset, which corresponds to various tasks; Obtain an optimized dataset corresponding to a portion of the original prompt words in the original prompt word dataset, wherein the optimized dataset includes the portion of the original prompt words and the first optimized prompt words corresponding to each portion of the original prompt words; For a target original prompt word in the original prompt word dataset, based on the similarity between it and a portion of the original prompt words in the optimized dataset, a first optimized prompt word that matches is retrieved from the optimized dataset, wherein the target original prompt word is any one of the original prompt word datasets; The target original prompt word and the first optimized prompt word are input into the first large language model to output the second optimized prompt word corresponding to the target original prompt word; A prompt word optimization model is trained using the target original prompt word and the second optimized prompt word, wherein the parameter size of the prompt word optimization model is smaller than that of the first large language model.
2. The method according to claim 1, characterized in that, The method further includes: Obtain the input data corresponding to the target task and the prompt words to be optimized corresponding to the second largest language model, wherein the target task is included in the multiple tasks; The prompt word to be optimized is optimized using the prompt word optimization model to obtain the optimized prompt word; The input data and the optimized prompt words are input into the second large language model to obtain the corresponding answer results.
3. The method according to claim 1 or 2, characterized in that, The step of retrieving a first optimized prompt word from the optimized dataset based on the similarity between the target original prompt word in the original prompt word dataset and the partial original prompt words in the optimized dataset includes: Determine the first embedding vector corresponding to each of the original prompt words, and the second embedding vector corresponding to the target original prompt word; Determine the similarity between the second embedding vector and each of the multiple first embedding vectors; Determine at least one original prompt word corresponding to at least one first embedding vector whose similarity with the second embedding vector meets the set requirements; The first optimized prompt word corresponding to the at least one original prompt word is determined to be the first optimized prompt word that matches the target original prompt word.
4. The method according to claim 1 or 2, characterized in that, The step of inputting the target original prompt word and the first optimized prompt word into the first large language model includes: Based on the target original prompt word, the first optimized prompt word, and the prompt word template corresponding to the first large language model, a prompt word corresponding to the first large language model is generated and input into the first large language model.
5. The method according to claim 1 or 2, characterized in that, The method further includes: The system prompts and the target original prompts are combined and input into the trained prompt optimization model to obtain multiple third optimized prompts corresponding to the target original prompts. The multiple system prompts use different descriptions to prompt the prompt optimization model to optimize and rewrite the target original prompts. The prompt word optimization model is optimized and trained based on the multiple third optimized prompt words and the second optimized prompt words.
6. The method according to claim 5, characterized in that, The step of optimizing and training the prompt word optimization model based on the plurality of third optimized prompt words and the second optimized prompt words includes: The multiple third-optimized prompt words are input into the third language model to obtain the answer results corresponding to the multiple third-optimized prompt words respectively; Determine the degree of difference in the answer results corresponding to the plurality of third optimized prompt words, and take two third optimized prompt words with a degree of difference greater than a set threshold as a preference pair, thereby forming at least one preference pair corresponding to the plurality of third optimized prompt words; Using the second optimized prompt word as supervision information, the prompt word optimization model is optimized and trained using at least one preference pair.
7. The method according to claim 6, characterized in that, Determining the degree of difference in the answer results corresponding to the plurality of third-optimized prompt words includes: Based on the answer results corresponding to the multiple third optimized prompt words and the prompt word template corresponding to the fourth language model, the prompt words corresponding to the fourth language model are generated so that the fourth language model outputs a detail score of the answer results corresponding to the multiple third optimized prompt words based on the input prompt words; Based on the level of detail of the responses corresponding to the multiple third-optimized prompts, the degree of difference in the responses corresponding to the multiple third-optimized prompts is determined.
8. An electronic device, characterized in that, include: The system includes a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor performs the prompt word optimization method for a large language model as described in any one of claims 1 to 7.
9. A non-transitory machine-readable storage medium, characterized in that, The non-transitory machine-readable storage medium stores executable code that, when executed by a processor of an electronic device, causes the processor to perform a prompt word optimization method for a large language model as described in any one of claims 1 to 7.
10. A computer program product, characterized in that, include: A computer program, when executed by a processor of an electronic device, causes the processor to perform a prompt word optimization method for a large language model as described in any one of claims 1 to 7.