Prompt word optimization method and device based on large model
By obtaining user feedback and using the second major model to analyze semantics, and automatically adjusting the prompt words of the big model, the problem of poor operating status of the big model in a dynamic changing environment is solved, and business process efficiency and user satisfaction are improved.
Patent Information
- Application Number
- CN202411195580.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2025-01-07
AI Technical Summary
When facing changing user needs and market conditions, the prompt words are difficult to dynamically adjust, resulting in poor operating conditions and affecting business process efficiency and user satisfaction.
By obtaining user feedback text, using the second major model to analyze the semantics of the feedback text, generate target improvement points, adjust the characters to be adjusted in the original prompt word, and realize automatic optimization of the prompt word.
It improves the flexibility and adaptability of prompt words, and enhances the operation efficiency and user satisfaction of the big model in dynamic changing environments.
Smart Images

Figure CN119271769A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a prompt word optimization method and device based on a large model. Background Art
[0002] In today's fast-paced business environment, enterprises are faced with increasingly complex business needs and changing market conditions. In order to maintain their competitive advantage, enterprises must continuously optimize their business processes and improve efficiency and responsiveness. However, traditional business process management methods often lack flexibility and intelligence, and are difficult to adapt to dynamically changing needs and diverse tasks.
[0003] At present, the application of large models is becoming more and more extensive. Large models have significant advantages in task processing efficiency and flexibility. However, the prompt words used when calling large models after development are often fixed, and it is difficult to dynamically adjust and optimize according to feedback from actual operation. This fixed performance limitation makes it difficult for large models to maintain the best operating state when facing changing user needs and market conditions, which in turn affects the overall efficiency of business processes and user satisfaction.
[0004] Therefore, how to automatically optimize the prompt words becomes a problem that needs to be solved urgently. Summary of the invention
[0005] The embodiments of the present application provide a method and device for optimizing prompt words based on a large model, so as to solve the problem in the prior art that prompt words of a large model cannot be automatically optimized.
[0006] In a first aspect, the present application provides a method for optimizing prompt words based on a large model, the method comprising:
[0007] Acquire a feedback text given by the user in response to the reply of the first model, wherein the reply is output by the first model after corresponding processing according to the original prompt word;
[0008] Inputting the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement points corresponding to the feedback text according to a set format, wherein the target improvement points are used to describe the characters to be adjusted in the original prompt word and the target characters after adjustment;
[0009] According to the target character, the character to be adjusted in the original prompt word is adjusted.
[0010] In a second aspect, the present application provides a prompt word optimization device based on a large model, the device comprising:
[0011] An acquisition module, used to acquire a feedback text given by the user in response to the reply of the first large model, wherein the reply is output by the first large model after corresponding processing according to the original prompt word;
[0012] an analysis module, configured to input the feedback text and the first prompt text into a second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement points corresponding to the feedback text according to a set format, wherein the target improvement points are used to describe the characters to be adjusted in the original prompt word and the target characters after adjustment;
[0013] The adjustment module is used to adjust the characters to be adjusted in the original prompt word according to the target characters.
[0014] In a third aspect, the present application further provides an electronic device, comprising a processor, wherein the processor is configured to implement the steps of any of the above-mentioned large model-based prompt word optimization methods when executing a computer program stored in a memory.
[0015] In a fourth aspect, the present application further provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-mentioned large-model-based prompt word optimization methods.
[0016] Because in the embodiment of the present application, after the first large model performs corresponding processing according to the original prompt word and obtains a reply, it obtains the feedback text given by the user in response to the reply, and inputs the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement points corresponding to the feedback text according to the set format, that is, the large model is used to extract the adjustment opinions given in the feedback text of the user feedback, and the target improvement points are used to describe the characters to be adjusted in the original prompt word and the target characters after adjustment. When optimizing the prompt word, the characters to be adjusted in the original prompt word are adjusted according to the target characters, thereby realizing automatic optimization of the original prompt word. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 A schematic diagram of a process flow of a prompt word optimization process based on a large model provided in an embodiment of the present application;
[0019] Figure 2 A schematic diagram of a multi-agent architecture provided in an embodiment of the present application;
[0020] Figure 3 A schematic diagram of the structure of a prompt word optimization device based on a large model provided in an embodiment of the present application;
[0021] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the embodiment of the present application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiment is only a part of the embodiment of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of this application.
[0023] The embodiment of the present application provides a prompt word optimization method and device based on a large model. In the method, a feedback text given by a user in response to a first large model is obtained, and the response is output by the first large model after corresponding processing according to the original prompt word; the feedback text and the first prompt text are input into a second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement point corresponding to the feedback text according to a set format, and the target improvement point is used to describe the characters to be adjusted in the original prompt word and the target characters after adjustment; according to the target characters, the characters to be adjusted in the original prompt word are adjusted.
[0024] Figure 1 A schematic diagram of a process flow of a prompt word optimization process based on a large model provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the process includes the following steps:
[0025] S101: Obtaining feedback text given by a user in response to a reply of a first large model, wherein the reply is output by the first large model after corresponding processing according to an original prompt word.
[0026] The large model-based prompt word optimization method provided in the present application is applied to electronic devices, which may be servers, PCs, mobile terminals, etc.
[0027] In the early stage of developing a task, users may be more concerned about information A, so the information in the original prompt words is related to information A. However, as time goes by, users may be more concerned about information B. At this time, the original prompt words need to be optimized. The original prompt words refer to the text input into the first large model when the first large model is called.
[0028] When optimizing the original prompt words, in an embodiment of the present application, the feedback text given by the user to the reply of the first large model can be obtained. Among them, the reply is output by the first large model after corresponding processing according to the original prompt words. That is to say, the first large model outputs the corresponding reply after processing the corresponding data according to the original prompt words. After viewing the reply, the user can give feedback on the reply, and the received feedback can be used as feedback text. In an embodiment of the present application, the text input by the user after viewing the reply can be directly determined as feedback text. It is also possible to output the "user feedback" option while outputting the reply. When the user selects this option, a feedback page can be popped up, and the content of the user's feedback on the feedback page can be determined as feedback text. When the user gives feedback, the text can be directly input, or the feedback content can be recorded in the form of audio. The electronic device converts the audio into text, and the text can be used as feedback text. The feedback text can be one or more. When there are multiple feedback texts, the multiple feedback texts can be feedback from the same user or from different users.
[0029] S102: Input the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement points corresponding to the feedback text according to a set format, wherein the target improvement points are used to describe the characters to be adjusted in the original prompt words and the target characters after adjustment.
[0030] After obtaining the feedback text, the second largest model can be used to extract the knowledge in the feedback text, so as to determine the target improvement points that the user thinks. Among them, the second largest model can be any large model with semantic understanding ability. Exemplarily, the second largest model can be any large language model (LLM), and the second largest model can be the same as the first largest model or different. In the embodiment of the present application, the feedback text and the first prompt text can be input into the second largest model, so that the second largest model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement points corresponding to the feedback text according to the set format. In other words, the first prompt text is a text used to prompt the second largest model to perform what operation on the feedback text, and at the same time, the first prompt text also defines the format used by the second largest model when outputting the target improvement points. It should be noted that the first prompt text can also include analysis samples, so that the second largest model performs small sample learning when analyzing the semantics of the feedback text. Those skilled in the art can design the specific content included in the first prompt text as needed, and the embodiment of the present application does not limit this. The target improvement point output by the second largest model is a text used to describe the characters to be adjusted in the original prompt word and the target characters after adjustment. For example, the target improvement point can be "the user thinks that the current output result is not very reasonable, the current focus is on field A, and the user would like to pay more attention to field B", where "field A" in the original prompt word is the character to be adjusted, and "field B" is the target field after adjustment.
[0031] S103: adjusting the characters to be adjusted in the original prompt word according to the target characters.
[0032] Since the target improvement points output by the second largest model are output according to the set format, after obtaining the target improvement points, the characters corresponding to the character area to be adjusted can be determined according to the pre-designed format, and the target characters corresponding to the adjusted target character area can be determined. According to the determined target characters, the characters to be adjusted in the original prompt word are adjusted to complete the optimization of the original prompt word.
[0033] Assume that the original prompt is "Please analyze the following text based on the information provided in field A, and output the understanding process"; the target improvement point determined by the second largest model is "The user thinks that the current output result is not very reasonable, and the current focus is on field A, while the user would like to pay more attention to field B." According to the pre-configured setting format, it can be determined that "field A" is the character to be adjusted, and "field B" is the target character. Then, "field B" can be used to adjust the "field A" in the original prompt. Then, the adjusted prompt is "Please analyze the following text based on the information provided in field B, and output the understanding process."
[0034] In the embodiment of the present application, the original prompt word used when calling the first large model can be determined according to the preset prompt word template. When calling the first large model, the target field value corresponding to the preset field can be extracted from the preset data table of the database, and the target field value can be filled into the preset prompt word template to obtain the original prompt word. Then, in the process of optimizing the prompt word, after determining the target improvement point, in the preset data table, the target field value in the preset field can be modified to the target character.
[0035] By analyzing user feedback, we can understand user needs and satisfaction, and make corresponding adjustments and improvements based on the feedback.
[0036] Exemplarily, when the business goal is a table recall task, the agent responsible for recall needs to pay special attention to the table fields during the task processing. During the development process, the knowledge in the prompt words requires special attention to the first three fields of the table. However, with the passage of time and the accumulation of data, the overall knowledge has shifted, and only focusing on the first three fields has had a significant negative impact on the table recall task, resulting in a decrease in recall accuracy. In an embodiment of the present application, the feedback text of user feedback can be used to extract the fields that need to be paid attention to for the table recall task, namely the 2nd to 5th fields and the last field in the table. After extracting these new knowledge, they are updated to the corresponding prompt words, thereby improving the originally declining recall accuracy.
[0037] Because in the embodiment of the present application, after the first large model performs corresponding processing according to the original prompt word and obtains a reply, it obtains the feedback text given by the user in response to the reply, and inputs the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement points corresponding to the feedback text according to the set format, that is, the large model is used to extract the adjustment opinions given in the feedback text of the user feedback, and the target improvement points are used to describe the characters to be adjusted in the original prompt word and the target characters after adjustment. When optimizing the prompt word, the characters to be adjusted in the original prompt word are adjusted according to the target characters, thereby realizing automatic optimization of the original prompt word.
[0038] In order to improve the accuracy of prompt word optimization, based on the above embodiment, in the embodiment of the present application, if there are multiple feedback texts, before inputting the feedback text and the first prompt text into the second large model, the method further includes:
[0039] Determine the evaluation category corresponding to each feedback text, and group each feedback text to obtain a feedback group;
[0040] For each feedback group, respectively perform the subsequent step of inputting the feedback text and the first prompt text into the second large model;
[0041] After determining the target improvement point of the evaluation category corresponding to each feedback group, and before adjusting the characters to be adjusted in the original prompt word according to the target characters, the method further includes:
[0042] The target improvement points and the second prompt text corresponding to each feedback group are input into the third largest model, and each target improvement point is integrated using the third largest model according to the prompt of the second prompt text to obtain comprehensive improvement points, and the target improvement points are updated using the comprehensive improvement points.
[0043] Since the feedback text may include positive feedback and negative feedback, when multiple feedback texts are obtained, before the feedback text and the first prompt text are input into the second large model, in an embodiment of the present application, the evaluation category corresponding to each feedback text can also be determined. The evaluation category includes positive feedback and negative feedback. In other words, it is determined whether each feedback text is positive feedback or negative feedback. Positive feedback can be understood as the user's affirmation of the reply of the first large model, and negative feedback can be understood as the user's denial of the reply of the first large model, and there may be areas that need improvement. When determining the evaluation category corresponding to the feedback text, it can be determined whether the feedback text belongs to positive feedback or negative feedback based on the classification model that has been pre-trained.
[0044] After determining the evaluation category corresponding to each feedback text, each feedback text can be grouped according to the evaluation category corresponding to each feedback text to obtain a feedback group. In other words, feedback texts of the same evaluation category are determined as one feedback group, and the evaluation categories of all feedback texts included in the same feedback group are the same.
[0045] After each feedback group is determined, the subsequent step of inputting the feedback text and the first prompt text into the second largest model can be performed for each feedback group. That is to say, for each feedback group, the target improvement point corresponding to the feedback group is determined. When determining the target improvement point corresponding to each feedback group, for each feedback group, each feedback text and the first prompt text included in the feedback group can be input into the second largest model, and the second largest model can be used to analyze each feedback text according to the prompt of the first prompt text, and the semantics of these feedback texts can be combined to determine the target improvement point corresponding to the feedback group. It should be noted that any feedback group can include one feedback text or multiple feedback texts.
[0046] Since the opinions of different feedback texts from different users are different, and the opinions of feedback texts from different evaluation categories are even more different, all target improvement points determined by the second largest model can be integrated to determine the final improvement points. In the embodiment of the present application, after determining the target improvement points corresponding to each feedback group, before adjusting the characters to be adjusted in the original prompt word according to the target characters, the third largest model can be used to integrate all target improvement points.
[0047] In an embodiment of the present application, the target improvement point and the second prompt text corresponding to each feedback group can be input into the third largest model, and the third largest model can be used to integrate all the target improvement points according to the prompt of the second prompt text to obtain comprehensive improvement points, and the target improvement points can be updated using the determined comprehensive improvement points, so as to facilitate the subsequent adjustment of the original prompt words based on the updated target improvement points to achieve optimization of the prompt words.
[0048] In order to further improve the accuracy of prompt word optimization, based on the above embodiments, in the embodiment of the present application, the process of determining the evaluation category corresponding to any feedback text includes:
[0049] Determine the target score of the feedback text based on the pre-trained evaluation model;
[0050] According to the pre-saved correspondence between different scores and evaluation categories, the target evaluation category corresponding to the target score is determined, and the target evaluation category is determined as the evaluation category corresponding to the feedback text.
[0051] In order to determine the evaluation category corresponding to any feedback text, in an embodiment of the present application, each evaluation category may be classified according to the score, and the correspondence between different scores and evaluation categories may be saved.
[0052] When determining the evaluation category corresponding to any feedback text, the target score of the feedback text can be determined based on the pre-trained evaluation model. After the target score is determined, the target evaluation category corresponding to the target score can be determined based on the pre-saved correspondence between different scores and evaluation categories.
[0053] Specifically, assume that the evaluation model can give a score of 0-10 points for the feedback text, where the evaluation category corresponding to 0-5 points is negative feedback, and the evaluation category corresponding to 6-10 points is positive feedback. It should be noted that technicians in this field can add evaluation categories as needed, and can also divide the scores corresponding to different evaluation categories as needed, not limited to the above examples. If the target score of a feedback text is 3 points, since 3 points is within the score range of 0-5 points, the target evaluation category corresponding to the feedback text is negative feedback.
[0054] After the target evaluation category is determined, the target evaluation category may be determined as the evaluation category corresponding to the feedback text.
[0055] In order to further improve the accuracy of prompt word optimization, based on the above embodiments, in the embodiment of the present application, before determining the evaluation category corresponding to each feedback text, the method further includes:
[0056] Counting the number of feedback texts;
[0057] If the number of the feedback texts meets the preset threshold requirement, then continue to perform the subsequent step of determining the evaluation category corresponding to each feedback text;
[0058] If the number does not meet the preset threshold requirement, other feedback texts are cumulatively obtained until the number of obtained feedback texts meets the preset threshold requirement.
[0059] Since a small amount of feedback texts may have particularities, in the embodiment of the present application, after a preset number of feedback texts are accumulated and acquired, the prompt words may be optimized once.
[0060] In an embodiment of the present application, before determining the evaluation category corresponding to each feedback text, the number of currently acquired feedback texts may also be counted. If the number of the feedback texts meets the preset threshold requirement, the subsequent steps of determining the evaluation category corresponding to each feedback text may continue to be performed. If the number of the feedback texts does not meet the preset threshold requirement, other feedback texts may be accumulated until the number of acquired feedback texts meets the preset threshold requirement. Among them, the preset threshold requirement may be that the number of feedback texts is greater than N, and N may be any positive integer, for example, N=1, 5, 50, etc., and technicians in this field may configure the value of N as needed.
[0061] Specifically, assuming that the preset threshold is 80, the current cumulative number of feedback texts obtained is 55. Since the number 55 is less than the preset threshold 80, the number does not meet the preset threshold requirement, and other feedback texts can continue to be accumulated until the number of feedback texts obtained reaches 55, and then prompt word optimization is performed.
[0062] In order to further improve the accuracy of prompt word optimization, based on the above embodiments, in the embodiment of the present application, the step of inputting the feedback text and the first prompt text into the second large model includes:
[0063] Determine the target score for each feedback text based on the pre-trained evaluation model;
[0064] Sort each feedback text according to the order of the target score to obtain a feedback text sequence;
[0065] The feedback text sequence, the first prompt text and the third prompt text are spliced and input into the second large model, and the third prompt text is used to prompt the second large model to determine the target improvement point based on the weight corresponding to each feedback text when performing semantic analysis, wherein the target score of any feedback text with a high weight value is greater than the target score of any feedback text with a low weight value.
[0066] In the actual application process, some users give very intuitive feedback when giving feedback, while some users give very vague feedback. For example, the feedback text "the field of the result query you gave should be A, not B" is very intuitive, and the feedback text "the result you gave is not what I want" is also negative feedback, but the feedback text is very vague, and it is not very helpful for the upgrade of the prompt word. Therefore, in the embodiment of the present application, when the feedback text and the first prompt text are input into the second largest model, the target score of each feedback text can be determined based on the evaluation model trained in advance. The target score is used to describe the role of the feedback text in optimizing the prompt word. The larger the target score, the more intuitive the user's point of view is, and the stronger the optimization help for the prompt word is. Continuing to use the above example as an example to illustrate, the target score corresponding to the feedback text "the field of the result query you gave should be A, not B" can be 3, and the target score corresponding to the feedback text "the result you gave is not what I want" can be 0.
[0067] After determining the target score of each feedback text, each feedback text may be sorted in order of the target score to obtain a feedback text sequence. For example, the feedback texts may be arranged in order of the target score from large to small to obtain a feedback text sequence.
[0068] After obtaining the feedback text sequence, the feedback text sequence, the first prompt text and the third prompt text can be spliced and input into the second largest model. The third prompt text is input into the second largest model to prompt the second largest model to determine the target improvement point based on the weight corresponding to each feedback text when performing semantic analysis, wherein the target score of any feedback text with a high weight value is greater than the target score of the feedback text with a low weight value. In other words, in the process of determining the target improvement point, the second largest model gives priority to the semantics of the feedback text with a higher target score, while the semantics of the feedback text with a lower target score are relatively less important.
[0069] In the embodiment of the present application, a small model is used to analyze user feedback and rate it. By assigning different weights to positive and negative feedback, the second largest model can better understand the user's needs and pain points, so as to optimize the prompt words in a targeted manner.
[0070] In order to further improve the accuracy of prompt word optimization, based on the above embodiments, in the embodiment of the present application, the target score of any feedback text is determined based on the pre-trained evaluation model, including:
[0071] Obtaining a question-answer pair of a conversation conducted before the feedback text, wherein the question-answer pair includes an input text and an output text of the first large model;
[0072] The feedback text and the question-answer pair are concatenated and input into the evaluation model to obtain the target score.
[0073] In order to further improve the accuracy of prompt word optimization, when determining the target score of any feedback text, a question-answer pair of a conversation before the feedback text can be obtained, and the question-answer pair includes the input text and output text of the first large model. In other words, it is determined for which question-answer pair the feedback text is raised.
[0074] When determining the target score corresponding to the feedback text, the feedback text and the question-answer pair may be concatenated and input into the evaluation model, and the evaluation model processes the received input data to obtain the target score.
[0075] In an embodiment of the present application, the evaluation model is obtained through pre-training, and the device for training the evaluation model may be the same as or different from the electronic device for optimizing the prompt word. The training process of the evaluation model is described below. In an embodiment of the present application, a training set may be obtained, the training set including sample data, the sample data consisting of sample question-answer pairs and sample feedback text, and the training set also including a label corresponding to each sample data, the label being used to identify the standard score of the corresponding sample data.
[0076] In order to train the original evaluation model, in an embodiment of the present application, after obtaining the training set, each sample data in the training set can be input into the original evaluation model in turn, and the original evaluation model determines the prediction score corresponding to each sample data.
[0077] After the predicted score is determined, the loss value is determined according to the deviation between the predicted score and the corresponding standard score, and the parameters of the original evaluation model are adjusted based on the loss value to obtain the evaluation model.
[0078] The evaluation model that reaches the convergence condition can be used in the above embodiments to determine the target score.
[0079] In the embodiment of the present application, a small model with low parameter quantity is used for training. During training, the input merges the question-answer pair of the previous round and the feedback text of the current user, and the output score range can be 0-10 points. Among them, the evaluation category corresponding to 0-3 points can be negative feedback, the evaluation category corresponding to 4-6 points can be neutral evaluation, and the evaluation category corresponding to 7-10 points can be positive feedback. Those skilled in the art can configure the evaluation category and the score range as needed, not limited to the above examples.
[0080] In order to further improve the accuracy of prompt word optimization, based on the above embodiments, in the embodiment of the present application, before inputting the feedback text and the first prompt text into the second large model, the method further includes:
[0081] Obtaining a question-answer pair of a conversation conducted before receiving the feedback text, wherein the question-answer pair includes an input text and an output text of the first large model;
[0082] The step of inputting the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, comprises:
[0083] The feedback text, the question-answer pair and the first prompt text are input into the second large model, so that the second large model analyzes the semantics of the feedback text and the question-answer pair according to the prompt of the first prompt text, and determines the target improvement points corresponding to the feedback text.
[0084] Since the feedback text input by the user is made in response to the reply output by the first largest model in the previous round, in order to further improve the accuracy of prompt word optimization, before the feedback text and the first prompt text are input into the second largest model, a question-answer pair of a conversation before the received feedback text can also be obtained, and the question-answer pair includes the input text and output text of the first largest model.
[0085] When determining the target improvement points later, the second largest model can be used to analyze the question and answer pair and the feedback text to determine the target improvement points corresponding to the feedback text. That is to say, the question and answer pair of the conversation before receiving the feedback text is input into the second largest model to help the second largest model understand and extract the target improvement points. In an embodiment of the present application, after obtaining the question and answer pair, when the feedback text and the first prompt text are input into the second largest model, the question and answer pair can be input into the second largest model together, so that when the second largest model determines the target improvement points corresponding to the feedback text, it can determine the target improvement points corresponding to the feedback text according to the specific application process. In an embodiment of the present application, the feedback text, the question and answer pair and the first prompt text can be input into the second largest model, so that the second largest model analyzes the semantics of the feedback text and the question and answer pair according to the prompt of the first prompt text, and determines the target improvement points corresponding to the feedback text.
[0086] In order to further improve the accuracy of prompt word optimization, on the basis of the above embodiments, in the embodiment of the present application, the process of obtaining the first prompt text includes:
[0087] Determining an evaluation category corresponding to the feedback text;
[0088] Obtain a first prompt text stored for the evaluation category.
[0089] Since the feedback text of positive feedback is an affirmation of the original prompt word, for positive feedback, the target improvement point output by the second largest model can be to strengthen the corresponding characters in the prompt word, while the feedback text of negative feedback is a negation of the original prompt word, and for negative feedback, the target improvement point output by the second largest model can be to reflect on the cause of the error and extract the key information that should be paid attention to when outputting the correct content. Therefore, in an embodiment of the present application, different prompt texts can be saved for different evaluation categories. When determining the first prompt text input into the second largest model, the evaluation category corresponding to the feedback text can be determined, and the first prompt text pre-saved for the evaluation category can be obtained.
[0090] Exemplarily, the prompt text saved for the negative feedback evaluation category may be:
[0091] "Description: Thoroughly analyze the generated answer. If the user prompt is not empty, pay attention to the difference between the generated answer and the user prompt.
[0092] Identify any discrepancies, misunderstandings, or errors. Provide clear insights, principles, or guidelines that can be drawn from this analysis to improve future responses.
[0093] We focus not on this one data point but on the general principle.
[0094] Reasoning: <Discuss why the generated answer is not satisfactory to the user>
[0095] Insight: <Which principles should be carefully considered to improve future performance>"
[0096] If the above prompt text is determined as the first prompt text when determining the target improvement point, the input data of the second largest model can be:
[0097] "User question: {Question}
[0098] Generated answer: {Answer}
[0099] User feedback: {response}
[0100] User tips {tips}
[0101] Note: Thoroughly analyze the generated answer. If the user prompt is not empty, pay attention to the difference between the generated answer and the user prompt.
[0102] Identify any discrepancies, misunderstandings, or errors. Provide clear insights, principles, or guidelines that can be drawn from this analysis to improve future responses.
[0103] We focus not on this one data point but on the general principle.
[0104] Reasoning: <Discuss why the generated answer is not satisfactory to the user>
[0105] Insight: <Which principles should be carefully considered to improve future performance>"
[0106] The "Question" in the above input data represents the user's question, that is, the input text of the first largest model; the "Answer" represents the reply of the first largest model, that is, the output text of the first largest model; the "response" represents the feedback text given by the user for the reply "Answer"; and the "tips" represents some special prompts given by the user when making feedback to remind the second largest model to focus on the analysis. The "tips" can be empty or not empty.
[0107] In order to further improve the accuracy of prompt word optimization, based on the above embodiments, in the embodiment of the present application, before inputting the feedback text and the first prompt text into the second large model, the method further includes:
[0108] Determining whether the evaluation category corresponding to the feedback text is a preset category, wherein the preset category includes positive feedback and negative feedback;
[0109] If so, continue to execute the subsequent step of inputting the feedback text and the first prompt text into the second large model.
[0110] Since users may not all provide feedback on the accuracy of the reply after receiving the reply corresponding to the first large model, it is very likely that after receiving the reply of the first large model, the user will continue to ask questions about the reply, and the questions do not contain prompt word optimization suggestions. Therefore, in an embodiment of the present application, before inputting the feedback text and the first prompt text into the second large model, it can also be determined whether the evaluation category corresponding to the feedback text is a preset category, and the preset category includes positive feedback and negative feedback. If so, continue to execute the subsequent step of inputting the feedback text and the first prompt text into the second large model. If not, the feedback text can be deleted. In other words, only when the evaluation category of the feedback text is a preset category, the target improvement point is determined based on the feedback text.
[0111] In the embodiment of the present application, the evaluation category corresponding to the feedback text may be positive feedback, negative feedback or neutral. When the evaluation category corresponding to any feedback text is neutral, it can be considered that the feedback text is not a text for providing feedback on the correctness of the reply, and the feedback text can be deleted.
[0112] The following is a description of the process of the prompt word optimization method based on a large model in conjunction with a specific embodiment. The prompt word optimization method based on a large model provided in this application can be applied to a multi-agent process. In the embodiment of this application, a complete multi-agent process can be constructed according to the requirements of the business process. The multi-agent process can cover all business links and can effectively handle various tasks and requirements.
[0113] Figure 2 A schematic diagram of a multi-agent architecture provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the multi-agent business framework includes four agents, namely a central agent and three task agents. Among them, the central agent is configured to perform: analyze and process user needs, and finally assign the processed tasks to the corresponding task agents. After receiving the task, the task agent can search the corresponding fields in the database according to the received task requirements, fill in the prompt word template, and obtain the original prompt word. And input the original prompt word into the first large model called to obtain the corresponding reply. After completing the task, the task agent passes the result to the central agent for integration, and finally the central agent returns it to the user.
[0114] In the process of the intelligent agent performing the task, the prompt word can be optimized synchronously, that is, the prompt word optimization process runs in parallel with the business process. After obtaining the user's feedback text, the feedback text can be stored in the database. When the prompt word optimization condition is met, the feedback text can be obtained from the database and input into the evaluation model. The evaluation model can evaluate the effect and quality of the reply generated by the first large model according to the user's feedback and the preset evaluation criteria. According to the target score of the feedback text determined by the evaluation model, the evaluation category of the feedback text can be determined. The evaluation category can be positive feedback, neutral or negative feedback. For the feedback text of positive feedback, these feedback texts and the first prompt text corresponding to the positive feedback can be input into the second large model to determine the target improvement point corresponding to the feedback text of the positive feedback. For the feedback text of negative feedback, these feedback texts and the first prompt text corresponding to the negative feedback can be input into the second large model to determine the target improvement point corresponding to the feedback text of the negative feedback.
[0115] After all target improvement points are obtained, all target improvement points can be integrated to obtain comprehensive improvement points, which are determined as target improvement points, and the characters to be adjusted of the original prompt words in the database are adjusted according to the target characters in the target improvement points.
[0116] Through the prompt word optimization method provided in this application, the execution mode and results of the process can be continuously optimized and improved. This method can effectively improve the efficiency and accuracy of prompt word optimization, and provide users with better experience and services through the optimization of prompt words. It can also continuously improve process efficiency and accuracy, improve user satisfaction, and quickly respond to changing needs and problems.
[0117] Based on the same inventive concept, the embodiment of the present application also provides a prompt word optimization device based on a large model, Figure 3 A schematic diagram of the structure of a prompt word optimization device based on a large model provided in an embodiment of the present application, the device includes:
[0118] An acquisition module 301 is used to acquire a feedback text given by a user in response to a reply of the first large model, wherein the reply is output by the first large model after corresponding processing according to the original prompt word;
[0119] The analysis module 302 is used to input the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement points corresponding to the feedback text according to a set format, wherein the target improvement points are used to describe the characters to be adjusted in the original prompt word and the target characters after adjustment;
[0120] The adjustment module 303 is used to adjust the characters to be adjusted in the original prompt word according to the target characters.
[0121] In a possible implementation manner, if there are multiple feedback texts, the device further includes:
[0122] A determination module 304 is used to determine the evaluation category corresponding to each feedback text, and group each feedback text to obtain a feedback group;
[0123] The analysis module 302 is specifically used to execute the subsequent step of inputting the feedback text and the first prompt text into the second large model for each feedback group;
[0124] Integration module 305 is used to input the target improvement point and the second prompt text corresponding to each feedback group into the third largest model, use the third largest model to integrate each target improvement point according to the prompt of the second prompt text to obtain a comprehensive improvement point, and use the comprehensive improvement point to update the target improvement point.
[0125] In a possible implementation, the determination module 304 is specifically used to determine the target score of the feedback text based on a pre-trained evaluation model; determine the target evaluation category corresponding to the target score according to the pre-saved correspondence between different scores and evaluation categories, and determine the target evaluation category as the evaluation category corresponding to the feedback text.
[0126] In a possible implementation, the device further includes:
[0127] The judgment module 306 is used to count the number of the feedback texts; if the number of the feedback texts meets the preset threshold requirement, continue to execute the subsequent step of determining the evaluation category corresponding to each feedback text; if the number does not meet the preset threshold requirement, accumulate and obtain other feedback texts until the number of the obtained feedback texts meets the preset threshold requirement.
[0128] In a possible implementation, the analysis module 302 is specifically used to determine the target score of each feedback text based on a pre-trained evaluation model; sort each feedback text in order of the target score to obtain a feedback text sequence; splice the feedback text sequence, the first prompt text and the third prompt text and input them into the second large model, the third prompt text is used to prompt the second large model to determine the target improvement point based on the weight corresponding to each feedback text when performing semantic analysis, wherein the target score of any feedback text with a high weight value is greater than the target score of any feedback text with a low weight value.
[0129] In a possible implementation, the determination module 304 is specifically used to obtain a question-and-answer pair of a conversation conducted before the feedback text, wherein the question-and-answer pair includes an input text and an output text of the first large model; the feedback text and the question-and-answer pair are concatenated and input into the evaluation model to obtain the target score.
[0130] In a possible implementation, the acquisition module 301 is further used to acquire a question-answer pair of a conversation conducted before receiving the feedback text, wherein the question-answer pair includes an input text and an output text of the first large model;
[0131] The analysis module 302 is specifically used to input the feedback text, the question and answer pair and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text and the question and answer pair according to the prompt of the first prompt text, and determines the target improvement points corresponding to the feedback text.
[0132] In a possible implementation, the determination module 304 is further configured to determine an evaluation category corresponding to the feedback text;
[0133] The acquisition module 301 is further used to acquire a first prompt text stored for the evaluation category.
[0134] In a possible implementation, the judgment module 306 is also used to judge whether the evaluation category corresponding to the feedback text is a preset category, and the preset category includes positive feedback and negative feedback; if so, continue to execute the subsequent step of inputting the feedback text and the first prompt text into the second large model.
[0135] Based on the same inventive concept, an embodiment of the present application further provides an electronic device, Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, it includes: a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404;
[0136] The memory 403 stores a computer program. When the program is executed by the processor 401, the processor 401 performs the following steps:
[0137] Acquire a feedback text given by the user in response to the reply of the first model, wherein the reply is output by the first model after corresponding processing according to the original prompt word;
[0138] Inputting the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement points corresponding to the feedback text according to a set format, wherein the target improvement points are used to describe the characters to be adjusted in the original prompt word and the target characters after adjustment;
[0139] According to the target character, the character to be adjusted in the original prompt word is adjusted.
[0140] In a possible implementation manner, if there are multiple feedback texts, before inputting the feedback text and the first prompt text into the second large model, the method further includes:
[0141] Determine the evaluation category corresponding to each feedback text, and group each feedback text to obtain a feedback group;
[0142] For each feedback group, respectively, performing the subsequent step of inputting the feedback text and the first prompt text into the second large model;
[0143] After determining the target improvement point of the evaluation category corresponding to each feedback group, and before adjusting the characters to be adjusted in the original prompt word according to the target characters, the method further includes:
[0144] The target improvement points and the second prompt text corresponding to each feedback group are input into the third largest model, and each target improvement point is integrated using the third largest model according to the prompt of the second prompt text to obtain comprehensive improvement points, and the target improvement points are updated using the comprehensive improvement points.
[0145] In a possible implementation, the process of determining the evaluation category corresponding to any feedback text includes:
[0146] Determine the target score of the feedback text based on the pre-trained evaluation model;
[0147] According to the pre-saved correspondence between different scores and evaluation categories, the target evaluation category corresponding to the target score is determined, and the target evaluation category is determined as the evaluation category corresponding to the feedback text.
[0148] In a possible implementation manner, before determining the evaluation category corresponding to each feedback text, the method further includes:
[0149] Counting the number of feedback texts;
[0150] If the number of the feedback texts meets the preset threshold requirement, then continue to perform the subsequent step of determining the evaluation category corresponding to each feedback text;
[0151] If the number does not meet the preset threshold requirement, other feedback texts are cumulatively obtained until the number of obtained feedback texts meets the preset threshold requirement.
[0152] In a possible implementation manner, inputting the feedback text and the first prompt text into the second large model includes:
[0153] Determine the target score for each feedback text based on the pre-trained evaluation model;
[0154] Sort each feedback text according to the order of the target score to obtain a feedback text sequence;
[0155] The feedback text sequence, the first prompt text and the third prompt text are spliced and input into the second large model, and the third prompt text is used to prompt the second large model to determine the target improvement point based on the weight corresponding to each feedback text when performing semantic analysis, wherein the target score of any feedback text with a high weight value is greater than the target score of any feedback text with a low weight value.
[0156] In a possible implementation, determining a target score for any feedback text based on a pre-trained evaluation model includes:
[0157] Obtaining a question-answer pair of a conversation conducted before the feedback text, wherein the question-answer pair includes an input text and an output text of the first large model;
[0158] The feedback text and the question-answer pair are concatenated and input into the evaluation model to obtain the target score.
[0159] In a possible implementation manner, before inputting the feedback text and the first prompt text into the second large model, the method further includes:
[0160] Obtaining a question-answer pair of a conversation conducted before receiving the feedback text, wherein the question-answer pair includes an input text and an output text of the first large model;
[0161] The step of inputting the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, comprises:
[0162] The feedback text, the question-answer pair and the first prompt text are input into the second large model, so that the second large model analyzes the semantics of the feedback text and the question-answer pair according to the prompt of the first prompt text, and determines the target improvement points corresponding to the feedback text.
[0163] In a possible implementation, the process of obtaining the first prompt text includes:
[0164] Determining an evaluation category corresponding to the feedback text;
[0165] Obtain a first prompt text stored for the evaluation category.
[0166] In a possible implementation manner, before inputting the feedback text and the first prompt text into the second large model, the method further includes:
[0167] Determining whether the evaluation category corresponding to the feedback text is a preset category, wherein the preset category includes positive feedback and negative feedback;
[0168] If so, continue to execute the subsequent step of inputting the feedback text and the first prompt text into the second large model.
[0169] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 402 is used for communication between the above electronic device and other devices. The memory may include a random access memory (RAM) and may also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0170] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0171] On the basis of the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program that can be executed by a processor. When the program runs on the processor, the processor implements the steps of the large model-based prompt word optimization method described in the above embodiments.
[0172] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0173] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0174] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0175] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0176] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A prompt word optimization method based on a large model, characterized in that: The method comprises: Acquire a feedback text given by the user in response to the reply of the first model, wherein the reply is output by the first model after corresponding processing according to the original prompt word; Inputting the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, and outputs the target improvement points corresponding to the feedback text according to a set format, wherein the target improvement points are used to describe the characters to be adjusted in the original prompt word and the target characters after adjustment; According to the target character, the character to be adjusted in the original prompt word is adjusted.
2. The method according to claim 1, characterized in that: If there are multiple feedback texts, before inputting the feedback texts and the first prompt text into the second large model, the method further includes: Determine the evaluation category corresponding to each feedback text, and group each feedback text to obtain a feedback group; For each feedback group, respectively, performing the subsequent step of inputting the feedback text and the first prompt text into the second large model; After determining the target improvement point of the evaluation category corresponding to each feedback group, and before adjusting the characters to be adjusted in the original prompt word according to the target characters, the method further includes: The target improvement points and the second prompt text corresponding to each feedback group are input into the third largest model, and each target improvement point is integrated using the third largest model according to the prompt of the second prompt text to obtain comprehensive improvement points, and the target improvement points are updated using the comprehensive improvement points.
3. The method according to claim 2, characterized in that The process of determining the evaluation category corresponding to any feedback text includes: Determine the target score of the feedback text based on the pre-trained evaluation model; According to the pre-saved correspondence between different scores and evaluation categories, the target evaluation category corresponding to the target score is determined, and the target evaluation category is determined as the evaluation category corresponding to the feedback text.
4. The method according to claim 2, characterized in that: Before determining the evaluation category corresponding to each feedback text, the method further includes: Counting the number of the feedback texts; If the number of the feedback texts meets the preset threshold requirement, then continue to perform the subsequent step of determining the evaluation category corresponding to each feedback text; If the number does not meet the preset threshold requirement, other feedback texts are cumulatively obtained until the number of obtained feedback texts meets the preset threshold requirement.
5. The method according to claim 4, characterized in that The step of inputting the feedback text and the first prompt text into the second large model comprises: Determine the target score for each feedback text based on the pre-trained evaluation model; Sort each feedback text according to the order of the target score to obtain a feedback text sequence; The feedback text sequence, the first prompt text and the third prompt text are spliced and input into the second large model, and the third prompt text is used to prompt the second large model to determine the target improvement point based on the weight corresponding to each feedback text when performing semantic analysis, wherein the target score of any feedback text with a high weight value is greater than the target score of any feedback text with a low weight value.
6. The method according to claim 3 or 5, characterized in that: Based on the pre-trained evaluation model, determine the target score of any feedback text, including: Obtaining a question-answer pair of a conversation conducted before the feedback text, wherein the question-answer pair includes an input text and an output text of the first large model; The feedback text and the question-answer pair are concatenated and input into the evaluation model to obtain the target score.
7. The method according to claim 1 or 2, characterized in that: Before inputting the feedback text and the first prompt text into the second large model, the method further comprises: Obtaining a question-answer pair of a conversation conducted before receiving the feedback text, wherein the question-answer pair includes an input text and an output text of the first large model; The step of inputting the feedback text and the first prompt text into the second large model, so that the second large model analyzes the semantics of the feedback text according to the prompt of the first prompt text, comprises: The feedback text, the question-answer pair and the first prompt text are input into the second large model, so that the second large model analyzes the semantics of the feedback text and the question-answer pair according to the prompt of the first prompt text, and determines the target improvement points corresponding to the feedback text.
8. The method according to claim 1, characterized in that The process of obtaining the first prompt text includes: Determining an evaluation category corresponding to the feedback text; Obtain a first prompt text stored for the evaluation category.
9. The method according to claim 8, characterized in that Before inputting the feedback text and the first prompt text into the second large model, the method further comprises: Determining whether the evaluation category corresponding to the feedback text is a preset category, wherein the preset category includes positive feedback and negative feedback; If so, continue to execute the subsequent step of inputting the feedback text and the first prompt text into the second large model.
10. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to implement the steps of the prompt word optimization method based on a large model as claimed in any one of claims 1 to 9 when executing a computer program stored in a memory.
Citation Information
Cited By
Method and device for generating answers
CN120822518A
AI agent construction method based on continuous and automatic optimization of user marks
CN121327082A
Prompt word optimization method, electronic equipment, storage medium and program product
CN121480506A