Adjustment and optimization prompting method and device and storage medium

By guiding the first model to perform Q&A during the prompt tuning process, and optimizing the response to the user's original prompts using context information, the problem of low computing resource consumption and practicality in the prior art is solved, and a more accurate and efficient user experience is achieved.

CN120086313APending Publication Date: 2025-06-03RICOH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311641388.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-30
Publication Date
2025-06-03

AI Technical Summary

Technical Problem

The prior art occupies a large amount of computing resources during the prompt tuning process, consumes a lot of time, and is less practical for variable and differentiated tasks for individual users.

Method used

By guiding the first model to start a question-and-answer process based on the content of the user's original prompt, the first model is assisted in answering the original prompt with context information obtained during the question-and-answer process, thereby generating a more accurate response.

Benefits of technology

It improves the accuracy of the response of the large language model to the user's original prompts, improves the user experience, and reduces the probability of multiple inputs from users due to dissatisfaction with the generation of results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120086313A_ABST
    Figure CN120086313A_ABST
Patent Text Reader

Abstract

The invention provides a prompt tuning method and device and a storage medium, and relates to the technical field of machine learning and natural language processing.The prompt tuning method comprises the steps that an original prompt input by a user is received; guiding a first model to start a question and answer process based on the content of the original prompt, and requesting the first model to answer the original prompt according to the original prompt and context information obtained in the question and answer process; and obtaining an answer to the original prompt generated by the first model. According to the method, the first model is guided to start the question-answering process based on the content of the original prompt, so that the first model can be assisted in answering the original prompt by utilizing the context information obtained in the question-answering process, and when the first model answers the original prompt, the question-answering efficiency of the first model is improved. More accurate answers can be generated based on the context information, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine learning and natural language processing (NLP, Natural Language Processing), and particularly relates to a prompt tuning method, device, and storage medium. Background Art

[0002] In recent years, large language models (hereinafter referred to as large models) represented by ChatGPT, ChatGLM, etc. have become the focus of attention in the field of artificial intelligence due to their excellent generation capabilities and broad application prospects. These large models have demonstrated amazing potential in many fields such as natural language processing, dialogue systems, and text creation, driving the development of intelligent interaction technologies. However, in practical applications, the "prompt" as the input of the large model greatly affects the quality of the model's generated results. How to accurately guide the large model to generate text of a specific type or content has become an important challenge.

[0003] "Prompt tuning" aims to optimize the prompts input by users and guide the large model to more accurately generate outputs that meet user needs. Currently, some companies hire professional prompt engineers to perform prompt tuning for different tasks, while another part of the companies or service providers offer automated prompt tuning services. Users can complete the tuning of any prompt by inputting on their websites or by calling the Application Programming Interface (API). Additionally, if automated prompt tuning can be integrated into the preprocessing module of the large model service, it can greatly improve the accuracy of the large model's response to user prompts, reduce the probability of users inputting multiple times due to dissatisfaction with the generated results, and thus significantly enhance the user experience.

[0004] A prompt tuning method in related technologies, for a target task specified by a user, fills the input / output pairs of the task given by the user into a fixed template, and allows the large model to generate candidate prompts based on these input / output pairs. For each generated candidate prompt, it inputs the candidate prompt and the evaluation input / output pairs into the large model to obtain the generated results, and evaluates the candidate prompt by scoring the generated results. Then, it selects the candidate prompt with the highest score in the evaluation as the optimal prompt for the target task. The above method uses the input / output pair data of the target task to generate / evaluate candidate prompts, which will consume a large amount of computing resources and time. In addition, due to the large number of target tasks specified by individual users and the relatively large differences between tasks, and it is also unlikely that individual users will provide the input / output pair data of the target tasks, so the practicality of the above method is relatively low. Summary of the Invention

[0005] At least one embodiment of the present application provides a prompt tuning method, apparatus, and storage medium. By tuning the original prompt input by the user, the accuracy of the response of the large language model can be improved, and the user experience can be enhanced.

[0006] To solve the above technical problems, the present application is implemented as follows:

[0007] In a first aspect, an embodiment of the present application provides a prompt tuning method, including:

[0008] Receiving the original prompt input by the user;

[0009] Guiding the first model to start a question-and-answer process based on the content of the original prompt, and requesting the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process, where the question-and-answer process includes at least one of the following: the first model asks a question, and the second model answers; the first model asks a question and answers;

[0010] Obtaining the answer to the original prompt generated by the first model.

[0011] Optionally, guiding the first model to start a question-and-answer process based on the content of the original prompt, and requesting the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process includes:

[0012] Generating an optimized prompt based on the original prompt and a preset prompt template, and inputting the optimized prompt into the first model, where the prompt template is used to guide the first model to start a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process.

[0013] Optionally, generating an optimized prompt based on the original prompt and a preset prompt template, and inputting the optimized prompt into the first model includes:

[0014] Generating a first optimized prompt based on the original prompt and a preset first prompt template, and inputting the first optimized prompt into the first model to obtain at least one question output by the first model; where the first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt;

[0015] Generating a first intermediate prompt based on the original prompt, the at least one question, and a preset second prompt template, and inputting the first intermediate prompt into the second model to obtain the answer output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the question;

[0016] Generate a second optimized prompt based on the original prompt, the answer output by the second model, and a third prompt template, and input the second optimized prompt into the first model, where the third prompt template is used to prompt the original prompt and the answer output by the second model to the first model, and request the first model to answer the original prompt.

[0017] Optionally, generating an optimized prompt based on the original prompt and a preset prompt template and inputting the optimized prompt into the first model includes:

[0018] Generate a first optimized prompt based on the original prompt and a preset first prompt template, and input the first optimized prompt into the first model to obtain at least one question output by the first model; where the first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt;

[0019] Determine a first type of question and a second type of question among the at least one question, where the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer;

[0020] When there is a question of the first type among the at least one question, generate a second intermediate prompt based on the original prompt, the question of the first type, and a preset second prompt template, and input the second intermediate prompt into the second model to obtain the answer output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the question of the first type;

[0021] When there is a question of the second type among the at least one question, prompt the question of the second type to the user and receive the answer input by the user;

[0022] Generate a third optimized prompt based on the original prompt, the first answer, and a third prompt template, and input the third optimized prompt into the first model, where the third prompt template is used to prompt the original prompt and the first answer to the first model and request the first model to answer the original prompt; the first answer includes: the answer output by the second model, and / or, the answer input by the user.

[0023] Optionally, generating an optimized prompt based on the original prompt and a preset prompt template and inputting the optimized prompt into the first model includes:

[0024] Generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and input the fourth optimized prompt into the first model to obtain an answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, and request the first model to ask questions and output answers according to the content of the original prompt;

[0025] Generate a fifth optimized prompt based on the original prompt and a fifth prompt template, and input the fifth optimized prompt into the first model, wherein the fifth prompt template is used to prompt the first model with the original prompt and request the first model to answer the original prompt.

[0026] Optionally, the generating an optimized prompt based on the original prompt and a preset prompt template and inputting the optimized prompt into the first model includes:

[0027] Generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and input the fourth optimized prompt into the first model to obtain an answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, and request the first model to ask questions and output answers according to the content of the original prompt;

[0028] In the case that the answer output by the first model includes at least one first question that the first model cannot answer, generate a third intermediate prompt based on the original prompt, the at least one first question, and a preset second prompt template, and input the third intermediate prompt into a second model to obtain an answer output by the second model; wherein, the second prompt template is used to prompt the second model with the content of the original prompt and request the second model to answer the first question;

[0029] Generate a sixth optimized prompt based on the original prompt, the second answer, and a third prompt template, and input the sixth optimized prompt into the first model, wherein the third prompt template is used to prompt the first model with the original prompt and the second answer and request the first model to answer the original prompt, and the second answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question that the first model can answer.

[0030] Optionally, the generating an optimized prompt based on the original prompt and a preset prompt template and inputting the optimized prompt into the first model includes:

[0031] Generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and input the fourth optimized prompt into the first model to obtain an answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, and request the first model to ask questions and output answers according to the content of the original prompt;

[0032] In the case that the answer output by the first model includes at least one first question proposed by the first model and not answered by the first model, determine the first type of questions and the second type of questions among the at least one first question, where the first type of questions are questions that the second model can answer, and the second type of questions are questions that the second model cannot answer;

[0033] In the case that there are the first type of questions among the at least one first question, generate a fourth intermediate prompt based on the original prompt, the first type of questions, and a preset second prompt template, and input it into the second model to obtain the answer output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of questions;

[0034] In the case that there are the second type of questions among the at least one first question, prompt the second type of questions to the user and receive the answer input by the user;

[0035] Generate a seventh optimized prompt based on the original prompt, the third answer, and a third prompt template, and input it into the first model, where the third prompt template is used to prompt the original prompt and the third answer to the first model and request the first model to answer the original prompt, and the third answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question; the second question is a question proposed by the first model and can be answered by the first model.

[0036] Optionally, obtaining the answer generated by the first model to the original prompt includes:

[0037] Receive the answer output by the first model to the original prompt and display it.

[0038] Optionally, generating an optimized prompt based on the original prompt and a preset prompt template and inputting it into the first model includes:

[0039] Generate an eighth optimized prompt based on the original prompt and a sixth prompt template, and input it into the first model, where the sixth prompt template is specifically used to prompt the content of the original prompt, request the first model to ask questions and answer according to the content of the original prompt, and answer the original prompt.

[0040] Optionally, obtaining the answer generated by the first model to the original prompt includes:

[0041] Receive the answer information output by the first model;

[0042] When the response information output by the first model includes at least one first question proposed by the first model and unable to be answered, a fifth intermediate prompt is generated based on the original prompt, the at least one first question, and a preset second prompt template and input into the second model to obtain the response output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first question.

[0043] A ninth optimized prompt is generated based on the original prompt, the fourth response, and a seventh prompt template and input into the first model, wherein the seventh prompt template is used to prompt the original prompt and the fourth response to the first model and request the first model to answer the original prompt again, and the fourth response includes: the response output by the second model, and / or, the response of the first model to at least one second question; the second question is a question proposed by the first model and able to be answered.

[0044] Optionally, obtaining the response of the first model to the original prompt includes:

[0045] Receiving the response information output by the first model;

[0046] When the response information output by the first model includes at least one first question that the first model cannot answer, determine the first type of question and the second type of question among the at least one first question, wherein the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer;

[0047] When there is the first type of question among the at least one first question, a sixth intermediate prompt is generated based on the original prompt, the first type of question, and a preset second prompt template and input into the second model to obtain the response output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of question.

[0048] When there is the second type of question among the at least one first question, prompt the second type of question to the user and receive the response input by the user;

[0049] Generate a tenth optimized prompt based on the original prompt, the fifth response, and the seventh prompt template, and input the tenth optimized prompt into the first model. The seventh prompt template is used to prompt the first model with the original prompt and the fifth response, and request the first model to answer the original prompt again. The fifth response includes one or more of the following responses: the response input by the user; the response output by the second model; the response of the first model to at least one second question, where the second question is a question that the first model can answer.

[0050] Optionally, obtaining the response of the first model to the original prompt further includes:

[0051] When the response information includes the response of the first model to the original prompt, display the response of the first model to the original prompt.

[0052] In a second aspect, an embodiment of the present application provides a prompt optimization device, including:

[0053] A receiving module, configured to receive an original prompt input by a user;

[0054] A guiding module, configured to guide the first model to start a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process. The question-and-answer process includes at least one of the following: the first model asks a question and the second model answers; the first model asks a question and answers it;

[0055] An obtaining module, configured to obtain the response of the first model to the original prompt.

[0056] Optionally, the guiding module includes:

[0057] A prompt construction module, configured to generate an optimized prompt based on the original prompt and a preset prompt template, and input the optimized prompt into the first model. The prompt template is used to guide the first model to start a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process.

[0058] Optionally, the prompt construction module includes:

[0059] A first construction interaction module, configured to generate a first optimized prompt based on the original prompt and a preset first prompt template, and input the first optimized prompt into the first model to obtain at least one question output by the first model. The first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt;

[0060] A second structured interaction module, configured to generate a first intermediate prompt based on the original prompt, the at least one question, and a preset second prompt template, and input the first intermediate prompt into a second model to obtain an answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the at least one question.

[0061] A third structured interaction module, configured to generate a second optimized prompt based on the original prompt, the answer output by the second model, and a third prompt template, and input the second optimized prompt into the first model, wherein the third prompt template is used to prompt the original prompt and the at least one answer to the first model and request the first model to answer the original prompt.

[0062] Optionally, the second structured interaction module is further configured to generate a first intermediate prompt and input the first intermediate prompt into the second model to obtain an answer output by the second model in any of the following manners:

[0063] Fill the original prompt and each question output by the first model into the second prompt template to generate a first intermediate prompt, input the first intermediate prompt into the same second model, and obtain an answer output by the second model.

[0064] Determine the categories to which each question output by the first model belongs; fill the original prompt and the questions in the same category into the second prompt template to generate a first intermediate prompt, input the first intermediate prompt into the second model corresponding to the same category, and obtain an answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0065] Optionally, the prompt construction module includes:

[0066] A fourth structured interaction module, configured to generate a first optimized prompt based on the original prompt and a preset first prompt template, and input the first optimized prompt into the first model to obtain at least one question output by the first model; wherein, the first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt.

[0067] A first determination module, configured to determine a first type of question and a second type of question among the at least one question, wherein the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer.

[0068] The fifth structured interaction module is configured to, when the first type of problem exists among the at least one problem, generate a second intermediate prompt based on the original prompt, the first type of problem, and a preset second prompt template, and input the second intermediate prompt into a second model to obtain an answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of problem;

[0069] The first user interaction module is configured to, when the second type of problem exists among the at least one problem, prompt the second type of problem to the user and receive an answer input by the user;

[0070] The sixth structured interaction module is configured to generate a third optimized prompt based on the original prompt, the first answer, and a third prompt template, and input the third optimized prompt into the first model, wherein the third prompt template is used to prompt the original prompt and the first answer to the first model and request the first model to answer the original prompt; the first answer includes: the answer output by the second model, and / or, the answer input by the user.

[0071] Optionally, the fifth structured interaction module is further configured to generate a second intermediate prompt and input the second intermediate prompt into the second model to obtain an answer output by the second model in any of the following manners:

[0072] Fill the original prompt and the first type of problem into the second prompt template to generate a second intermediate prompt and input the second intermediate prompt into the same second model to obtain an answer output by the second model;

[0073] Determine the category to which each problem in the first type of problem belongs; fill the original prompt and the problems in the same category into the second prompt template to generate a second intermediate prompt and input the second intermediate prompt into the second model corresponding to the same category to obtain an answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0074] Optionally, the prompt construction module includes:

[0075] The seventh structured interaction module is configured to generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and input the fourth optimized prompt into the first model to obtain an answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, request the first model to ask questions according to the content of the original prompt and output answers;

[0076] An eighth structured interaction module, configured to generate a fifth optimized prompt based on the original prompt and a fifth prompt template, and input the fifth optimized prompt into the first model, where the fifth prompt template is used to prompt the original prompt to the first model and request the first model to answer the original prompt.

[0077] Optionally, the prompt construction module includes:

[0078] A ninth structured interaction module, configured to generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and input the fourth optimized prompt into the first model to obtain an answer output by the first model; where the fourth prompt template is used to prompt the content of the original prompt and request the first model to ask questions and output answers according to the content of the original prompt;

[0079] A tenth structured interaction module, configured to, when the answer output by the first model includes at least one first question that the first model cannot answer, generate a third intermediate prompt based on the original prompt, the at least one first question, and a preset second prompt template, and input the third intermediate prompt into a second model to obtain an answer output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first question;

[0080] An eleventh structured interaction module, configured to generate a sixth optimized prompt based on the original prompt, a second answer, and a third prompt template, and input the sixth optimized prompt into the first model, where the third prompt template is used to prompt the original prompt and the second answer to the first model and request the first model to answer the original prompt, and the second answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question that the first model can answer.

[0081] Optionally, the tenth structured interaction module is further configured to generate a third intermediate prompt and input it into the second model to obtain an answer output by the second model in any of the following ways:

[0082] Fill the original prompt and each first question into the second prompt template to generate a third intermediate prompt and input it into the same second model to obtain an answer output by the second model;

[0083] Determine the category to which each first question belongs; fill the original prompt and the first questions in the same category into the second prompt template to generate a third intermediate prompt and input it into the second model corresponding to the same category to obtain an answer output by the second model corresponding to the same category; where there are multiple second models, and each second model corresponds to a different category.

[0084] Optionally, the prompt construction module includes:

[0085] A twelfth construction interaction module, configured to generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and input the fourth optimized prompt into the first model to obtain an answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, request the first model to ask questions according to the content of the original prompt and output answers;

[0086] A second determination module, configured to determine a first type of question and a second type of question among the at least one first question when the answer output by the first model includes at least one first question that is asked by the first model and cannot be answered, wherein the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer;

[0087] A thirteenth construction interaction module, configured to, when there is a first type of question among the at least one first question, generate a fourth intermediate prompt based on the original prompt, the first type of question and a preset second prompt template, and input the fourth intermediate prompt into the second model to obtain an answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model, and request the second model to answer the first type of question;

[0088] A second user interaction module, configured to, when there is a second type of question among the at least one first question, prompt the second type of question to the user and receive an answer input by the user;

[0089] A fourteenth construction interaction module, configured to generate a seventh optimized prompt based on the original prompt, a third answer and a third prompt template, and input the seventh optimized prompt into the first model, wherein the third prompt template is used to prompt the original prompt and the third answer to the first model, and request the first model to answer the original prompt, and the third answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question; the second question is a question that is asked by the first model and can be answered.

[0090] Optionally, the thirteenth construction interaction module is further configured to generate a fourth intermediate prompt and input the fourth intermediate prompt into the second model to obtain an answer output by the second model in any one of the following manners:

[0091] Fill the original prompt and the first type of question into the second prompt template, generate a fourth intermediate prompt and input the fourth intermediate prompt into the same second model to obtain an answer output by the second model;

[0092] Determine the category to which each problem in the first type of problems belongs; fill the original prompt and the problems in the same category into the second prompt template to generate a fourth intermediate prompt and input it into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0093] Optionally, the obtaining module is further configured to receive and display the answer to the original prompt output by the first model.

[0094] Optionally, the prompt construction module includes:

[0095] The fifteenth construction interaction module is configured to generate an eighth optimized prompt based on the original prompt and the sixth prompt template and input it into the first model, wherein the sixth prompt template is specifically used to prompt the content of the original prompt, request the first model to ask questions and give answers according to the content of the original prompt, and answer the original prompt.

[0096] Optionally, the obtaining module includes:

[0097] The first receiving module is configured to receive the answer information output by the first model;

[0098] The sixteenth construction interaction module is configured to, when the answer information output by the first model includes at least one first question proposed by the first model and not answered, generate a fifth intermediate prompt based on the original prompt, the at least one first question and a preset second prompt template and input it into the second model to obtain the answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first question.

[0099] The seventeenth construction interaction module is configured to generate a ninth optimized prompt based on the original prompt, the fourth answer and the seventh prompt template and input it into the first model, wherein the seventh prompt template is used to prompt the original prompt and the fourth answer to the first model and request the first model to answer the original prompt again, and the fourth answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question proposed by the first model and can be answered.

[0100] Optionally, the sixteenth construction interaction module is further configured to generate a fifth intermediate prompt and input it into the second model to obtain the answer output by the second model in any of the following ways:

[0101] Fill the original prompt and each first question into the second prompt template to generate a fifth intermediate prompt and input it into the same second model to obtain the answer output by the second model;

[0102] Determine the category to which each first question belongs; fill the original prompt and the first questions under the same category into the second prompt template to generate a fifth intermediate prompt and input it into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category respectively.

[0103] Optionally, the obtaining module includes:

[0104] A second receiving module, configured to receive the answer information output by the first model;

[0105] An eighteenth construction interaction module, configured to determine a first type of question and a second type of question in the at least one first question in the case that the answer information output by the first model includes at least one first question that the first model cannot answer, wherein the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer;

[0106] A nineteenth construction interaction module, configured to generate a sixth intermediate prompt based on the original prompt, the first type of question, and a preset second prompt template and input it into the second model to obtain the answer output by the second model in the case that there is the first type of question in the at least one first question; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of question;

[0107] A third user interaction module, configured to prompt the second type of question to the user and receive the answer input by the user in the case that there is the second type of question in the at least one first question;

[0108] A twentieth construction interaction module, configured to generate a tenth optimization prompt based on the original prompt, the fifth answer, and a seventh prompt template and input it into the first model, wherein the seventh prompt template is used to prompt the original prompt and the fifth answer to the first model and request the first model to answer the original prompt again, and the fifth answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question; the second question is a question that the first model can answer.

[0109] Optionally, the nineteenth structured interaction module is further configured to generate a sixth intermediate prompt and input it into the second model in any of the following ways to obtain an answer output by the second model:

[0110] Fill the original prompt and the first type of questions into the second prompt template to generate a sixth intermediate prompt and input it into the same second model, and obtain an answer output by the second model;

[0111] Determine the category to which each question in the first type of questions belongs; fill the original prompt and the questions in the same category into the second prompt template to generate a sixth intermediate prompt and input it into the second model corresponding to the same category, and obtain an answer output by the second model corresponding to the same category; where there are multiple second models, and each second model corresponds to a different category.

[0112] Optionally, the obtaining module further includes:

[0113] A display module, configured to display the answer of the first model to the original prompt when the answer information includes the answer of the first model to the original prompt.

[0114] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed by a processor, the steps of the method described above are implemented.

[0115] Compared with the prior art, the prompt tuning method and device provided by the embodiment of the present application can guide the first model to start a question-and-answer process based on the content of the original prompt, so that the context information obtained in the question-and-answer process can be used to assist the first model in answering the original prompt, enabling the first model to generate a more accurate answer based on this context information when answering the original prompt, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0116] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present application. Moreover, throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:

[0117] Figure 1 is a flowchart of a prompt tuning method according to an embodiment of the present application;

[0118] Figure 2 is a schematic diagram of a prompt template in Mode 1 according to an embodiment of the present application;

[0119] Figure 3Schematic diagram of input optimization prompt in Embodiment 1 of the present application;

[0120] Figure 4 Effect comparison diagram of not using / using the prompt tuning method of the embodiment of the present application;

[0121] Figure 5 Schematic diagram of the prompt template in Embodiment 3 of the present application;

[0122] Figure 6 Schematic diagram of input optimization prompt in Embodiment 3 of the present application;

[0123] Figure 7 Schematic diagram of the prompt template in Embodiment 3 of the present application;

[0124] Figure 8 Schematic diagram of input optimization prompt in Embodiment 3 of the present application;

[0125] Figure 9 Schematic diagram of the structure of the prompt optimization device of the embodiment of the present application;

[0126] Figure 10 Another schematic diagram of the structure of the prompt optimization device of the embodiment of the present application;

[0127] Figure 11 Another schematic diagram of the structure of the prompt optimization device of the embodiment of the present application. Detailed implementation manners

[0128] To make the technical problems, technical solutions and advantages to be solved by the present application clearer, the following will be described in detail in conjunction with the accompanying drawings and specific embodiments. In the following description, specific details such as specific configurations and components are provided only to help a comprehensive understanding of the embodiments of the present application. Therefore, those skilled in the art should clearly understand that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. In addition, descriptions of known functions and structures are omitted for clarity and conciseness.

[0129] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, the "in one embodiment" or "in an embodiment" that appears throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics may be combined in one or more embodiments in any suitable manner. The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented, for example, in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that comprises a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices. The "and / or" in the specification and claims means at least one of the connected objects.

[0130] In various embodiments of the present application, it should be understood that the magnitudes of the serial numbers of the following processes do not mean the order of execution, and the order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.

[0131] The following description provides examples and does not limit the scope, applicability or configuration set forth in the claims. Changes may be made to the functions and arrangements of the elements discussed without departing from the spirit and scope of the disclosure. Various examples may appropriately omit, substitute, or add various procedures or components. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0132] Currently, many companies hire humans to perform prompt tuning work. The embodiments of this application mainly discuss automated prompt tuning techniques. Automated prompt tuning techniques refer to the process of improving and optimizing the original prompt by using computer programs and algorithms, where the original prompt refers to the specified task description entered by the user for the target large model to assist in completing. The final output of this process is generally the optimized prompt. Starting from the ultimate goal of prompt tuning, that is, to improve the response accuracy of the large model to the user's original prompt (or to make the generated content meet the user's expectations), the embodiments of this application propose a prompt tuning method based on machine-to-machine interaction, using an agent module to guide the target large model (the first model) to ask questions about the original prompt and answer them as additional information, so as to improve the quality of the final output of the target large model (the first model).

[0133] The automated prompt tuning methods in the related art mainly use other or the same large model to optimize the prompts used on the target large model, and are divided into methods involving model training and methods not involving model training.

[0134] Among the methods not involving model training, some methods propose to use artificial templates and input / output pairs of the user's target tasks to let several large models generate prompt candidates, and then use the evaluation data to evaluate the prompt candidates on the target large model and select the optimal prompt. This method enables users not to face the difficulty of constructing the original prompt at the beginning, and uses the evaluation data to conduct strict evaluation through the target large model to ensure the effectiveness of the optimal prompt for the target task. However, for individual users, the tasks they specify are ever-changing. In most cases, users do not provide input / output data. Even in the case of such data, the computational resources and time costs for prompt tuning for each specified task of the user are too high to be implemented.

[0135] Among the methods involving model training, some studies propose gradient-based prompt tuning methods. On the one hand, as the scale of the large model increases day by day, the computational cost also increases significantly. On the other hand, large models led by ChatGPT are provided in the form of APIs, only receiving text input and not supporting the acquisition of gradients. Moreover, the optimal prompts generated by such methods are often abstract and incomprehensible to humans, and the process of prompt tuning lacks interpretability. The method proposed in the embodiments of this application can solve the problems of the above methods. On the one hand, the embodiments of this application do not require users to provide data and are convenient for optimizing the original prompts for ever-changing specified tasks. On the other hand, it does not involve model training, saving costs, and has interpretability.

[0136] Many attempts on large models have shown that the failure to obtain the expected output using large models may not be due to the poor performance of the large models themselves, but rather to the user prompt tuning skills. On the one hand, the original prompt input by the user may have problems such as vague task descriptions and lack of details, which often lead to the large model asking questions or generating unhelpful outputs; on the other hand, although the large model has learned a vast amount of knowledge, it sometimes lacks the guidance of logical thinking and cannot call on this knowledge, resulting in incorrect or inaccurate outputs.

[0137] In response to the above two situations, the embodiments of this application propose to add an additional prompt tuning device (which can also be called a proxy module) between the user and the target large model to process and forward the interaction information between the two. This prompt tuning device guides the target large model to ask questions about the user's original prompt and answer these questions, and these answers provide additional information as the context for the target large model's final answer. The process of the prompt tuning device guiding the target large model to ask questions and answer is an interaction process between machines, which can clarify the task objectives, fill in details, and guide logical thinking, thereby improving the quality of the target large model's final answer.

[0138] The embodiments of this application provide a prompt tuning method, which can improve the response accuracy of the large language model to the original prompt by tuning the original prompt input by the user, thus enhancing the user experience. As Figure 1 shown, this method includes:

[0139] Step 11, receive the original prompt input by the user.

[0140] Here, when the user needs to use the large language model to generate the content they need, they usually need to input the original prompt to the large language model. The original prompt is usually text content in natural language, used to describe the user's specific needs. For example, the original prompt can be "Help me arrange a holiday plan in Japan", "Help me write an end-of-year summary", etc. Of course, the user can also input the original prompt by voice. In this case, the voice signal can be converted into the corresponding text content to obtain the original prompt input by the user.

[0141] Step 12, guide the first model to start a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained in the question-and-answer process, where the question-and-answer process includes at least one of the following: the first model asks a question and the second model answers; the first model asks a question and answers it.

[0142] Here, in the embodiments of the present application, a prompt template is preset. The prompt template is used to guide the first model to initiate a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process.

[0143] In the embodiments of the present application, the question-and-answer process may be: the first model asks a question, and another model (the second model) answers it. In this way, the first model can obtain context information related to the original prompt based on the answer of the second model, and then answer the original prompt based on this context information.

[0144] In the embodiments of the present application, the question-and-answer process may also be: the first model asks a question, and the first model answers it. That is, the first model obtains context information related to the original prompt by asking and answering itself, and then answers the original prompt based on this context information.

[0145] Specifically, in step 12, the embodiments of the present application generate an optimized prompt based on the original prompt and the prompt template, and input it into the first model. The prompt template is used to guide the first model to initiate a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process.

[0146] Step 13, obtain the answer to the original prompt generated by the first model.

[0147] Here, the embodiments of the present application can receive the answer to the original prompt output by the first model and display it. The specific display methods include but are not limited to at least one of the following: display the answer to the original prompt (for example, display it in text); play the answer to the original prompt by voice, etc.

[0148] Compared with the implementation method of directly requesting the first model to answer the original prompt, the embodiments of the present application guide the first model to initiate a question-and-answer process based on the content of the original prompt, so that the context information obtained during the question-and-answer process can be used to assist the first model in answering the original prompt, enabling the first model to generate a more accurate answer based on this context information when answering the original prompt, thereby improving the user experience.

[0149] The above method of the embodiments of the present application can be applied to an automatic question-and-answer system based on a large language model, enabling the system to optimize the original prompt input by the user in the background to improve the accuracy of the response of the automatic question-and-answer system and improve the user experience.

[0150] The following specifically describes several implementation manners of generating an optimized prompt based on the original prompt and a preset prompt template in step 12 of the embodiments of the present application.

[0151] Manner 1:

[0152] In Manner 1, three prompt templates are introduced, which are respectively called the first prompt template, the second prompt template, and the third prompt template. Figure 2 A specific example of these three templates is provided. These templates respectively include at least one placeholder, at least one keyword, and task description content, and each placeholder corresponds to a content to be filled in. Figure 2 In this application, "[]" is used to represent a placeholder, and the content in "[]" represents the content to be filled in corresponding to the placeholder. For example, "[original prompt]" means that the content to be filled in corresponding to this placeholder is the original prompt, that is, the original prompt input by the user is filled in the position corresponding to this placeholder to generate the corresponding optimized prompt. The keyword is used to indicate the text structure adopted by the model when providing an answer. For example, the keyword "I have the following questions" in the first prompt template indicates the text structure adopted by the first model when providing questions, and the second and third prompt templates include the keyword "Answer:", so that after obtaining the answer provided by the relevant model, the required answer content can be conveniently extracted from the answer based on the keyword. The task description content is used to indicate the task that the model needs to execute. For example, the task description content in the first prompt template "You should ask me any questions that you are unsure about. If you have any questions, it should be 'I have the following questions:'" is used to request the first model to ask questions according to the content of the original prompt; the task description content in the second prompt template "Now assume that you are me, how would you answer these questions" is used to request the second model to answer questions; the task description content in the third prompt template "Now, you should answer the original prompt '[original prompt]'" is used to request the first model to answer the original prompt.

[0153] Since the model can usually obtain the context information in the question-and-answer process and execute subsequent tasks based on this context information, the content of the above templates can be further simplified. For example, the third prompt template may not include the original prompt. In addition, it should be noted that although the specific structures and contents of the first, second, and third prompt templates are provided in the embodiments of the present application, the above structures and contents are not used to limit the present application. Any structure that can provide relevant information to the model and trigger the model to execute corresponding tasks can be applied to the present application.

[0154] Figure 3 An example of inputting the optimized prompt generated based on Manner 1 to the first model is provided.

[0155] Specifically, step 12 includes:

[0156] Step 1201: Based on the original prompt and a preset first prompt template, generate a first optimized prompt and input it into the first model to obtain at least one question output by the first model. The first prompt template is used to prompt the content of the original prompt and request the first model to ask questions based on the content of the original prompt.

[0157] Here, the function of the first prompt template is to prompt the content of the original prompt to the first model and guide the target large model to ask questions based on the content of the original prompt. Through experimental verification, these questions include at least one of the following: questions for confirming details in the original prompt, questions for requesting an explanation of the instruction content in the original prompt, and questions for requesting external knowledge.

[0158] For example, when the original prompt is "Help me arrange a holiday plan in Japan", the first model may ask "How long do you plan to stay in Japan?" to confirm details; when the original prompt is "Does the following sentence contain a tense error:...", the first model will ask "What does a tense error refer to?"; when the original prompt is "Please write a poem in the style of Shakespeare", the first model will ask "How many lines are there generally in Shakespeare's poems?" to confirm details. These questions reflect the aspects considered by the large language model to generate the content expected by the user and avoid errors. Answering these questions can have a positive impact on the final output of the large model.

[0159] Figure 2 The first prompt template shown includes a placeholder corresponding to the original prompt and includes the task description content: You should ask me any questions you are unsure about. If you have any questions, it should start with "I have the following questions:". The above text content is used to request the first model to ask questions based on the content of the original prompt. In this way, filling the original prompt into Figure 2 the first prompt template shown can generate Figure 3 the first optimized prompt 301 shown in. Input the first optimized prompt 301 into the first model to obtain at least one question output by the first model, such as Figure 3 the question 302 shown in.

[0160] Step 1202: Based on the original prompt, the at least one question, and a preset second prompt template, generate a first intermediate prompt and input it into the second model to obtain an answer output by the second model. The second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the at least one question.

[0161] Here, the function of the second prompt template is to prompt the second model with the questions raised by the first model and request it to answer each question. In order to enable the second model to answer questions related to human preferences, the second prompt template asks the second model to answer questions in a human tone in the way of "assuming you are me".

[0162] Figure 2 The second prompt template shown includes placeholders corresponding to the original prompt, placeholders corresponding to at least one question, and includes the task description content: Now assume you are me, how would you answer these questions. The above text content is used to prompt the second model with the at least one question and request an answer. The second model is various models capable of generating answers based on questions. The second model and the first model can be the same large language model. Of course, the second model can also be other models different from the first model. The second model can specifically be large language models such as ChatGPT and ChatGLM, or can also be question-and-answer models based on document recall, question-and-answer models based on knowledge recall, etc., large language model APIs provided by third parties and other organizations, open source large models, and large language models fine-tuned using their own domain data. The embodiments of the present application do not make specific limitations in this regard. For example, if the second model is a large language model, then by filling the original prompt and the at least one question into Figure 2 the second prompt template shown, the first intermediate prompt 303 shown in Figure 3 can be generated. Input the first intermediate prompt 303 into the second model to obtain at least one answer output by the second model, such as the answer 304 shown in Figure 3 . Also for example, if the second model is a traditional question-and-answer model, then the at least one question can be input into the second model to obtain the answer output by the second model. Specifically, one question can be input into the second model each time, and the answer to this question output by the second model can be obtained.

[0163] In the above step 1202, based on the original prompt, the at least one question, and a preset second prompt template, generating a first intermediate prompt and inputting it into the second model to obtain at least one answer output by the second model can specifically include any of the following situations:

[0164] Situation 1: Fill the original prompt and each question output by the first model into the second prompt template, generate a first intermediate prompt and input it into the same second model to obtain the answer output by the second model.

[0165] In Case 1, only one second model is set, and each question output by the first model is answered by this second model. When the second model can answer multiple questions at one time, the original prompt and all the questions output by the first model can be filled into the second prompt template to generate a first intermediate prompt and input it into the same second model to obtain the answers output by the second model. When the second model can only answer one question at a time, the original prompt and one question output by the first model can be filled into the second prompt template each time to generate a first intermediate prompt and input it into the same second model to obtain the answers output by the second model, and the above steps can be repeated multiple times, so that the answers of the second model to all the questions output by the first model can be obtained.

[0166] For example, continuing with the previous example of "help me arrange a Japanese holiday plan", assuming the first model asks three questions: Question A "Which scenic spots in Japan are you interested in", Question B "Do you like cultural scenic spots or natural scenic spots", and Question C "Which hotels do you want to stay in", then the same second model can answer these three questions, either answering all three questions at once or answering them one by one in three times.

[0167] Case 2: Determine the category to which each question output by the first model belongs; fill the original prompt and the questions in the same category into the second prompt template to generate a first intermediate prompt and input it into the second model corresponding to the same category to obtain the answers output by the second model corresponding to the same category; where there are multiple second models, and each second model corresponds to a different category respectively. The question category corresponding to one second model can be one or more.

[0168] In Case 2, multiple second models are preset, and each second model corresponds to questions of different categories and can answer questions of different categories. That is to say, in the embodiments of the present application, corresponding second models are trained in advance for questions of different categories, and each second model can answer the questions of the category it corresponds to. In this way, in Case 2, first determine the category to which each question output by the first model belongs, and then fill the original prompt and the questions in the same category into the second prompt template to generate a first intermediate prompt and input it into the second model corresponding to the same category to obtain the answers output by the second model corresponding to the same category. Similarly, according to the capabilities of the second model, multiple questions in the same category can be answered at once, or only one question in the same category can be answered each time.

[0169] Continuing with the previous example, question A, "Which scenic spots in Japan are you interested in?" and question B, "Do you prefer cultural scenic spots or natural scenic spots?" are questions related to scenic spots, and assume their category is scenic spots; question C, "Which hotels do you hope to stay in?" is a question related to accommodation, and assume its category is accommodation. Suppose two second models are pre-trained, corresponding to scenic spots and accommodation respectively. Then, questions A and B can be filled into the second prompt template to generate a first intermediate prompt and input it into the second model corresponding to scenic spots to obtain the answer output by the model; question C can be filled into the second prompt template to generate a first intermediate prompt and input it into the second model corresponding to accommodation to obtain the answer output by the model.

[0170] Step 1203, based on the original prompt, the answer output by the second model, and a third prompt template, generate a second optimized prompt and input it into the first model, where the third prompt template is used to prompt the first model with the original prompt and the answer output by the second model, and request the first model to answer the original prompt.

[0171] Here, the function of the third prompt template is to forward the answer content of the second model to the first model, and again prompt the first model with the original prompt and require it to answer the original prompt. Since the first model may have a context truncation mechanism, that is, when the current input and the conversation history exceed the maximum input length specified by the model, the model will truncate the conversation history, which may cause the first model to forget the user's original prompt. Therefore, here the third prompt template avoids the above situation by prompting the content of the original prompt again.

[0172] Continuing with the above example, filling the original prompt and the at least one answer 304 into Figure 2 the third prompt template shown can generate Figure 3 the second optimized prompt 305 shown in. Input the second optimized prompt 305 into the first model to obtain the answer to the original prompt output by the first model, such as Figure 3 the answer 306 shown in.

[0173] Figure 4It is a comparison chart of the effects of not using / using the prompt optimization method of the embodiments of the present application. The left side shows a real example of not using the prompt optimization method of the embodiments of the present application: for the user's original prompt "Help me arrange a Japanese holiday plan", the first model generates an answer. After analysis, the answer only prompts the aspects that need to be considered for the trip, but does not list a complete plan according to the user's requirements, lacking helpfulness. While the right side shows an example of using the prompt optimization method described in the embodiments of the present application: for the original prompt, the first model asks questions to confirm details from multiple aspects such as travel date, number of travel days, destination, etc. Then, the second model answers these questions one by one, and these answers are provided as references for the context of the final answer of the first model, so that the first model finally outputs a rich travel plan that meets the user's requirements. It can be seen that the answers obtained in the embodiments of the present application are more in line with the user's expectations. That is to say, the embodiments of the present application can improve the response accuracy of the large language model to the original prompt and enhance the user experience.

[0174] Method 2:

[0175] In Method 2, the same 3 prompt templates as in Method 1 are also introduced, namely the first prompt template, the second prompt template, and the third prompt template. Considering the capabilities of the second model, there may be questions that the second model cannot answer. Method 2 makes a distinction for this situation.

[0176] Specifically, the above step 12 includes:

[0177] Step 1211, based on the original prompt and the preset first prompt template, generate a first optimized prompt and input it into the first model to obtain at least one question output by the first model; wherein, the first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt.

[0178] Step 1212, determine the first type of questions and the second type of questions among the at least one question, where the first type of questions are questions that the second model can answer, and the second type of questions are questions that the second model cannot answer.

[0179] Here, the second model corresponds to a specific question category and can answer questions in that category. When a certain question does not belong to the category corresponding to the second model, the second model cannot answer that question. Therefore, it is possible to determine whether the second model can answer these questions according to the categories to which the questions proposed by the first model belong, so as to divide the questions proposed by the first model into the above first type of questions and the second type of questions. In addition, similar to Method 1, there can be one or more second models. The question categories corresponding to one second model can be one or more.

[0180] In addition, embodiments of the present application may also pre - save the correspondence between question categories and whether to ask the user. For example, for questions of the category of user attributes (such as the user's age, gender), it is set that such questions need to be asked to the user; for question categories that can be answered by the second model, it is set that such questions do not need to be asked to the user. Based on the above method, each question proposed by the first model can also be divided into the above - mentioned first - type questions and second - type questions.

[0181] Specifically, in embodiments of the present application, the category to which a question belongs can be determined based on information such as keywords included in the question and its context.

[0182] Step 1213, when there are the first - type questions among the at least one question, generate a second intermediate prompt based on the original prompt, the first - type questions, and a preset second prompt template, and input it into the second model to obtain an answer output by the second model; wherein, the second prompt template is used to prompt the second model with the content of the original prompt and request the second model to answer the first - type questions.

[0183] Here, step 1213 is similar to step 1202 of Method 1. For the first - type questions, a second intermediate prompt is generated through the second prompt template and input into the second model, so as to obtain the answer of the second model to the first - type questions. Similarly, step 1213 may also include any of the following situations:

[0184] Situation 1: Fill the original prompt and the first - type questions into the second prompt template, generate a second intermediate prompt and input it into the same second model to obtain an answer output by the second model. Situation 1 corresponds to the scenario where only 1 second model is set.

[0185] Situation 2: Determine the category to which each question in the first - type questions belongs; fill the original prompt and questions in the same category into the second prompt template, generate a second intermediate prompt and input it into the second model corresponding to the same category to obtain an answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category respectively. Situation 2 corresponds to the scenario where multiple second models are set, and each second model corresponds to a different category respectively. Of course, the question category corresponding to one second model can be 1 or more.

[0186] Step 1214, when there are the second - type questions among the at least one question, prompt the second - type questions to the user and receive the answer input by the user.

[0187] Here, the user is prompted with the second type of question, and the answer input by the user for the second type of question is received. For example, assume that the questions proposed by the first model also include: question D "Your age", question E "Your gender", etc. These questions belong to the category of "user attributes", which are the second type of questions and need to be asked to the user to obtain answers. Specifically, the embodiments of the present application can display the second type of question and receive the relevant answers input by the user.

[0188] Step 1215, based on the original prompt, the first answer, and the third prompt template, generate a third optimized prompt and input it into the first model, where the third prompt template is used to prompt the first model with the original prompt and the first answer, and request the first model to answer the original prompt; the first answer includes: the answer output by the second model, and / or, the answer input by the user.

[0189] Here, in step 1215, based on the answer output by the second model, and / or, the answer input by the user, a second optimized prompt is generated and input into the first model to request the first model to answer the original prompt according to these answers.

[0190] Method 3:

[0191] In Method 3, two prompt templates are introduced, called the fourth prompt template and the fifth prompt template respectively. Figure 5 A specific example of these two prompt templates is provided. Similarly, the fourth prompt template and the fifth prompt template each include at least one placeholder, and each placeholder corresponds to a prompt content. Figure 6 An example of inputting an optimized prompt generated based on Method 3 into the first model is provided.

[0192] Specifically, the above step 12 includes:

[0193] Step 1221, based on the original prompt and the preset fourth prompt template, generate a fourth optimized prompt and input it into the first model to obtain the answer output by the first model; where the fourth prompt template is used to prompt the content of the original prompt, and request the first model to ask questions according to the content of the original prompt and output answers.

[0194] In the above Method 1, the first model asks questions and the second model answers; in Method 3, the first model asks questions and the first model answers, that is, both asking questions and answering are processed by the first model. Continuing with the above example, filling the original prompt into the fourth prompt template can generate Figure 6The fourth optimization prompt 601 shown in []. The fourth optimization prompt 601 requires the first model to ask and answer questions for the original prompt. Inputting the fourth optimization prompt 601 into the first model, at least one answer 602 output by the first model is obtained. The first model is various large language models capable of generating answers based on prompts, specifically, it can be large language models such as ChatGPT, ChatGLM, etc. The embodiments of this application do not make specific limitations on this.

[0195] Step 1222, based on the original prompt and the fifth prompt template, generate the fifth optimization prompt and input it into the first model, where the fifth prompt template is used to prompt the first model with the original prompt and request the first model to answer the original prompt.

[0196] Here, filling the original prompt into the fifth prompt template can generate Figure 6 the fifth optimization prompt 603 shown in []. The fifth optimization prompt 603 requires the first model to ask and answer questions for the original prompt. Since in the interaction process of step 1221, the first model has already been required to ask and answer questions for the original prompt, generating at least one pair of questions and answers, therefore, in subsequent steps, after receiving the fourth optimization prompt, the first model will answer the original prompt based on at least one pair of questions and answers generated in the previous interaction process, etc., generating an answer 604, thereby improving the accuracy of the answer generated by the first model and enhancing the user experience.

[0197] The implementation method of the above method three avoids using the second model, thereby reducing the number of model inferences.

[0198] Method four:

[0199] In method four, similar second prompt templates as in method one and fourth and fifth prompt templates as in method three are adopted. Method four considers the situation where the first model may not be able to answer the questions it raises. For this situation, the above step 12 includes:

[0200] Step 1231, based on the original prompt and the preset fourth prompt template, generate the fourth optimization prompt and input it into the first model to obtain the answer output by the first model; where the fourth prompt template is used to prompt the content of the original prompt, request the first model to ask questions according to the content of the original prompt and output answers.

[0201] Step 1232, in the case where the answer output by the first model includes at least one first question that the first model cannot answer, generate a third intermediate prompt based on the original prompt, the at least one first question, and a preset second prompt template, and input it into the second model to obtain the answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first question.

[0202] Here, in the scenario where the first model cannot answer the questions proposed by the first model, the answer output by the first model contains relevant prompt information. For example, it prompts one or more questions that the first model cannot answer (for ease of description, here it is called the first question). In this way, in the case where the answer output by the first model includes at least one first question that the first model cannot answer, the embodiments of the present application can extract at least one first question that the first model cannot answer according to the above prompt information.

[0203] For example, the embodiments of the present application can also obtain the questions that the first model cannot answer by adding the following content to the fourth prompt template:

[0204] If you have questions that you cannot answer, you should start asking me with "I have questions that I cannot answer:".

[0205] In this way, in step 1232, it can be determined whether the first model has questions that it cannot answer according to whether the keyword "I have questions that I cannot answer:" is included in the answer output by the first model. In the case where the first model has questions that it cannot answer, the questions that the first model cannot answer are extracted according to the above keyword.

[0206] Then, after extracting the first questions that the first model cannot answer, the external second model can be used to answer the first questions. At this time, the first questions are filled into the second prompt template to obtain a third intermediate prompt and input it into the second model.

[0207] Similarly, there can be one or more second models. The generating a first intermediate prompt based on the original prompt, the at least one first question, and a preset second prompt template, and inputting it into the second model to obtain the answer output by the second model may specifically include any of the following situations:

[0208] Situation 1: Fill the original prompt and each first question into the second prompt template, generate a third intermediate prompt and input it into the same second model to obtain the answer output by the second model;

[0209] Case 2: Determine the category to which each first question belongs; fill the original prompt and the first questions in the same category into the second prompt template to generate a third intermediate prompt and input it into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category respectively.

[0210] Step 1233, generate a sixth optimized prompt based on the original prompt, the second answer, and the third prompt template, and input it into the first model, wherein the third prompt template is used to prompt the original prompt and the second answer to the first model and request the first model to answer the original prompt, and the second answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question that the first model can answer.

[0211] At this time, since the answers to some questions are obtained from the second model, the fifth prompt template can be modified to replace the original answer of the first model. For example, modify it into the following form:

[0212] Now, you should answer the original prompt "Help me arrange a Japanese holiday plan." But please replace the answer to question 3... with [Answer]. Answer:

[0213] Here, the content of the [Answer] part is the answer of the second model.

[0214] Of course, embodiments of the present application can also add a new prompt template to replace the original answer of the first model.

[0215] Method Five:

[0216] In Method Five, on the basis of Method Four, it further considers the situation that a certain or some questions proposed by the first model cannot be answered by the second model and need to be answered by the user (similar to Method Two). For this situation, the above step 12 includes:

[0217] Step 1241, generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and input it into the first model to obtain the answer output by the first model; wherein the fourth prompt template is used to prompt the content of the original prompt and request the first model to ask questions and output answers according to the content of the original prompt.

[0218] Step 1242, in the case where the answer output by the first model includes at least one first question proposed by the first model and cannot be answered, determine the first type of question and the second type of question in the at least one first question, where the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer.

[0219] Step 1243, in the case where there is the first type of question in the at least one first question, generate a fourth intermediate prompt based on the original prompt, the first type of question, and a preset second prompt template, and input it into the second model to obtain the answer output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of question.

[0220] Similarly, there can be one or more second models. The generating a fourth intermediate prompt based on the original prompt, the first type of question, and a preset second prompt template, and inputting it into the second model to obtain the answer output by the second model can specifically include any of the following situations:

[0221] Situation 1: Fill the original prompt and the first type of question into the second prompt template, generate a fourth intermediate prompt and input it into the same second model to obtain the answer output by the second model.

[0222] Situation 2: Determine the category to which each question in the first type of question belongs; fill the original prompt and the questions in the same category into the second prompt template, generate a fourth intermediate prompt and input it into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; where there are multiple second models, and each second model corresponds to a different category.

[0223] Step 1244, in the case where there is the second type of question in the at least one first question, prompt the second type of question to the user and receive the answer input by the user.

[0224] Step 1245, generate a seventh optimized prompt based on the original prompt, the third answer, and a third prompt template, and input it into the first model, where the third prompt template is used to prompt the original prompt and the third answer to the first model and request the first model to answer the original prompt, and the third answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question; the second question is a question proposed by the first model and can be answered.

[0225] At this time, since the answers to some questions may be obtained from the second model and / or the user, the fifth prompt template can be modified to replace the original answer of the first model. For example, it can be modified into the following form:

[0226] Now, you should answer the original prompt "Help me arrange a holiday plan in Japan." But please replace the answer to question 3… with [Answer]. Answer:

[0227] Here, the content of [Answer] is the answer of the second model and / or the user.

[0228] Of course, the embodiments of the present application can also add a new prompt template to replace the original answer of the first model.

[0229] In the above methods 1 to 5, in step 13, the embodiments of the present application receive the answer to the original prompt output by the first model and display it.

[0230] Method 6:

[0231] In Method 6, 1 prompt template is introduced, which is called the sixth prompt template here. Similarly, the sixth prompt template includes at least one placeholder, and each placeholder corresponds to a prompt content. Figure 7 A specific example of this prompt template is provided. Figure 8 An example of inputting an optimized prompt generated based on Method 6 into the first model is provided.

[0232] Specifically, the above step 12 includes:

[0233] Step 1251, generate an eighth optimized prompt based on the original prompt and the sixth prompt template, and input it into the first model. The sixth prompt template is specifically used to prompt the content of the original prompt, request the first model to ask questions and answer according to the content of the original prompt, and answer the original prompt.

[0234] Here, filling the original prompt into the sixth prompt template can generate Figure 8The eighth optimization hint 801 shown in [figure]. The eighth optimization hint 801 requires the first model to ask questions and answer regarding the original hint, and to answer the original hint. Inputting the eighth optimization hint 801 into the first model, the answer 802 to the original hint output by the first model is obtained. Since in the process of answering the original hint, the first model asks questions and answers regarding the original hint according to the requirements of the fifth optimization hint, generating at least one pair of questions and answers, therefore, when the first model answers the original hint, it will answer the original hint based on at least one pair of questions and answers and other content generated in the previous interaction process, thereby improving the accuracy of the answer generated by the first model and enhancing the user experience.

[0235] In the above-mentioned sixth method, in the process of the first model generating an answer to the original hint, there may be questions that the first model cannot answer. As an implementation method, the embodiments of the present application use the second model to answer the questions that the first model cannot answer. At this time, the above step 13 specifically includes:

[0236] Step 1301, receiving the answer information output by the first model.

[0237] Here, the answer information output by the first model may include the answer of the first model to the original hint, may also include the questions proposed by the first model and the answers of the first model to the questions, and may also include the questions proposed by the first model and the questions that the first model cannot answer.

[0238] Step 1302, in the case that the answer information output by the first model includes at least one first question proposed by the first model and cannot be answered, generating a fifth intermediate hint based on the original hint, the at least one first question, and a preset second hint template, and inputting it into the second model to obtain the answer output by the second model; wherein, the second hint template is used to prompt the content of the original hint to the second model and request the second model to answer the first question.

[0239] Similarly, the embodiments of the present application can also obtain the questions that the first model cannot answer by modifying the sixth hint template. For example, the questions that the first model cannot answer can be obtained by adding the following content to the sixth hint template:

[0240] If you have questions that you cannot answer, you should start your question with "I have questions that I cannot answer:".

[0241] In this way, in step 1302, it is possible to determine whether the first model has questions that it cannot answer based on whether the keyword "I have questions that I cannot answer:" is included in the answer output by the first model. In the case where the first model has questions that it cannot answer, the questions that the first model cannot answer are extracted based on the above keyword.

[0242] Here, based on the original prompt, the at least one first question, and a preset second prompt template, a fifth intermediate prompt is generated and input into the second model. Specifically, it may include any of the following situations:

[0243] Situation 1: Fill the original prompt and each first question into the second prompt template, generate a fifth intermediate prompt and input it into the same second model to obtain the answer output by the second model;

[0244] Situation 2: Determine the category to which each first question belongs; fill the original prompt and the first questions in the same category into the second prompt template, generate a fifth intermediate prompt and input it into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0245] Step 1303, based on the original prompt, the fourth answer, and a seventh prompt template, generate a ninth optimized prompt and input it into the first model, where the seventh prompt template is used to prompt the first model with the original prompt and the fourth answer and request the first model to answer the original prompt again. The fourth answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question proposed by the first model and can be answered by the first model.

[0246] In the above method six, during the process of the first model generating an answer to the original prompt, there may be questions that the first model cannot answer. As another implementation manner, in the embodiments of the present application, the second model and the user answer the questions that the first model cannot answer. At this time, step 13 specifically includes:

[0247] Step 1311, receive the answer information output by the first model.

[0248] Here, the answer information output by the first model may include the answer of the first model to the original prompt, may also include the questions proposed by the first model and the answers of the first model to the questions, and may also include the questions proposed by the first model and the questions that the first model cannot answer.

[0249] Step 1312, in the case that the response information output by the first model includes at least one first question that the first model cannot answer, determine the first type of questions and the second type of questions among the at least one first question, where the first type of questions are questions that the second model can answer, and the second type of questions are questions that the second model cannot answer.

[0250] Here, the specific implementation of determining the first type of questions and the second type of questions can refer to the description in Method 2 above, and will not be elaborated here.

[0251] Step 1313, in the case that there are the first type of questions among the at least one first question, generate a sixth intermediate prompt based on the original prompt, the first type of questions, and a preset second prompt template, and input it into the second model to obtain the response output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of questions.

[0252] Here, generating a sixth intermediate prompt based on the original prompt, the first type of questions, and a preset second prompt template, and inputting it into the second model to obtain the response output by the second model may specifically include any of the following situations:

[0253] Situation 1: Fill the original prompt and the first type of questions into the second prompt template, generate a sixth intermediate prompt, and input it into the same second model to obtain the response output by the second model;

[0254] Situation 2: Determine the categories to which each question in the first type of questions belongs; fill the original prompt and the questions in the same category into the second prompt template, generate a sixth intermediate prompt, and input it into the second model corresponding to the same category to obtain the response output by the second model corresponding to the same category; where there are multiple second models, and each second model corresponds to a different category.

[0255] Step 1314, in the case that there are the second type of questions among the at least one first question, prompt the second type of questions to the user and receive the response input by the user.

[0256] Here, the specific implementation of Step 1314 can refer to the implementation of Step 1214 in Method 2 above, and will not be elaborated here.

[0257] Step 1315: Generate a tenth optimized prompt based on the original prompt, the fifth answer, and the seventh prompt template, and input it into the first model. The seventh prompt template is used to prompt the first model with the original prompt and the fifth answer, and request the first model to answer the original prompt again. The fifth answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question, where the second question is a question that the first model can answer.

[0258] Here, in step 1315, by the newly added seventh prompt template, the answer of the first model to the first question is replaced, that is, replaced with the answer of the second model and / or the user.

[0259] In the above method six, when the answer information includes the answer of the first model to the original prompt, display the answer of the first model to the original prompt.

[0260] Based on the above method, the embodiments of the present application also provide a device for implementing the above method. Please refer to Figure 9 , the embodiments of the present application provide a prompt optimization device, including:

[0261] A receiving module 91, configured to receive an original prompt input by a user;

[0262] A guiding module 92, configured to guide the first model to start a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process. The question-and-answer process includes at least one of the following: the first model asks a question and the second model answers; the first model asks a question and answers it;

[0263] An obtaining module 93, configured to obtain the answer of the first model to the original prompt.

[0264] Based on the above modules, the embodiments of the present application can improve the accuracy of the response of the large language model and enhance the user experience by optimizing the original prompt input by the user.

[0265] As Figure 10 shown, the guiding module 92 specifically includes:

[0266] A prompt construction module 921, configured to generate an optimized prompt based on the original prompt and a preset prompt template, and input the optimized prompt into the first model, where the prompt template is used to guide the first model to initiate a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process.

[0267] Optionally, the prompt construction module includes:

[0268] A first construction interaction module, configured to generate a first optimized prompt based on the original prompt and a preset first prompt template, and input the first optimized prompt into the first model to obtain at least one question output by the first model; where the first prompt template is used to prompt the content of the original prompt, and request the first model to ask questions according to the content of the original prompt;

[0269] A second construction interaction module, configured to generate a first intermediate prompt based on the original prompt, the at least one question, and a preset second prompt template, and input the first intermediate prompt into a second model to obtain an answer output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model, and request the second model to answer the at least one question;

[0270] A third construction interaction module, configured to generate a second optimized prompt based on the original prompt, the answer output by the second model, and a third prompt template, and input the second optimized prompt into the first model, where the third prompt template is used to prompt the original prompt and the at least one answer to the first model, and request the first model to answer the original prompt.

[0271] Optionally, the second construction interaction module is further configured to generate a first intermediate prompt and input it into the second model in any of the following ways to obtain an answer output by the second model:

[0272] Fill the original prompt and each question output by the first model into the second prompt template to generate a first intermediate prompt and input it into the same second model to obtain an answer output by the second model;

[0273] Determine the category to which each question output by the first model belongs; fill the original prompt and the questions in the same category into the second prompt template to generate a first intermediate prompt and input it into the second model corresponding to the same category to obtain an answer output by the second model corresponding to the same category; where there are multiple second models, and each second model corresponds to a different category.

[0274] Optionally, the prompt construction module includes:

[0275] The fourth structured interaction module is used to generate a first optimized prompt based on the original prompt and a preset first prompt template, and input the first optimized prompt into the first model to obtain at least one question output by the first model; wherein, the first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt.

[0276] The first determination module is used to determine the first type of questions and the second type of questions among the at least one question, wherein the first type of questions are questions that the second model can answer, and the second type of questions are questions that the second model cannot answer.

[0277] The fifth structured interaction module is used to, when there is a first type of question among the at least one question, generate a second intermediate prompt based on the original prompt, the first type of question and a preset second prompt template, and input the second intermediate prompt into the second model to obtain an answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of question.

[0278] The first user interaction module is used to, when there is a second type of question among the at least one question, prompt the second type of question to the user and receive the answer input by the user.

[0279] The sixth structured interaction module is used to generate a third optimized prompt based on the original prompt, the first answer and a third prompt template, and input the third optimized prompt into the first model, wherein the third prompt template is used to prompt the original prompt and the first answer to the first model and request the first model to answer the original prompt; the first answer includes: the answer output by the second model, and / or, the answer input by the user.

[0280] Optionally, the fifth structured interaction module is further used to generate a second intermediate prompt and input the second intermediate prompt into the second model to obtain an answer output by the second model in any of the following ways:

[0281] Fill the original prompt and the first type of question into the second prompt template to generate a second intermediate prompt and input the second intermediate prompt into the same second model to obtain an answer output by the second model.

[0282] Determine the category to which each question in the first type of questions belongs; fill the original prompt and the questions in the same category into the second prompt template to generate a second intermediate prompt and input the second intermediate prompt into the second model corresponding to the same category to obtain an answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0283] Optionally, the prompt construction module includes:

[0284] A seventh construction interaction module, configured to generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, input the fourth optimized prompt into the first model, and obtain an answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, request the first model to ask questions according to the content of the original prompt and output answers;

[0285] An eighth construction interaction module, configured to generate a fifth optimized prompt based on the original prompt and a fifth prompt template, and input the fifth optimized prompt into the first model, wherein the fifth prompt template is used to prompt the first model with the original prompt and request the first model to answer the original prompt.

[0286] Optionally, the prompt construction module includes:

[0287] A ninth construction interaction module, configured to generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, input the fourth optimized prompt into the first model, and obtain an answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, request the first model to ask questions according to the content of the original prompt and output answers;

[0288] A tenth construction interaction module, configured to, when the answer output by the first model includes at least one first question that the first model cannot answer, generate a third intermediate prompt based on the original prompt, the at least one first question, and a preset second prompt template, input the third intermediate prompt into the second model, and obtain an answer output by the second model; wherein, the second prompt template is used to prompt the second model with the content of the original prompt and request the second model to answer the first question;

[0289] An eleventh construction interaction module, configured to generate a sixth optimized prompt based on the original prompt, the second answer, and a third prompt template, and input the sixth optimized prompt into the first model, wherein the third prompt template is used to prompt the first model with the original prompt and the second answer, and request the first model to answer the original prompt, and the second answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question that the first model can answer.

[0290] Optionally, the tenth construction interaction module is further configured to generate a third intermediate prompt in any of the following ways, input the third intermediate prompt into the second model, and obtain an answer output by the second model:

[0291] Fill the original prompt and each first question into the second prompt template to generate a third intermediate prompt and input it into the same second model to obtain the answer output by the second model;

[0292] Determine the category to which each first question belongs; fill the original prompt and the first questions under the same category into the second prompt template to generate a third intermediate prompt and input it into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category respectively.

[0293] Optionally, the prompt construction module includes:

[0294] The twelfth construction interaction module is used to generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template and input it into the first model to obtain the answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt and request the first model to ask questions and output answers according to the content of the original prompt;

[0295] The second determination module is used to determine the first type of questions and the second type of questions in the at least one first question when the answer output by the first model includes at least one first question proposed by the first model and cannot be answered, wherein the first type of questions are questions that the second model can answer, and the second type of questions are questions that the second model cannot answer;

[0296] The thirteenth construction interaction module is used to generate a fourth intermediate prompt based on the original prompt, the first type of questions and a preset second prompt template and input it into the second model to obtain the answer output by the second model when there is the first type of questions in the at least one first question; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of questions;

[0297] The second user interaction module is used to prompt the second type of questions to the user and receive the answer input by the user when there is the second type of questions in the at least one first question;

[0298] The fourteenth structured interaction module is used to generate a seventh optimized prompt based on the original prompt, the third answer, and the third prompt template, and input the seventh optimized prompt into the first model. The third prompt template is used to prompt the first model with the original prompt and the third answer, and request the first model to answer the original prompt. The third answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question; the second question is a question proposed by the first model and can be answered by the first model.

[0299] Optionally, the thirteenth structured interaction module is further configured to generate a fourth intermediate prompt in any of the following ways and input the fourth intermediate prompt into the second model to obtain the answer output by the second model:

[0300] Fill the original prompt and the first type of questions into the second prompt template to generate a fourth intermediate prompt and input the fourth intermediate prompt into the same second model to obtain the answer output by the second model;

[0301] Determine the category to which each question in the first type of questions belongs; fill the original prompt and the questions in the same category into the second prompt template to generate a fourth intermediate prompt and input the fourth intermediate prompt into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0302] Optionally, the obtaining module is further configured to receive and display the answer of the first model to the original prompt.

[0303] Optionally, the prompt construction module includes:

[0304] The fifteenth structured interaction module is used to generate an eighth optimized prompt based on the original prompt and the sixth prompt template, and input the eighth optimized prompt into the first model. The sixth prompt template is specifically used to prompt the content of the original prompt, request the first model to ask questions and answer according to the content of the original prompt, and answer the original prompt.

[0305] Optionally, the obtaining module includes:

[0306] The first receiving module is used to receive the answer information output by the first model;

[0307] The sixteenth structured interaction module is used to generate a fifth intermediate prompt based on the original prompt, the at least one first question, and a preset second prompt template and input it into the second model to obtain the answer output by the second model when the answer information output by the first model includes at least one first question proposed by the first model and cannot be answered; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first question.

[0308] The seventeenth structured interaction module is used to generate a ninth optimized prompt based on the original prompt, the fourth answer, and a seventh prompt template and input it into the first model, wherein the seventh prompt template is used to prompt the original prompt and the fourth answer to the first model and request the first model to answer the original prompt again, and the fourth answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question proposed by the first model and can be answered.

[0309] Optionally, the sixteenth structured interaction module is further used to generate a fifth intermediate prompt and input it into the second model in any of the following ways to obtain the answer output by the second model:

[0310] Fill the original prompt and each first question into the second prompt template, generate a fifth intermediate prompt and input it into the same second model to obtain the answer output by the second model.

[0311] Determine the category to which each first question belongs; fill the original prompt and the first questions in the same category into the second prompt template, generate a fifth intermediate prompt and input it into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0312] Optionally, the acquisition module includes:

[0313] The second receiving module is used to receive the answer information output by the first model.

[0314] The eighteenth structured interaction module is used to determine the first type of question and the second type of question in the at least one first question when the answer information output by the first model includes at least one first question that the first model cannot answer, wherein the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer.

[0315] The nineteenth structured interaction module is used to generate a sixth intermediate prompt based on the original prompt, the first type of problem, and a preset second prompt template and input it into the second model to obtain an answer output by the second model when the first type of problem exists in the at least one first question; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of problem.

[0316] The third user interaction module is used to prompt the second type of problem to the user and receive the answer input by the user when the second type of problem exists in the at least one first question.

[0317] The twentieth structured interaction module is used to generate a tenth optimized prompt based on the original prompt, the fifth answer, and a seventh prompt template and input it into the first model, wherein the seventh prompt template is used to prompt the original prompt and the fifth answer to the first model and request the first model to answer the original prompt again, and the fifth answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question; the second question is a question that the first model can answer.

[0318] Optionally, the nineteenth structured interaction module is further used to generate a sixth intermediate prompt and input it into the second model in any of the following ways to obtain an answer output by the second model:

[0319] Fill the original prompt and the first type of problem into the second prompt template, generate a sixth intermediate prompt and input it into the same second model to obtain an answer output by the second model.

[0320] Determine the category to which each problem in the first type of problem belongs; fill the original prompt and the problems in the same category into the second prompt template, generate a sixth intermediate prompt and input it into the second model corresponding to the same category to obtain an answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0321] Optionally, the acquisition module further includes:

[0322] The display module is used to display the answer of the first model to the original prompt when the answer information includes the answer of the first model to the original prompt.

[0323] It should be noted that each device provided in the above embodiments is a device corresponding to the above-mentioned prompt optimization method. The implementation manners in the above embodiments are all applicable to the embodiments of this device and can achieve the same technical effects. The above device provided in the embodiments of this application can implement all the method steps implemented in the above method embodiments and can achieve the same technical effects. Therefore, the same parts and beneficial effects as those in the method embodiments will not be specifically described herein.

[0324] Please refer to Figure 11 , the embodiments of this application also provide a hardware structure block diagram of a prompt optimization device, as Figure 11 shown. The prompt optimization device 1100 includes:

[0325] A processor 1102; and

[0326] A memory 1104, in which computer program instructions are stored.

[0327] Among them, when the computer program instructions are run by the processor, the processor 1102 is caused to execute the following steps:

[0328] Receive the original prompt input by the user;

[0329] Guide the first model to start a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process. Among them, the question-and-answer process includes at least one of the following: the first model asks a question and the second model answers; the first model asks a question and answers it;

[0330] Obtain the answer to the original prompt generated by the first model.

[0331] It should be noted that each system provided in the above embodiments is a device corresponding to the above-mentioned prompt optimization method. The implementation manners in the above embodiments are all applicable to the embodiments of this device and can achieve the same technical effects. The above device provided in the embodiments of this application can implement all the method steps implemented in the above method embodiments and can achieve the same technical effects. Therefore, the same parts and beneficial effects as those in the method embodiments will not be specifically described herein.

[0332] Furthermore, as Figure 11 shown, the prompt optimization device 1100 further includes a network interface 1101, an input device 1103, a hard disk 1105, and a display device 1106.

[0333] The above-mentioned various interfaces and devices can be interconnected through a bus architecture. The bus architecture can include any number of interconnected buses and bridges. Specifically, one or more central processing units (CPUs) and / or graphics processing units (GPUs) represented by the processor 1102, and various circuits of one or more memories represented by the memory 1104 are connected together. The bus architecture can also connect various other circuits such as peripheral devices, voltage regulators, and power management circuits. It can be understood that the bus architecture is used to achieve connection and communication between these components. In addition to the data bus, the bus architecture also includes a power bus, a control bus, and a status signal bus, which are well-known in the art and will not be described in detail herein.

[0334] The network interface 1101 can be connected to a network (such as the Internet, a local area network, etc.).

[0335] The input device 1103 can receive various instructions input by an operator and send them to the processor 1102 for execution. The input device 1103 can include a keyboard or a pointing device (for example, a mouse, a trackball, a touchpad, or a touch screen, etc.).

[0336] The display device 1106 can display the results obtained by the processor 1102 executing instructions, such as displaying the model training progress, etc.

[0337] The memory 1104 is used to store programs and data necessary for the operation of the operating system, as well as data such as intermediate results during the calculation process of the processor 1102.

[0338] It can be understood that the memory 1104 in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. The memory 1104 of the devices and methods described herein is intended to include, but is not limited to, these and any other suitable types of memories.

[0339] In some embodiments, the memory 1104 stores the following elements, executable modules, or data structures, or subsets thereof, or extended sets thereof: an operating system 11041 and an application program 11042.

[0340] Among them, the operating system 11041 includes various system programs, such as the framework layer, the core library layer, the driver layer, etc., which are used to implement various basic services and handle hardware-based tasks. The application program 11042 includes various application programs, such as a browser, etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present application may be included in the application program 11042.

[0341] The method disclosed in the above embodiments of the present application can be applied to or implemented by the processor 1102. The processor 1102 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor 1102 or by instructions in the form of software. The above-mentioned processor 1102 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 1104, and the processor 1102 reads the information in the memory 1104 and combines its hardware to complete the steps of the above method.

[0342] It can be understood that these embodiments described herein can be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.

[0343] For software implementation, the technologies described herein can be implemented by modules (such as procedures, functions, etc.) that execute the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented inside or outside the processor.

[0344] Specifically, when the computer program is executed by the processor 1102, the following steps can also be implemented:

[0345] Generate an optimized prompt based on the original prompt and a preset prompt template, and input the optimized prompt into the first model. The prompt template is used to guide the first model to initiate a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process.

[0346] Specifically, when the computer program is executed by the processor 1102, the following steps may also be implemented:

[0347] Generate a first optimized prompt based on the original prompt and a preset first prompt template, and input the first optimized prompt into the first model to obtain at least one question output by the first model. The first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt.

[0348] Generate a first intermediate prompt based on the original prompt, the at least one question, and a preset second prompt template, and input the first intermediate prompt into the second model to obtain an answer output by the second model. The second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the question.

[0349] Generate a second optimized prompt based on the original prompt, the answer output by the second model, and a third prompt template, and input the second optimized prompt into the first model. The third prompt template is used to prompt the original prompt and the answer output by the second model to the first model and request the first model to answer the original prompt.

[0350] Specifically, when the computer program is executed by the processor 1102, the following steps may also be implemented:

[0351] Generate a first intermediate prompt and input it into the second model in any of the following ways to obtain an answer output by the second model, including any of the following:

[0352] Fill the original prompt and each question output by the first model into the second prompt template to generate a first intermediate prompt and input it into the same second model to obtain an answer output by the second model.

[0353] Determine the category to which each question output by the first model belongs; fill the original prompt and the questions in the same category into the second prompt template to generate a first intermediate prompt and input it into the second model corresponding to the same category to obtain an answer output by the second model corresponding to the same category. There are multiple second models, and each second model corresponds to a different category.

[0354] Specifically, when the computer program is executed by the processor 1102, the following steps can also be implemented:

[0355] Based on the original prompt and a preset first prompt template, generate a first optimized prompt and input it into the first model to obtain at least one question output by the first model; wherein, the first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt;

[0356] Determine the first type of questions and the second type of questions among the at least one question, wherein the first type of questions are questions that the second model can answer, and the second type of questions are questions that the second model cannot answer;

[0357] In the case where the first type of questions exist among the at least one question, based on the original prompt, the first type of questions and a preset second prompt template, generate a second intermediate prompt and input it into the second model to obtain the answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of questions;

[0358] In the case where the second type of questions exist among the at least one question, prompt the second type of questions to the user and receive the answer input by the user;

[0359] Based on the original prompt, the first answer and a third prompt template, generate a third optimized prompt and input it into the first model, wherein the third prompt template is used to prompt the original prompt and the first answer to the first model and request the first model to answer the original prompt; the first answer includes: the answer output by the second model, and / or, the answer input by the user.

[0360] Specifically, when the computer program is executed by the processor 1102, the following steps can also be implemented:

[0361] Generate a second intermediate prompt and input it into the second model in any of the following ways to obtain the answer output by the second model:

[0362] Fill the original prompt and the first type of questions into the second prompt template, generate a second intermediate prompt and input it into the same second model to obtain the answer output by the second model;

[0363] Determine the category to which each problem in the first type of problems belongs; fill the original prompt and the problems in the same category into the second prompt template to generate a second intermediate prompt and input it into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0364] Specifically, when the computer program is executed by the processor 1102, the following steps may also be implemented:

[0365] Generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and input it into the first model to obtain the answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, and request the first model to ask questions and output answers according to the content of the original prompt.

[0366] Generate a fifth optimized prompt based on the original prompt and a fifth prompt template, and input it into the first model, wherein the fifth prompt template is used to prompt the first model with the original prompt and request the first model to answer the original prompt.

[0367] Specifically, when the computer program is executed by the processor 1102, the following steps may also be implemented:

[0368] Generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and input it into the first model to obtain the answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, and request the first model to ask questions and output answers according to the content of the original prompt.

[0369] In the case where the answer output by the first model includes at least one first question that the first model cannot answer, generate a third intermediate prompt based on the original prompt, the at least one first question and a preset second prompt template, and input it into the second model to obtain the answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first question.

[0370] Generate a sixth optimized prompt based on the original prompt, the second answer and a third prompt template, and input it into the first model, wherein the third prompt template is used to prompt the first model with the original prompt and the second answer, and request the first model to answer the original prompt, and the second answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question that the first model can answer.

[0371] Specifically, when the computer program is executed by the processor 1102, the following steps may also be implemented:

[0372] Generate a third intermediate prompt and input it into the second model in any of the following ways to obtain the answer output by the second model:

[0373] Fill the original prompt and each first question into the second prompt template to generate a third intermediate prompt and input it into the same second model to obtain the answer output by the second model;

[0374] Determine the category to which each first question belongs; fill the original prompt and the first questions in the same category into the second prompt template to generate a third intermediate prompt and input it into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0375] Specifically, when the computer program is executed by the processor 1102, the following steps may also be implemented:

[0376] Generate a fourth optimized prompt based on the original prompt and a preset fourth prompt template and input it into the first model to obtain the answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt, request the first model to ask questions based on the content of the original prompt and output answers;

[0377] In the case where the answer output by the first model includes at least one first question proposed by the first model and that the first model cannot answer, determine the first type of questions and the second type of questions among the at least one first question, wherein the first type of questions are questions that the second model can answer, and the second type of questions are questions that the second model cannot answer;

[0378] In the case where there are the first type of questions among the at least one first question, generate a fourth intermediate prompt based on the original prompt, the first type of questions and a preset second prompt template and input it into the second model to obtain the answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of questions;

[0379] In the case where there are the second type of questions among the at least one first question, prompt the second type of questions to the user and receive the answer input by the user;

[0380] Generate a seventh optimized prompt based on the original prompt, the third answer, and the third prompt template, and input the seventh optimized prompt into the first model, where the third prompt template is used to prompt the first model with the original prompt and the third answer, and request the first model to answer the original prompt. The third answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question, where the second question is a question proposed by the first model and can be answered by the first model.

[0381] Specifically, when the computer program is executed by the processor 1102, the following steps may further be implemented:

[0382] Generate a fourth intermediate prompt in any of the following ways and input the fourth intermediate prompt into the second model to obtain the answer output by the second model:

[0383] Fill the original prompt and the first type of questions into the second prompt template, generate a fourth intermediate prompt, and input the fourth intermediate prompt into the same second model to obtain the answer output by the second model;

[0384] Determine the categories to which each question in the first type of questions belongs; fill the original prompt and the questions in the same category into the second prompt template, generate a fourth intermediate prompt, and input the fourth intermediate prompt into the second model corresponding to the same category to obtain the answer output by the second model corresponding to the same category, where there are multiple second models, and each second model corresponds to a different category respectively.

[0385] Specifically, when the computer program is executed by the processor 1102, the following steps may further be implemented:

[0386] Receive the answer of the first model to the original prompt and display it.

[0387] Specifically, when the computer program is executed by the processor 1102, the following steps may further be implemented:

[0388] Generate an eighth optimized prompt based on the original prompt and the sixth prompt template, and input the eighth optimized prompt into the first model, where the sixth prompt template is specifically used to prompt the content of the original prompt, request the first model to ask questions and answer according to the content of the original prompt, and answer the original prompt.

[0389] Specifically, when the computer program is executed by the processor 1102, the following steps may further be implemented:

[0390] Receive the answer information output by the first model;

[0391] In the case where the response information output by the first model includes at least one first question proposed by the first model and cannot be answered, based on the original prompt, the at least one first question, and a preset second prompt template, generate a fifth intermediate prompt and input it into the second model to obtain the response output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first question.

[0392] Based on the original prompt, the fourth response, and the seventh prompt template, generate a ninth optimized prompt and input it into the first model, wherein the seventh prompt template is used to prompt the original prompt and the fourth response to the first model and request the first model to answer the original prompt again, and the fourth response includes: the response output by the second model, and / or, the response of the first model to at least one second question; the second question is a question proposed by the first model and can be answered.

[0393] Specifically, when the computer program is executed by the processor 1102, the following steps can also be implemented:

[0394] Generate a fifth intermediate prompt and input it into the second model in any of the following ways to obtain the response output by the second model:

[0395] Fill the original prompt and each first question into the second prompt template, generate a fifth intermediate prompt and input it into the same second model to obtain the response output by the second model.

[0396] Determine the category to which each first question belongs; fill the original prompt and the first questions in the same category into the second prompt template, generate a fifth intermediate prompt and input it into the second model corresponding to the same category to obtain the response output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category respectively.

[0397] Specifically, when the computer program is executed by the processor 1102, the following steps can also be implemented:

[0398] Receive the response information output by the first model.

[0399] In the case where the response information output by the first model includes at least one first question that the first model cannot answer, determine the first type of question and the second type of question in the at least one first question, wherein the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer.

[0400] In the case where the first type of problem exists in the at least one first problem, based on the original prompt, the first type of problem, and a preset second prompt template, generate a sixth intermediate prompt and input it into a second model to obtain an answer output by the second model; wherein, the second prompt template is used to prompt the second model with the content of the original prompt and request the second model to answer the first type of problem.

[0401] In the case where the second type of problem exists in the at least one first problem, prompt the user with the second type of problem and receive an answer input by the user.

[0402] Based on the original prompt, the fifth answer, and a seventh prompt template, generate a tenth optimized prompt and input it into the first model, wherein the seventh prompt template is used to prompt the first model with the original prompt and the fifth answer and request the first model to answer the original prompt again, and the fifth answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second problem; the second problem is a problem that the first model can answer.

[0403] Specifically, when the computer program is executed by the processor 1102, the following steps can also be implemented:

[0404] Generate a sixth intermediate prompt and input it into the second model in any of the following ways to obtain an answer output by the second model:

[0405] Fill the original prompt and the first type of problem into the second prompt template, generate a sixth intermediate prompt and input it into the same second model to obtain an answer output by the second model.

[0406] Determine the category to which each problem in the first type of problem belongs; fill the original prompt and the problems in the same category into the second prompt template, generate a sixth intermediate prompt and input it into the second model corresponding to the same category to obtain an answer output by the second model corresponding to the same category; wherein, there are multiple second models, and each second model corresponds to a different category.

[0407] Specifically, when the computer program is executed by the processor 1102, the following steps can also be implemented:

[0408] In the case where the answer information includes the answer of the first model to the original prompt, display the answer of the first model to the original prompt.

[0409] When the program is executed by the processor, it can implement all implementation manners in the above prompt optimization method and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0410] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0411] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.

[0412] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, and the indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.

[0413] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiments of this application.

[0414] In addition, the functional units in the various embodiments of this application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.

[0415] When the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art or a part of this technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical discs that can store program codes.

[0416] As described above, the above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed in this application can easily think of changes or substitutions, which should all be covered within the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.

Claims

1. A prompting optimization method, characterized in that, it includes: Receiving the original prompt input by the user; Guiding the first model to initiate a question-and-answer process based on the content of the original prompt, and requesting the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process, where the question-and-answer process includes at least one of the following: the first model asks a question and the second model answers; the first model asks a question and answers it; Obtaining the answer to the original prompt generated by the first model.

2. The method according to claim 1, characterized in that, the guiding the first model to initiate a question-and-answer process based on the content of the original prompt, and requesting the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process includes: Generating an optimized prompt based on the original prompt and a preset prompt template, and inputting the optimized prompt into the first model, where the prompt template is used to guide the first model to initiate a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process.

3. The method according to claim 2, characterized in that, the generating an optimized prompt based on the original prompt and a preset prompt template, and inputting the optimized prompt into the first model includes: Generating a first optimized prompt based on the original prompt and a preset first prompt template, and inputting the first optimized prompt into the first model to obtain at least one question output by the first model; where the first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt; Generating a first intermediate prompt based on the original prompt, the at least one question and a preset second prompt template, and inputting the first intermediate prompt into the second model to obtain the answer output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the question; Generating a second optimized prompt based on the original prompt, the answer output by the second model and a third prompt template, and inputting the second optimized prompt into the first model, where the third prompt template is used to prompt the original prompt and the answer output by the second model to the first model, and request the first model to answer the original prompt.

4. The method according to claim 2, characterized in that, the generating an optimized prompt based on the original prompt and a preset prompt template, and inputting the optimized prompt into the first model includes: Generating a first optimized prompt based on the original prompt and a preset first prompt template, and inputting the first optimized prompt into the first model to obtain at least one question output by the first model; where the first prompt template is used to prompt the content of the original prompt and request the first model to ask questions according to the content of the original prompt; Identify the first type of problem and the second type of problem among the at least one problem, where the first type of problem is a problem that the second model can answer, and the second type of problem is a problem that the second model cannot answer; When there is the first type of problem among the at least one problem, generate a second intermediate prompt based on the original prompt, the first type of problem, and a preset second prompt template, and input it into the second model to obtain the answer output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of problem; When there is the second type of problem among the at least one problem, prompt the second type of problem to the user and receive the answer input by the user; Generate a third optimized prompt based on the original prompt, the first answer, and a third prompt template, and input it into the first model, where the third prompt template is used to prompt the original prompt and the first answer to the first model and request the first model to answer the original prompt; the first answer includes: the answer output by the second model, and / or, the answer input by the user.

5. The method according to claim 2, characterized in that, the generating an optimized prompt based on the original prompt and a preset prompt template and inputting it into the first model includes: generating a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and inputting it into the first model to obtain the answer output by the first model; where the fourth prompt template is used to prompt the content of the original prompt and request the first model to ask questions and output answers according to the content of the original prompt; generating a fifth optimized prompt based on the original prompt and a fifth prompt template, and inputting it into the first model, where the fifth prompt template is used to prompt the original prompt to the first model and request the first model to answer the original prompt.

6. The method according to claim 2, characterized in that, the generating an optimized prompt based on the original prompt and a preset prompt template and inputting it into the first model includes: generating a fourth optimized prompt based on the original prompt and a preset fourth prompt template, and inputting it into the first model to obtain the answer output by the first model; where the fourth prompt template is used to prompt the content of the original prompt and request the first model to ask questions and output answers according to the content of the original prompt; When the answer output by the first model includes at least one first question that the first model cannot answer, generate a third intermediate prompt based on the original prompt, the at least one first question, and a preset second prompt template, and input it into the second model to obtain the answer output by the second model; where the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first question. Generate a sixth optimized prompt based on the original prompt, the second answer, and the third prompt template, and input the sixth optimized prompt into the first model. The third prompt template is used to prompt the original prompt and the second answer to the first model and request the first model to answer the original prompt. The second answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question that the first model can answer.

7. The method according to claim 2, wherein, the generating an optimized prompt based on the original prompt and a preset prompt template and inputting the optimized prompt into the first model includes: generating a fourth optimized prompt based on the original prompt and a preset fourth prompt template and inputting the fourth optimized prompt into the first model to obtain the answer output by the first model; wherein, the fourth prompt template is used to prompt the content of the original prompt and request the first model to ask questions and output answers according to the content of the original prompt; when the answer output by the first model includes at least one first question proposed by the first model and not answered by the first model, determining a first type of question and a second type of question among the at least one first question, wherein the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer; when there is a first type of question among the at least one first question, generating a fourth intermediate prompt based on the original prompt, the first type of question, and a preset second prompt template and inputting the fourth intermediate prompt into the second model to obtain the answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of question; when there is a second type of question among the at least one first question, prompting the second type of question to the user and receiving the answer input by the user; generating a seventh optimized prompt based on the original prompt, the third answer, and the third prompt template, and inputting the seventh optimized prompt into the first model. The third prompt template is used to prompt the original prompt and the third answer to the first model and request the first model to answer the original prompt. The third answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question; the second question is a question proposed by the first model and can be answered by the first model.

8. The method according to any one of claims 3 to 7, wherein, the obtaining the answer of the first model to the original prompt includes: receiving and displaying the answer of the first model to the original prompt output by the first model.

9. The method according to claim 2, wherein, the generating an optimized prompt based on the original prompt and a preset prompt template and inputting the optimized prompt into the first model includes: Generate an eighth optimized prompt based on the original prompt and the sixth prompt template, and input the eighth optimized prompt into the first model. The sixth prompt template is specifically used to prompt the content of the original prompt, request the first model to ask questions and provide answers based on the content of the original prompt, and provide answers to the original prompt.

10. The method according to claim 9, wherein, the obtaining of the answer to the original prompt generated by the first model includes: receiving the answer information output by the first model; when the answer information output by the first model includes at least one first question that the first model asks and cannot answer, generating a fifth intermediate prompt based on the original prompt, the at least one first question, and a preset second prompt template, and inputting the fifth intermediate prompt into a second model to obtain the answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first question; generating a ninth optimized prompt based on the original prompt, the fourth answer, and a seventh prompt template, and inputting the ninth optimized prompt into the first model, wherein the seventh prompt template is used to prompt the original prompt and the fourth answer to the first model and request the first model to answer the original prompt again, and the fourth answer includes: the answer output by the second model, and / or, the answer of the first model to at least one second question; the second question is a question that the first model asks and can answer.

11. The method according to claim 9, wherein, the obtaining of the answer to the original prompt generated by the first model includes: receiving the answer information output by the first model; when the answer information output by the first model includes at least one first question that the first model cannot answer, determining a first type of question and a second type of question among the at least one first question, wherein the first type of question is a question that the second model can answer, and the second type of question is a question that the second model cannot answer; when there is a first type of question among the at least one first question, generating a sixth intermediate prompt based on the original prompt, the first type of question, and a preset second prompt template, and inputting the sixth intermediate prompt into the second model to obtain the answer output by the second model; wherein, the second prompt template is used to prompt the content of the original prompt to the second model and request the second model to answer the first type of question; when there is a second type of question among the at least one first question, prompting the second type of question to the user and receiving the answer input by the user; Generate a tenth optimized prompt based on the original prompt, the fifth answer, and the seventh prompt template, and input the tenth optimized prompt into the first model, where the seventh prompt template is used to prompt the first model with the original prompt and the fifth answer and request the first model to answer the original prompt again, and the fifth answer includes one or more of the following answers: the answer input by the user; the answer output by the second model; the answer of the first model to at least one second question, where the second question is a question that the first model can answer.

12. The method according to any one of claims 10 to 11, characterized in that the obtaining of the answer of the first model to the original prompt further includes: when the answer information includes the answer of the first model to the original prompt, displaying the answer of the first model to the original prompt.

13. A prompt optimization device, characterized in that it includes: a receiving module, configured to receive an original prompt input by a user; a guiding module, configured to guide the first model to start a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process, where the question-and-answer process includes at least one of the following: the first model asks a question and the second model answers; the first model asks a question and answers it; an obtaining module, configured to obtain the answer of the first model to the original prompt.

14. The device according to claim 13, characterized in that the guiding module includes: a prompt construction module, configured to generate an optimized prompt based on the original prompt and a preset prompt template, and input the optimized prompt into the first model, where the prompt template is used to guide the first model to start a question-and-answer process based on the content of the original prompt, and request the first model to answer the original prompt according to the original prompt and the context information obtained during the question-and-answer process.

15. A computer-readable storage medium, the computer-readable storage medium stores a computer program, characterized in that when the computer program is executed by a processor, the steps of the prompt tuning method according to any one of claims 1 to 12 are implemented.