Method and device for generating answers
By collaboratively and iteratively updating prompt words through multiple model components, the problems of time-consuming and labor-intensive prompt word design and poor adaptability in existing technologies are solved, and efficient and accurate answer generation is achieved, which is suitable for a variety of tasks and fields.
Patent Information
- Application Number
- CN202511326237.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-17
- Publication Date
- 2025-10-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technologies have problems in designing prompt words, such as being time-consuming and labor-intensive, relying on expert experience, having high computational costs, poor adaptability, and limited flexibility. This makes it difficult to quickly obtain high-quality prompt words to improve the efficiency and accuracy of answer generation.
Through the collaboration of multiple model components, the initial prompt words are iteratively updated, including construction of initial prompt words, quality assessment and optimization, and the use of large language models to generate answers, achieving dynamic adaptation to different user questions.
It improves the efficiency and accuracy of answer generation, is highly adaptable, and is suitable for various tasks and fields, while reducing deployment costs and computing resource requirements.
Smart Images

Figure CN120822518A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of this specification relate to the field of artificial intelligence, and more particularly, to a method and apparatus for generating answers. Background Art
[0002] Large language models (LLMs) and agents (collectively referred to as model components) are two key concepts in artificial intelligence and computer science. Large language models are used to perform simple, single data analysis tasks, such as answering questions. Agents, which can be implemented based on LLMs, are entities that possess at least one of the following capabilities: perception, decision-making, and execution. They are typically used to complete complex tasks, such as automated programming and e-commerce operations.
[0003] The aforementioned model components typically complete tasks guided by prompts, and the quality of these prompts directly impacts task performance. However, designing high-quality prompts presents numerous challenges: A deep understanding of task requirements, model characteristics, and domain knowledge is required; different prompts need to be designed for different tasks; and improperly designed prompts can lead to error accumulation, impacting the overall performance of the model or agent.
[0004] Therefore, there is an urgent need for a reasonable and reliable solution that can quickly and easily obtain effective prompt words to improve the efficiency and accuracy of answer generation. Summary of the Invention
[0005] One or more embodiments of this specification describe a method and device for generating answers. During the answer generation process, multiple model components collaborate to automatically update the initial prompt words, thereby quickly and easily obtaining effective prompt words, thereby improving the efficiency and accuracy of answer generation.
[0006] In a first aspect, a method for generating an answer is provided, comprising: Build initial prompt words based on user questions; Iteratively performing several rounds of update operations on the initial prompt word; wherein a single round of update operations includes inputting the current prompt word into a first model component to obtain a current answer to the user question; performing a quality assessment on the current prompt word based on the current answer and the user question to obtain a current assessment result; inputting the current prompt word and the current assessment result into a second model component, causing the second model component to optimize the current prompt word based on the current assessment result to obtain an updated prompt word; The updated prompt words obtained after the several rounds of update operations are input into the first model component to obtain the target answer to the user question.
[0007] In a second aspect, a device for generating an answer is provided, comprising: Construction unit, used to construct initial prompt words based on user questions; an execution unit, configured to iteratively execute several rounds of update operations on the initial prompt word; The execution unit includes: A generation submodule, configured to input the current prompt word into the first model component to obtain a current answer to the user question; An evaluation submodule, configured to perform a quality evaluation on the current prompt word based on the current answer and the user question, and obtain a current evaluation result; an optimization submodule, configured to input the current prompt word and the current evaluation result into a second model component, and instruct the second model component to optimize the current prompt word based on the current evaluation result to obtain an updated prompt word; The input unit is used to input the update prompt words obtained after the several rounds of update operations into the first model component to obtain a target answer to the user question.
[0008] According to a third aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method according to the first aspect.
[0009] In a fourth aspect, a computing device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method of the first aspect is implemented.
[0010] The method for generating answers provided in one or more embodiments of this specification, after obtaining a user question, first uses multiple model components to iteratively update the initial prompt words constructed based on the user question for several rounds, and then inputs the updated prompt words into the model component used to generate the answer to obtain the answer to the user question. In other words, this solution automatically updates the initial prompt words through the collaboration of multiple model components, thereby quickly and easily obtaining effective prompt words, thereby improving the efficiency and accuracy of answer generation. In addition, because the prompt words are dynamically updated during the answer generation process, they can dynamically adapt to different user questions, which greatly improves the universal adaptability of this solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0012] Figure 1 A schematic diagram of an implementation scenario of an embodiment disclosed in this specification; Figure 2 A flowchart of a method for generating an answer according to one embodiment of the present specification is shown; Figure 3 A schematic diagram of a device for generating answers according to one embodiment of the present specification is shown. DETAILED DESCRIPTION
[0013] The solution provided in this specification is described below in conjunction with the accompanying drawings.
[0014] As mentioned above, it is very necessary to design high-quality prompt words for model components. Currently, there are several main prompt word design schemes: First, manually designing prompt words. This involves human experts manually designing and debugging prompt words based on task requirements and model characteristics, optimizing their effectiveness through trial and error and accumulated experience. This approach has the following drawbacks: a. It is time-consuming and labor-intensive, making it difficult to scale; b. It relies on expert experience, which is subject to subjectivity and inconsistency; c. It cannot dynamically adapt to different tasks and inputs; and d. Its optimization effect is limited, making it difficult to achieve optimal performance.
[0015] Second, there are gradient-based optimization solutions. These utilize the model's gradient information to optimize the token representation of prompt words through a backpropagation algorithm, such as AutoPrompt and P-tuning. These solutions have the following drawbacks: a. They require access to the model's internal parameters and gradient information; b. They are not suitable for black-box models or API call scenarios; c. The optimization process is complex and computationally expensive; and d. They may lead to overfitting and have limited generalization capabilities.
[0016] Third, there's a reinforcement learning-based approach. This involves modeling the prompt word design as a reinforcement learning problem, using reward signals to guide the agent in learning the optimal prompt word. This approach has the following drawbacks: a. It requires a large amount of training data and a clear reward function; b. The training process is unstable and convergence is difficult; c. It has poor adaptability to new tasks, requiring retraining; and d. It requires large amounts of computing resources and is expensive to deploy.
[0017] Fourth, there's the template-based and rule-based approach. This involves pre-defining prompt word templates and rules, then selecting appropriate templates based on the task type to fill in and combine them. This approach has the following drawbacks: a) limited flexibility, making it difficult to handle complex and changing tasks; b) manual template design still requires human input, which can lead to design bias; c) the inability to dynamically adjust based on execution results; and d) limited adaptability to new domains and tasks.
[0018] Fifth, there's the solution based on evolutionary optimization algorithms. This involves using evolutionary algorithms like genetic algorithms and particle swarm optimization to search for initial prompt words, then iteratively improving them through mutation and selection. This solution has the following drawbacks: a. The search space is large, resulting in slow convergence; b. It requires a large number of model calls, resulting in high costs; c. It lacks semantic understanding, potentially leading to deviations in the optimization direction; and d. It's difficult to guarantee a globally optimal solution.
[0019] Sixth, a retrieval-based approach involves pre-building a library of prompt words, then retrieving relevant high-quality prompt words based on task similarity for reuse and combination. This approach has the following drawbacks: a. It relies on the construction and maintenance of a high-quality prompt word library; b. Similarity matching may be inaccurate; c. It cannot handle completely new types of tasks; and d. It lacks personalization and dynamic optimization capabilities.
[0020] To this end, this solution proposes to automatically update the initial prompt word during the answer generation process through the collaboration of multiple model components. This collaborative approach allows for quick and easy acquisition of effective prompt words, thereby improving the efficiency and accuracy of answer generation. Furthermore, dynamically updating prompt words during answer generation allows for dynamic adaptation to different user questions, significantly enhancing the solution's universal adaptability.
[0021] Figure 1 This is a schematic diagram of an implementation scenario of an embodiment disclosed in this specification. Figure 1 In the example above, an initial prompt word p0 is constructed based on the user question q. Several rounds of updates are then performed on this initial prompt word p0. Each update round is completed collaboratively by multiple model components. These multiple model components include at least the LLM_task model component for generating answers and the LLM_optimizer model component for optimizing prompt words.
[0022] The above single-round update operation specifically includes: first, the current prompt word p i Enter LLM_task and get the current answer O i Then based on the current answer O i and user question q, for the current prompt word p i Perform quality assessment and obtain the current assessment result f i Finally, the current prompt word p i and the current evaluation result f i Input LLM_optimizer and let it be based on the current evaluation result f i , for the current prompt word p i Optimize and get the update prompt word.
[0023] After several rounds of update operations are completed, the update prompt word obtained in the last round is input into LLM_task to obtain the target answer to the user's question.
[0024] In one example, the above-mentioned current prompt word p i The quality assessment can be performed using the model component LLM_feedback.
[0025] Of course, in practice, the current prompt word p can also be evaluated according to the preset evaluation rules. i Perform quality assessment, which is not limited in this manual.
[0026] Figure 2 The flowchart of the method for generating answers according to one embodiment of the present specification is shown. The method can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities. Figure 2 As shown, the method may include the following steps: Step S202: construct an initial prompt word p0 based on the user question q.
[0027] The user questions q here can be divided into two categories: the first category is simple questions, such as "How much is a plane ticket from Beijing to Chengdu?" or "My code reports an error. How can I debug and fix it?"; the second category is complex questions with goals or tasks, such as "Please help me book a plane ticket from Beijing to Chengdu for less than 5,000 yuan" or "My code reports an error. Please help me fix it." In one example, based on the target task type to which user question q belongs, a target prompt word template that matches the target task type can be selected from multiple preset prompt word templates corresponding to multiple task types. The initial prompt word p0 is then obtained by filling the target prompt word template with user question q.
[0028] Of course, when the target task type to which the user question q belongs is unclear, the target prompt word template can also be selected from the above-mentioned multiple preset prompt word templates by calculating the similarity between the user question q and each task type.
[0029] The similarity here may include but is not limited to Euclidean distance, cosine distance, etc.
[0030] In a more specific example, the target prompt word template includes at least an input data portion; in addition, it may also include a model role portion, a task instruction portion, an input data portion, a contextual information portion, a reference example portion, and an output constraint portion. Filling the target prompt word template with the user question q may specifically refer to filling the input data portion with the user question q.
[0031] In another example, the initial prompt word p0 may also be compiled based on expert experience or actual needs.
[0032] Step S204: iteratively perform several rounds of updating operations on the initial prompt word p0.
[0033] Among them, any i-th round of update operation may include the following steps: Step S2042: the current prompt word p i Input model component LLM_task and get the current answer O to the user question q i .
[0034] It should be understood that when the above-mentioned i-th round of updating operation is the first round of updating operation, the above-mentioned current prompt word p i This is the initial prompt word p0.
[0035] In an example, the model component LLM_task may be a large language model.
[0036] Throughout this document, a large language model (LLM) may also be referred to simply as a large model. A LLM is a natural language processing model based on deep learning technology. Its parameters typically range from billions to hundreds of billions, or even higher, and it possesses powerful language understanding and generation capabilities. LLMs can utilize the Transformer architecture or its variants (such as GPT and BERT). This architecture utilizes the attention mechanism to globally model sequential data, efficiently handling long-range dependencies and thus excelling in natural language tasks. LLMs are pre-trained on large corpora to learn the statistical characteristics and semantic relevance of language, enabling superior generalization capabilities. LLMs' core capabilities include, but are not limited to, understanding contextual semantics, generating coherent and grammatically correct text, performing logical reasoning, and handling multi-task scenarios. LLMs are typically used in two modes: direct inference and fine-tuning. In direct inference mode, users design prompts to guide the LLM to generate specific outputs. Prompts can be textual task descriptions or instructions designed to stimulate the LLM's semantic understanding and generation capabilities. In fine-tuning mode, large language models are further trained on smaller datasets in specific domains to optimize their performance on specific tasks. The powerful generalization and flexibility of large language models make them a vital tool in the field of artificial intelligence, providing efficient and accurate solutions for automated text generation and comprehension.
[0037] In some embodiments, large language models may also have the ability to understand and generate data from other modalities (such as vision, audio, etc.). In this case, large language models may also be referred to as multimodal large language models (MLLMs). MLLMs provide a richer and more natural interactive experience by integrating multiple types of inputs and outputs such as text, images, and sound. The core advantage of MLLMs is that they can process and understand information from different modalities and fuse this information to complete complex tasks. For example, MLLMs can analyze a picture and generate descriptive text, or generate a corresponding image based on the text description. This cross-modal understanding and generation capability gives MLLMs broad application prospects in multiple fields.
[0038] It should be noted that the key technologies of large language models can be found in the detailed description in the paper "A Survey of Large Language Models" (paper number: arXiv:2303.18223v16, published on March 11, 2025, public link: https: / / doi.org / 10.48550 / arXiv.2303.18223), which will not be repeated in this manual.
[0039] In another example, the model component LLM_task can be a dedicated agent dedicated to generating answers to user questions in various fields, including but not limited to medical care, finance, education, the Internet, etc.
[0040] The aforementioned agent can be configured using a pre-trained large language model with specific prompts. For example, a target prompt can be constructed, including text defining the agent's reasoning steps and text illustrative of these steps. The target prompt is then fed into the large language model to configure it as an agent.
[0041] The agent's reasoning steps may include observation, thinking, and action. The agent loops through these steps until a termination condition is met (e.g., a preset number of loops).
[0042] Specifically, in the observation step, the agent observes the current context and its own traversal and reasoning results, obtaining corresponding observation results. In the reflection step, the agent reflects on the observation results and decides which action to perform. In the action execution step, the agent executes the specific action determined in the reflection step. These actions include search actions, query actions, and completion actions.
[0043] It should be noted that this solution can also limit the current answer by adjusting the parameters of the model components or the prompt words. i The length of the current answer O i The length of the task can ensure timely feedback and precise optimization, thereby effectively controlling the error accumulation in multi-step tasks and improving the overall task success rate.
[0044] Step S2044, based on the current answer O i and user question q, for the current prompt word p i Perform quality assessment and obtain the current assessment result f i .
[0045] In one embodiment, the quality evaluation rules can be combined with the current answer. i and user question q, for the current prompt word p i Conduct quality assessment.
[0046] The above-mentioned quality assessment rules may include: semantic relevance rules, logic and coherence rules, depth and completeness rules, language and format rules, etc.
[0047] Among them, the semantic relevance rules can further include: a. Keyword matching: that is, checking the current answer O i Whether it contains the core keywords or synonyms in the user's question q; b. Topic consistency: that is, the current answer O i Is it consistent with the main domain of the user question q? b. Intent alignment: that is, the current answer O i Whether it directly responds to the user's intent.
[0048] Logic and coherence rules can further include: a. Whether the answer is irrelevant to the question: that is, the current answer is O i Should not deviate from the user's question; b. Logical clarity: that is, the current answer O i Is the structure clear, rather than a chaotic pile of information? c. Contradiction: that is, the current answer is O i There should be no logical contradictions within or with known facts.
[0049] Depth and completeness rules can further include: a. Information coverage: that is, the current answer O i Whether all sub-questions of the user question q are covered; b. Level of detail: that is, the current answer O i Whether sufficient details are provided; c. Whether there is a follow-up question: that is, if the user's question q is vague, the current answer O i Whether to proactively ask questions or clarify.
[0050] Language and format rules can further include: a. Whether the language style matches: that is, the current answer is O iWhether the style meets user needs; b. Whether there is redundant information: The current answer is O i Is there any duplication or irrelevant content? c. Format standardization: In the current answer O i In more complex cases, are lists, tables, and code blocks used to improve readability?
[0051] In one example, the current answer O can be evaluated based on the above rules. i Scoring, and finally synthesizing the scores obtained based on each rule, and then using the comprehensive score as the i The current evaluation result f i .
[0052] In practice, different quality assessment rules can be pre-defined for different task types.
[0053] In another embodiment, the current answer O i and the user question q and the current prompt word p i Input model component LLM_feedback, let it evaluate the current prompt word p from several evaluation dimensions describing the rationality of the answer i Conduct quality assessment.
[0054] In an example, the model component LLM_feedback may be a large language model, and the large language model is the same as the large language model used to implement LLM_task.
[0055] It should be understood that when LLM_feedback and LLM_task are implemented as the same large language model, different roles can be set for them respectively so that they perform the tasks of quality assessment and answer generation respectively.
[0056] In another example, the above-mentioned model component LLM_feedback may be a special agent dedicated to performing quality assessment on input text. The configuration method of the special agent can be referred to as described above and will not be repeated here.
[0057] Specifically, the above-mentioned evaluation dimensions include one or more of the following: correctness, which indicates the current answer O i Whether it is correct and whether it can truly reflect objective reality; completeness, which indicates whether the current answer is correct or not. i Whether it fully covers the user question q without missing any key details; logicality, which indicates the current answer O i Is the organization and expression logical, easy to understand, and free of contradictions? Relevance, which indicates the current answer i Is it highly relevant to the user's question q and not off-topic? Coherence, which indicates the current answer Oi Whether it is coherent, clear, and grammatically and word-wise correct; objectivity, which indicates the current answer i Whether it is impersonal or biased and based on facts and evidence; Actionability, which indicates the current answer i Is it specific and clear, can it be implemented smoothly in practice? Is it personified? It indicates the current answer is O i Whether the tone, word choice, emotional expression, etc. are natural and friendly.
[0058] In a more specific embodiment, the current answer O can be evaluated from the above-mentioned evaluation dimensions. i Scoring is then performed, and the multiple scores obtained are integrated, and the integrated score is used as the score for the current prompt word p i The current evaluation result f i .
[0059] In another more specific embodiment, the current answer O can also be evaluated from the above-mentioned evaluation dimensions. i Score, and then generate the current prompt word p according to the score i The comments are used as the current prompt word p i The current evaluation result f i .
[0060] Of course, in practice, the above current evaluation results f i It may also include modification suggestions and other content, which is not limited in this manual.
[0061] It is also necessary to explain that when using the model component LLM_feedback to evaluate the current prompt word p i When performing quality assessment, in each iteration, the target prompt word can be used to instruct the model component LLM_feedback to only evaluate the current prompt word p i The specified part is evaluated, and in different rounds of iteration, the current prompt word p i The parts of the assessment can vary.
[0062] The above-mentioned designated parts may include one or more of the following: the role played by the model, task instructions, context information, reference examples, and output constraints, etc.
[0063] For example, the role played by the model can be evaluated in the 1st to tth iterations, the task instructions can be evaluated in the t+1th to t+nth iterations, and so on, until all parts are optimized.
[0064] It should be understood that this is only an exemplary explanation. In practice, multiple parts can also be evaluated in each round of iteration. For example, in the 1st to tth round of iterations, the role and task instructions of the model can be evaluated, and in the t+1th to the last round of iterations, the context information, reference examples and output constraints can be evaluated.
[0065] It should also be understood that in each round of iteration, only the current prompt word p i When evaluating the specified part of i It usually only includes scores (or comments) on designated parts and suggestions for revisions.
[0066] In this solution, the model component LLM_feedback is used to evaluate the current prompt word p i When performing quality assessment, the text understanding ability of a large language model or an intelligent agent can be used to generate structured feedback (i.e., evaluation results) to guide the current prompt word p i This intelligent adjustment eliminates the need for numerical reward signals, breaking away from the traditional optimization methods' reliance on numerical feedback and enabling semantic-level optimization based on natural language. Furthermore, the evaluation results generated by this solution are rich in information and detailed, making them easy to understand and debug, making them applicable to a wide range of tasks.
[0067] Step S2046: the current prompt word p i and the current evaluation result f i Input model component LLM_optimizer, let it be based on the current evaluation result f i , for the current prompt word p i Optimize and get the update prompt word.
[0068] In an example, the model component LLM_optimizer may be a large language model, and the large language model is the same as the large language model used to implement LLM_task and LLM_feedback.
[0069] It should be understood that when LLM_optimizer, LLM_feedback, and LLM_task are implemented as the same large language model, different roles can be set for the three to enable them to perform the tasks of text optimization, quality assessment, and answer generation, respectively.
[0070] In another example, the above-mentioned model component LLM_optimizer can be a special intelligent agent dedicated to text optimization of input text. The configuration method of the special intelligent agent can be referred to as described above and will not be repeated here.
[0071] It should be understood that in the current evaluation result f iIn the case of including only the scoring (or comments) and modification suggestions for the specified part, you can only i Optimize the specified part.
[0072] So far, for the current prompt word p i After a round of update operation is completed, the update prompt word obtained after this round of update operation can be used as the current prompt word for the next round of update operation, and enter the next round of iteration, and so on, until the iteration end condition is reached.
[0073] The iteration end conditions here may include one or more of the following: the number of iteration rounds reaches the predetermined number, the current evaluation result f i The quality score in is greater than the score threshold, and LLM_task predicts the end character EOS, etc.
[0074] Based on the above iteration termination conditions, the stability and controllability of this scheme can be ensured.
[0075] It can be seen that this scheme can evaluate and improve the quality of prompt words in real time during task execution. That is, it can dynamically adjust the prompt words according to the specific input and intermediate results, avoiding the limitations of static optimization.
[0076] Furthermore, this solution utilizes a collaborative architecture of three model components during the automated optimization process, achieving a division of labor among answer generation, quality assessment, and text optimization. Compared to traditional training-time optimization or single-model component optimization approaches, this solution provides clear responsibilities for each model component, resulting in better optimization results and ease of scalability and maintenance.
[0077] Step S206: The updated prompt words obtained after several rounds of update operations are input into the model component LLM_task to obtain the target answer to the user's question.
[0078] The target answer here is the final answer returned to the user.
[0079] In summary, this solution provides an optimization framework that relies only on text input and output, without accessing the model's internal parameters. It is suitable for prompt word optimization of various black box models. This can break through the requirements of traditional optimization methods for model transparency and achieve true model-independent optimization. It has a wide range of applications, simple deployment, and supports cloud API calls.
[0080] In addition, this solution builds a complete closed loop from task execution (i.e., answer generation) to quality assessment and then to text optimization, that is, it realizes fully automated closed-loop control in prompt word optimization without the need for human intervention, and has the technical advantages of continuous optimization, adaptive adjustment and reduced labor costs.
[0081] Finally, this solution does not rely on prior knowledge of specific tasks, can quickly adapt to new tasks and domains, and has good generalization capabilities. Furthermore, by dynamically updating the prompt word during answer generation, it can significantly improve the performance of small models, bringing them closer to the performance of large models and reducing deployment costs.
[0082] Corresponding to the above-mentioned method for generating answers, an embodiment of this specification also provides a device for generating answers, such as Figure 3 As shown, the device may include: A construction unit 302 is used to construct an initial prompt word based on the user question; An execution unit 304 is configured to iteratively execute several rounds of update operations on the initial prompt word; The execution unit 304 includes: Generate submodule 3042, for inputting the current prompt word into the first model component to obtain the current answer to the user's question; Evaluation submodule 3044, for performing a quality evaluation on the current prompt word based on the current answer and the user question to obtain a current evaluation result; The optimization submodule 3046 is configured to input the current prompt word and the current evaluation result into the second model component, and instruct the second model component to optimize the current prompt word based on the current evaluation result to obtain an updated prompt word; The input unit 306 is used to input the updated prompt words obtained after several rounds of update operations into the first model component to obtain the target answer to the user's question.
[0083] In one embodiment, the evaluation submodule 3044 is specifically configured to: The current answer, user question, and current prompt word are input into the third model component, which is then asked to perform a quality assessment on the current prompt word based on several evaluation dimensions that describe the rationality of the answer.
[0084] In a more specific embodiment, the plurality of evaluation dimensions include one or more of the following: correctness, completeness, logic, relevance, coherence, objectivity, operability, and anthropomorphism.
[0085] In one embodiment, the first model component, the second model component, and the third model component are implemented as three dedicated agents.
[0086] In one embodiment, the first model component, the second model component, and the third model component are implemented by setting different roles for the same large language model.
[0087] In another embodiment, the evaluation submodule 3044 is further configured to: According to the preset quality assessment rules, the quality of the current prompt word is assessed in combination with the current answer and the user question.
[0088] In one embodiment, the single-round update operation is a first-round update operation, and the current prompt word is an initial prompt word.
[0089] In one embodiment, the current evaluation result includes the quality score of the current prompt word, and the iterative termination conditions of the above-mentioned several rounds of update operations include one or more of the following: The number of iteration rounds reaches the predetermined number; The quality score is greater than a score threshold; The first model component predicts a terminator.
[0090] In one embodiment, the evaluation submodule 3044 is further configured to: Perform quality assessment on the specified part of the current prompt word; The optimization submodule 3046 is specifically used for: Optimize the specified part of the current prompt word; The designated portion includes one or more of the following: The role the model plays, task instructions, contextual information, reference examples, and output constraints.
[0091] The functions of the functional units of the device in the above embodiment of this specification can be implemented through the steps of the above method embodiment. Therefore, the specific working process of the device provided by one embodiment of this specification will not be repeated here.
[0092] An embodiment of the present specification provides an answer generation device that automatically updates initial prompt words through collaboration of multiple model components during the answer generation process, thereby enabling quick and easy acquisition of effective prompt words, thereby improving the efficiency and accuracy of answer generation.
[0093] According to another embodiment, there is also provided a computer readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute a combination of Figure 2 The method described.
[0094] According to another embodiment, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the system realizes the combination of Figure 2 The method described.
[0095] The various embodiments in this specification are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the description of the medium or device embodiments is relatively simple because they are generally similar to the method embodiments. For relevant portions, refer to the description of the method embodiments.
[0096] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0097] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of this specification. It should be understood that the above description is only the specific implementation method of this specification and is not intended to limit the scope of protection of this specification. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of this specification should be included in the scope of protection of this specification.
Claims
1. A method for generating an answer, comprising: Build initial prompt words based on user questions; Iteratively performing several rounds of update operations on the initial prompt word; The single-round update operation includes inputting the current prompt word into the first model component to obtain the current answer to the user question; Based on the current answer and the user question, perform a quality assessment on the current prompt word to obtain a current assessment result; Inputting the current prompt word and the current evaluation result into a second model component, and causing the second model component to optimize the current prompt word based on the current evaluation result to obtain an updated prompt word; The updated prompt words obtained after the several rounds of update operations are input into the first model component to obtain the target answer to the user question.
2. The method according to claim 1, wherein The quality assessment of the current prompt word includes: The current answer, the user question, and the current prompt word are input into a third model component, which is instructed to perform a quality assessment on the current prompt word based on several assessment dimensions that describe the rationality of the answer.
3. The method according to claim 2, wherein: The evaluation dimensions include one or more of the following: correctness, completeness, logic, relevance, coherence, objectivity, operability and anthropomorphism.
4. The method according to claim 2, wherein: The first model component, the second model component and the third model component are implemented as three dedicated intelligent agents.
5. The method according to claim 2, wherein: The first model component, the second model component, and the third model component are implemented by setting different roles for the same large language model.
6. The method according to claim 1, wherein The quality assessment of the current prompt word includes: According to preset quality assessment rules, the quality of the current prompt word is assessed in combination with the current answer and the user question.
7. The method according to claim 1, wherein The single-round updating operation is a first-round updating operation, and the current prompt word is the initial prompt word.
8. The method according to claim 1, wherein The current evaluation result includes the quality score of the current prompt word; the iterative termination conditions of the multiple rounds of update operations include one or more of the following: The number of iteration rounds reaches the predetermined number; The quality score is greater than a score threshold; The first model component predicts a terminator.
9. The method according to claim 1, wherein The quality assessment of the current prompt word includes: Performing a quality assessment on a specified portion of the current prompt word; The optimizing the current prompt word includes: Optimizing the designated portion of the current prompt word; The designated portion includes one or more of the following: The role the model plays, task instructions, contextual information, reference examples, and output constraints.
10. A device for generating an answer, comprising: Construction unit, used to construct initial prompt words based on user questions; an execution unit, configured to iteratively execute several rounds of update operations on the initial prompt word; The execution unit includes: A generation submodule, configured to input the current prompt word into the first model component to obtain a current answer to the user question; An evaluation submodule, configured to perform a quality evaluation on the current prompt word based on the current answer and the user question, and obtain a current evaluation result; an optimization submodule, configured to input the current prompt word and the current evaluation result into a second model component, and instruct the second model component to optimize the current prompt word based on the current evaluation result to obtain an updated prompt word; The input unit is used to input the update prompt words obtained after the several rounds of update operations into the first model component to obtain a target answer to the user question.
11. A computer-readable storage medium having a computer program stored thereon, wherein: When the computer program is executed in a computer, the computer is caused to execute the method according to any one of claims 1 to 9.
12. A computing device comprising a memory and a processor, wherein: The memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Prompt word updating method, device and system based on multi-dimensional large language model
CN118132716A
Prompt word optimization method and device based on large model
CN119271769A
Question answering method and device based on large model, training method and device, intelligent agent, equipment and medium
CN120470097A