User question and answer interaction method and device, storage medium and program product
By introducing a memory bank and multiple large language models into the AI dialogue system, the system can identify user intent and generate rich prompts, thus solving the problem of inaccurate responses in existing AI dialogue systems and achieving efficient and accurate user question-and-answer interaction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ALIBABA CLOUD COMPUTING CO LTD
- Filing Date
- 2024-10-25
- Publication Date
- 2026-04-28
AI Technical Summary
Existing AI dialogue systems use only a large language model and have simple prompts, making them unable to efficiently and accurately respond to user-input dialogues.
Using a pre-configured memory bank and a trained first and second language model, rich prompt words are generated by recognizing the user's input intent and then input into the second language model to obtain accurate answers.
It improves the efficiency and accuracy of user question-and-answer interactions, ensuring the diversity and accuracy of the answers.
Smart Images

Figure CN121935339A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a user question-and-answer interaction method, device, storage medium, and program product. Background Technology
[0002] With the continuous development of technology, artificial intelligence (AI) dialogue systems have been widely used in users' work, life, entertainment and other aspects. Users can communicate with AI dialogue systems (such as chatbots, virtual dialogue assistants, etc.) through voice or text.
[0003] Existing AI dialogue systems typically rely on a Large Language Model (LLM) to facilitate conversations with users. In practice, the user inputs a dialogue into the AI system, which then retrieves relevant content from its knowledge base. The retrieved content, along with the user's input, is then fed into the LLM as prompts to generate the LLM's response to the user's dialogue.
[0004] The inventors have discovered that the prior art has at least the following problems:
[0005] Existing AI dialogue systems use only a large language model and have relatively simple prompts, which only include the dialogue entered by the user and relevant content retrieved from the knowledge base. They cannot provide efficient and accurate responses to the dialogue entered by the user. Summary of the Invention
[0006] This invention provides a user question-and-answer interaction method, device, storage medium, and program product for efficiently and accurately responding to the first question input by a user.
[0007] In a first aspect, embodiments of the present invention provide a user question-and-answer interaction method, applied to an artificial intelligence assistant program, the method comprising:
[0008] Receive the first question input by the user in the target application scenario;
[0009] Retrieve contextual information related to the content of the first question from the memory bank;
[0010] Based on the content of the first question and the historical interaction information flow generated before the content of the first question, the first intent matching the content of the first question is identified in the set intent library through the first language model, so as to obtain the response information corresponding to the first intent. The historical interaction information flow includes at least one round of historical question content and historical answer content generated within a set historical time period, as well as the execution action information of the user and the artificial intelligence assistant program within the set historical time period.
[0011] A first prompt word is generated based on the target application scenario, the context information, the first intent, the response information corresponding to the first intent, and the historical interaction information stream.
[0012] The first prompt word is input into the second language model to obtain the first answer content corresponding to the first question content.
[0013] Secondly, embodiments of the present invention provide a user question-and-answer interaction device, applied to an artificial intelligence assistant program, the device comprising:
[0014] The receiving module is used to receive the first question input by the user in the target application scenario;
[0015] The retrieval module is used to retrieve contextual information related to the content of the first question from the memory.
[0016] The identification module is used to identify a first intent that matches the first question content in a set intent library based on the first question content and the historical interaction information stream generated before the first question content, through a first language model, so as to obtain response information corresponding to the first intent. The historical interaction information stream includes at least one round of historical question content and historical answer content generated within a set historical time period, as well as the execution action information of the user and the artificial intelligence assistant program within the set historical time period.
[0017] The generation module is used to generate a first prompt word based on the target application scenario, the context information, the first intent, the response information corresponding to the first intent, and the historical interaction information stream;
[0018] The input module is used to input the first prompt word into the second language model to obtain the first answer content corresponding to the first question content.
[0019] Thirdly, embodiments of the present invention provide an electronic device, including: a memory, a processor, and a communication interface; wherein, the memory stores executable code, and when the executable code is executed by the processor, the processor executes the user question-and-answer interaction method as described in the first aspect.
[0020] Fourthly, embodiments of the present invention provide a non-transitory machine-readable storage medium storing executable code, wherein when the executable code is executed by a processor of an electronic device, the processor executes the user question-and-answer interaction method as described in the first aspect.
[0021] Fifthly, embodiments of the present invention provide a computer program product, the computer program product comprising: a computer program, which, when executed by a processor of an electronic device, causes the processor to execute the user question-and-answer interaction method as described in the first aspect.
[0022] The user question-and-answer interaction method provided in this invention obtains the first question input by the user in the target application scenario, as well as the historical interaction information flow generated before the first question. It then uses a first language model to identify the first intent matching the first question in a predefined intent library, thereby obtaining the response information corresponding to the first intent. This essentially completes the thought process on how to respond to the user's first question, laying the foundation for an accurate answer. Subsequently, based on the target application scenario, the contextual information related to the first question retrieved from the memory library, the first intent, the response information corresponding to the first intent, and the historical interaction information flow, a first prompt word is generated. It should be understood that this first prompt word contains not only the user's first question and the retrieved contextual information, but also various other types of related reference information, making it richer in content. Based on this, inputting the first prompt word into a second language model yields a more accurate first answer. Furthermore, in the above user question-and-answer interaction process, the retrieval operation in the memory library and the intent matching operation using the first language model can be performed simultaneously, improving the efficiency of the user question-and-answer interaction. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a schematic diagram of the structure of a user question-and-answer interaction system provided in an embodiment of the present invention;
[0025] Figure 2 A flowchart illustrating a user question-and-answer interaction method provided in an embodiment of the present invention;
[0026] Figure 3Another flowchart of a user question-and-answer interaction method provided in an embodiment of the present invention;
[0027] Figure 4 This is an application diagram of a user question-and-answer interaction system provided in an embodiment of the present invention;
[0028] Figure 5 A schematic diagram illustrating the application of the intent library provided in an embodiment of the present invention;
[0029] Figure 6 This is a schematic diagram illustrating the application of a user question-and-answer interaction method provided in an embodiment of the present invention;
[0030] Figure 7 This is a schematic diagram of the structure of a user question-and-answer interaction device provided in an embodiment of the present invention;
[0031] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0033] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0034] The following detailed description of some embodiments of the present invention is provided in conjunction with the accompanying drawings. Where there is no conflict between the embodiments, the following embodiments and features can be combined with each other. Furthermore, the timing of the steps in the following method embodiments is merely an example and not a strict limitation.
[0035] First, the terms or concepts involved in the embodiments of this invention will be explained:
[0036] Large Language Model (LLM): This refers to a deep learning model trained on massive amounts of text data, possessing powerful expressive and generalization capabilities. It can not only generate natural language text but also deeply understand the meaning of text, handling various natural language tasks such as text summarization, question answering, and translation.
[0037] This invention utilizes a large language model based on the Transformer architecture, which typically contains over one billion parameters. The model is first pre-trained on a public dataset containing over 1TB of text data to learn general language representations. Subsequently, to adapt to the specific application scenario of this invention—a question-answering system—the model is fine-tuned on a dedicated dataset containing a large number of dialogue records. This model receives a user question or one or more previous rounds of dialogue records as input and can generate accurate responses as output. This invention leverages the advantages of large language models in terms of generative capabilities to better capture complex relationships within the context and generate more natural, fluent, and accurate answers.
[0038] With the continuous development of technology, artificial intelligence (AI) dialogue systems have been widely used in users' work, life, and entertainment. However, the AI dialogue systems used in the current technology only use a large language model, and the design of prompt words is relatively simple, only including the dialogue entered by the user and the relevant content retrieved from the knowledge base. They cannot provide efficient and accurate responses to the dialogue entered by the user.
[0039] In view of this, embodiments of the present invention provide a user question-and-answer interaction system that solves the above problems through the following approach: A pre-configured memory bank, and a trained first and second language model. In practical applications, the system acquires the first question input by the user in the target application scenario. Based on the first question content and the historical interaction information flow preceding it, the first language model identifies the first intent matching the first question content in a pre-defined intent bank to obtain the response information corresponding to the first intent, understand the user's current dialogue intent, and consider how to respond to the user's input of the first question content. Then, the system retrieves contextual information related to the first question content from the memory bank and generates a first prompt word based on the target application scenario, contextual information, the first intent, the response information corresponding to the first intent, and the historical interaction information flow. Since this first prompt word contains various types of relevant reference information such as the application scenario, user intent, and historical interaction details, its content is richer. Therefore, by inputting this first prompt word into the second language model, the first answer content corresponding to the user's input of the first question content can be accurately obtained. In the aforementioned user question-and-answer interaction process, the retrieval operation in the memory bank and the intent matching operation using the first language model for first intent matching can be performed simultaneously, improving the efficiency of user question-and-answer interaction.
[0040] Figure 1 This is a schematic diagram of the structure of a user question-and-answer interaction system provided in an embodiment of the present invention, such as... Figure 1 As shown, the system includes a memory bank 10, a first large language model 20, and a second large language model 30. In practical applications, when the AI assistant program receives the first question input by the user in the target application scenario, it can retrieve contextual information related to the first question from the memory bank so that a first prompt word can be generated based on this contextual information. The first large language model 20 is used to identify the first intent matching the first question input by the user in the target application scenario and the historical interaction information flow generated before the first question, and obtain the response information corresponding to the first intent. The second large language model 30 is used to obtain the first answer content corresponding to the first question content based on the target application scenario, contextual information, the first intent, the response information corresponding to the first intent, and the first prompt word generated by the historical interaction information flow.
[0041] For details on the specific application of the aforementioned memory bank 10, the first large language model 20, and the second large language model 30, please refer to the embodiments below; they will not be described in detail here. In this embodiment of the invention, the first large language model 20 and the second large language model 30 may adopt the same model structure or different model structures.
[0042] Figure 2 A flowchart illustrating a user question-and-answer interaction method provided in an embodiment of the present invention is shown. This method is applied to an artificial intelligence assistant program, such as... Figure 2 As shown, the method includes the following steps:
[0043] 201. Receive the first question input by the user in the target application scenario.
[0044] 202. Retrieve contextual information related to the content of the first question from the memory.
[0045] 203. Based on the content of the first question and the historical interaction information flow generated before the content of the first question, the first intent matching the content of the first question is identified in the set intent library through the first language model, so as to obtain the response information corresponding to the first intent. The historical interaction information flow includes the content of historical questions and answers generated in at least one round within a set historical time period, as well as the execution action information of the user and the artificial intelligence assistant program within the set historical time period.
[0046] 204. Generate the first prompt word based on the target application scenario, context information, primary intent, response information corresponding to the primary intent, and historical interaction information flow.
[0047] 205. Input the first prompt word into the second language model to obtain the first answer content corresponding to the first question content.
[0048] In practical applications, a pre-configured memory bank is used. This memory bank stores reference information corresponding to at least multiple application scenarios, sets the content of historical questions and answers for at least one round generated within a historical period, and sets the execution actions of the user and the AI assistant program within that historical period. These multiple application scenarios can be film and television application scenarios, game application scenarios, customer service dialogue application scenarios, etc., while the target application scenario can be one of these multiple application scenarios. For ease of understanding, the following example illustrates the target application scenario as a game application scenario: An event XX occurs in a science fiction game setting. The event takes place in the year XXX AD in country XX. There are two non-player characters (NPCs) and several player characters. This constitutes the target application scenario.
[0049] In practice, the user inputs a first question into the AI assistant program. Upon receiving this question, the AI assistant program, in order to provide an accurate answer, first determines the user's dialogue intent (i.e., the first intent) and obtains the response information corresponding to it. The process of determining the first intent is as follows: Based on the first question content, historical interaction information flow, and multiple intents in the intent library, a second prompt word is generated. Each intent includes an intent name and response information. The second prompt word is then input into a first language model, enabling the first language model to identify the first intent matching the first question content in the intent library. For ease of understanding, an example is provided below:
[0050] In a role-playing game scenario, the user's role is a "junior student," and the NPC (the AI assistant program mentioned above) is a "senior student." The user's first question is, "What type of boy do you like?" After receiving this first question, the NPC determines at least one round of historical questions and answers that occurred within a set historical timeframe prior to the first question. For example, this could include 20 rounds of questions and answers that occurred within the last 30 minutes before the first question. A specific example is as follows:
[0051] User: Senior, there's something I'm not sure if it's convenient to ask you?
[0052] NPC: Oh, go ahead and ask. As long as you don't ask if I'm single, I can answer anything else.
[0053] User: Haha, how did you know I wanted to ask that?
[0054] .....”
[0055] In addition to determining the content of multiple rounds of questions and answers before the first question, it is also possible to determine the action information of users and NPCs within a set historical time period. For example, if an NPC performs a "flirting" action on a user within 30 minutes.
[0056] After acquiring the content of the first question, the content of at least one round of historical questions and answers generated within a set historical time period, and the execution action information of the user and the AI assistant program within the set historical time period, a second prompt word is generated based on the above information and multiple intents in the set intent library. The intent includes an intent name and response information. For example, the intent name could be "greet," "talk about music," "play the piano," or "ask about personal feelings." The response information can include the answer to the user's input question, the execution action, etc. For example, if the intent name is "ask about personal feelings," the response information could be "flirt with the user and invite them to a date at a bar next time," or "casually say that you are not interested in romance," etc., and so on.
[0057] Furthermore, in the process of determining the first intent described above, the second prompt word can be generated in the following way: determine the second intent matched by the historical question content contained in the historical interaction information flow; determine the intent search range of the first question content based on the intent tree corresponding to the intent library and the second intent, wherein the intent tree is used to describe the flow of multiple intents in the intent library, and the intent search range corresponds to the branch where the second intent is located; generate the second prompt word based on the first question content, the historical interaction information flow, and the intent search range of the first question content.
[0058] It should be noted that the intent library typically contains a large number of intents. Matching the first question content with each intent in the library individually would be time-consuming and inefficient. Therefore, this embodiment of the invention determines the matching second intent based on historical question content within the historical interaction information stream. This second intent and the first intent belong to the same general intent branch in the intent tree used to describe the flow of multiple intents in the intent library. In this case, the branch to which the first intent belongs in the intent tree can be determined simply by using the intent tree and the second intent. Intents under this branch are then used as the intent search range for the first question content. This method narrows the matching range for intent matching based on the first question content in the intent library, improving efficiency. For ease of understanding, an example is provided below:
[0059] Assume there are 100 intents in the intent library. Intents 1-30 belong to branch A of the intent tree, intents 31-70 belong to branch B, and intents 71-100 belong to branch C. The intents corresponding to branches A, B, and C are completely different. If the second intent matched in the 10 rounds of dialogue preceding the user's first question is located in branch A (e.g., A1), then all intents in branch A can be used as the intent search range for the first question. In practice, intent matching can be performed directly in branch A (e.g., the first intent matched is A2), without considering intents in branches B and C. Alternatively, the priority of intents can be dynamically adjusted based on the progress of the dialogue between the user and the NPC. Specifically, if the intent matched by the first language model is the first intent, and the second intent matched in the 10 rounds of dialogue preceding the first question is located in branch A, then the priority of intents in branch A can be adjusted to be higher than the priority of intents in branches B and C.
[0060] After generating a second prompt word based on the content of the first question, the historical interaction information flow, and the intent search range of the first question content, the second prompt word is input into the first language model. This allows the model to identify the first intent matching the first question content from the predefined intent library, thereby obtaining the corresponding response information. For example, if the first question content is "What type of guy do you like?", the intent name of the first intent matching the first question content in the predefined intent library could be "asking about personal feelings," and the response information for this first intent could be "teasing the user and inviting him to a date at a bar next time." It should be understood that using the first language model to match the user's input first question content with intent ensures both efficiency and accuracy in intent matching.
[0061] Next, contextual information related to the first question is retrieved from the memory. Based on the target application scenario, contextual information, first intent, response information corresponding to the first intent, and historical interaction information flow, a first prompt word is generated. This first prompt word is then input into the second language model to obtain the first answer to the first question. The method for retrieving contextual information from the memory can include Retrieval-Augmented Generation (RAG), vector search, etc., which are not limited here. Furthermore, it should be noted that the first and second language models can be large language models with different parameter sizes. For example, the second language model needs to process more dialogue content, so its parameter size can be set larger to ensure the accuracy of its output. In contrast, the first language model only needs to perform some small-scale intent matching work, so its parameter size can be set smaller.
[0062] Furthermore, it should be understood that the role information of the AI assistant program is also very important during the question-and-answer interaction between the user and the AI assistant program. Therefore, in order to ensure that the content output by the second language model based on the first prompt word is more accurate, the persona description information of the AI assistant program can be obtained during the generation of the first prompt word, the role feature information of the AI assistant program can be determined based on the persona description information, and the role feature information can be added to the first prompt word.
[0063] For example, the character description information for this AI assistant program could be: "Your name is Tasia, you are a senior student at the Psionic Academy, you often hang out in the entertainment area, you are young and energetic." Based on this character description information, the corresponding character feature information for the AI assistant program can be determined as: "Name: Tasia; Gender: Female; Style: Young and energetic." After adding this character feature information to the first prompt, its content in the first prompt could be: "You are an excellent actress, playing a character named Tasia. I hope you will use Tasia's style in your conversations and always maintain consistency with Tasia's character setting."
[0064] Based on the above, the user question-and-answer interaction method provided in this embodiment of the invention can identify a first intent matching the user's input of the first question in a set intent library through a first large language model, and obtain the response information corresponding to the first intent. This allows for consideration of how to respond to the user's input of the first question, laying the foundation for an accurate answer. Subsequently, based on the target application scenario, contextual information related to the first question retrieved from the memory library, the first intent, the response information corresponding to the first intent, and historical interaction information flow—a variety of relevant reference information—the content of the first prompt word is enriched, resulting in a more accurate first answer based on the first prompt word. Furthermore, in the above-mentioned user question-and-answer interaction process, the retrieval operation in the memory library and the intent matching operation through the first large language model can be performed simultaneously in parallel, improving the efficiency of user question-and-answer interaction.
[0065] Figure 3 Another flowchart of a user question-and-answer interaction method provided in an embodiment of the present invention is shown below. Figure 3 As shown, the method includes the following steps:
[0066] 301. Receive the first question input by the user in the target application scenario.
[0067] 302. Retrieve contextual information related to the content of the first question from the memory.
[0068] 303. Based on the content of the first question and the historical interaction information flow generated before the content of the first question, the first intent matching the content of the first question is identified in the set intent library through the first major language model, so as to obtain the response information corresponding to the first intent. The historical interaction information flow includes the content of historical questions and answers generated in at least one round within a set historical time period, as well as the execution action information of the user and the artificial intelligence assistant program within the set historical time period.
[0069] 304. Based on the target application scenario, context information, first intent, historical interaction information flow, and the first analysis result corresponding to the historical question content contained in the historical interaction information flow, generate a third prompt word. The first analysis result includes the second question content raised in response to the historical question content and the second answer content corresponding to the second question content retrieved from the memory bank.
[0070] 305. Input the third prompt word into the third language model to obtain the second analysis result corresponding to the content of the first question. The second analysis result includes the content of the third question based on the third prompt word and the third answer content corresponding to the content of the third question retrieved from the memory bank.
[0071] 306. Add the content of the third question and the content of the third answer to the memory bank as context information related to the fourth question when the user enters the content of the fourth question; or, add the content of the third question and the content of the third answer to the context related to the content of the first question, wherein the content of the fourth question is the next question entered by the user after the content of the first question.
[0072] The specific implementation methods for steps 301-303 can be found in the above embodiments, and will not be repeated here.
[0073] In this embodiment of the invention, the third language model can have a larger parameter scale compared to the first and second language models.
[0074] In practical applications, to further improve the accuracy of the final first answer, after obtaining the historical question content contained in the historical interaction information stream, this historical question content can be analyzed to obtain the first analysis result, which is the second question posed in response to the historical question content. The second answer content corresponding to the second question content is then retrieved from the memory database. This process is equivalent to "thinking" about the historical question content generated within a predetermined historical timeframe before the first question content. Subsequently, based on the target application scenario, contextual information, primary intent, historical interaction information stream, and the first analysis result corresponding to the historical question content contained in the historical interaction information stream, a third prompt word is generated. This third prompt word is then input into the third language model to obtain the second analysis result corresponding to the first question content.
[0075] It should be understood that after obtaining the first question input by the user, further in-depth analysis can be conducted by combining the target application scenario, contextual information, primary intent, historical interaction information flow, and the first analysis results corresponding to the historical question content contained in the historical interaction information flow, to obtain the third question content generated in order to achieve a certain goal desired by the user. For example, in a role-playing game scenario, the user's role is a "junior student," and the NPC is a "senior student." The user's goal is to ask the senior student out on a date. In this case, the third question content generated based on the third prompt could be "Senior student, what do you like to eat?"
[0076] After obtaining the content of the third question, the third answer is retrieved from the memory and used as context for the first question input by the user, participating in the subsequent generation of the first answer. Alternatively, the third question and answer are added to the memory as context for the fourth question (i.e., the next question input by the user after the first question), participating in the generation of the answer to the next question.
[0077] Using the content of the third question and the content of the third answer as context related to the first question input by the user can be suitable for application scenarios where latency requirements are not high. It should be understood that generating the third question content based on the third prompt word and retrieving the third answer content related to the third question content from the memory bank takes a certain amount of time. If the current application scenario does not have high time requirements, the content of the third question and the content of the third answer can be used as context related to the first question input by the user. In this way, the accuracy of generating the first answer content corresponding to the first question content can be improved.
[0078] Using the content of the third question and the third answer as context for the fourth question can be suitable for applications with high latency requirements. It should be understood that generating the third question based on the third prompt and retrieving the corresponding third answer from the memory takes time. If the current application scenario has high time requirements, the first answer corresponding to the first question is generated first using the first language model to ensure speed in obtaining the first answer. Then, the third question and the third answer are added to the memory and used as context information for the next question when the user inputs it, allowing for the generation of the answer to the next question. This ensures fast retrieval of the first answer with low latency.
[0079] Furthermore, after executing the question-and-answer interaction of a set round, the content of the question and answer in that round can be summarized using the third language model, and the summary results can be added to the memory. Summarizing the question-and-answer content of a set round can also be understood as extracting key information from the question and answer content. By adding the extracted key information to the memory, it is helpful to quickly extract key information based on the historical interaction information flow when answering user input questions in subsequent sessions, thus improving work efficiency. For example, the summary result could be a summary conclusion such as "A is a very good person" or "B is not cost-effective," etc., which will not be listed here.
[0080] The third language model mentioned above, besides summarizing the question-and-answer content of a set round, can also reflect and summarize based on the historical interaction information flow after executing a set round of question-and-answer interaction (or after each certain number of dialogue rounds). The result of this reflection and summary can serve as a new fourth cue word, with the aim of uncovering new intentions. In practice, if a new intention is uncovered based on the fourth cue word, it means that the third language model has discovered a new and valuable dialogue method based on the reflection and summary results. At this point, the current intention can be directly updated to the uncovered new intention. During the above reflection and summary process, it is possible to determine in real time whether the historical interaction information flow has affected the achievement status of the current intention, thereby determining whether a new intention needs to be added. For example, if the current intention has been achieved, or if the current intention has failed to be achieved, a new intention can be added. Specifically, suppose that during the current dialogue, the user suddenly asks a question that does not correspond to the current intention. Then, this situation can be judged as an intention failure. At this time, the user's new intention can be uncovered based on the fourth cue word, and subsequent dialogue can proceed.
[0081] In addition, it should be noted that during the question-and-answer interaction, in the first prompt word, the weight of the first intent and the response information corresponding to the first intent is higher than the weight of the context information.
[0082] It should be understood that as user input is continuously updated, the first prompt word also changes dynamically. However, the template of the first prompt word remains unchanged, always containing the intent, the corresponding response information, and context information. The statement that "in the first prompt word, the weight of the first intent and the corresponding response information is higher than the weight of the context information" can be understood as follows: in the first prompt word template, the weight of the intent and the corresponding response information is pre-set to be higher than the weight of the context information. This is because, based on the description in the above embodiments, due to latency, in some cases, the third question content and the third answer content need to serve as the context for the next question content input by the user after the first question content. However, this would prevent the third question content and the third answer content from being considered when generating the first answer content corresponding to the first question content through the first prompt word, potentially affecting the accuracy of the final first answer content. Based on this consideration, the embodiments of the present invention set the weight of the intent and the corresponding response information to be higher than the weight of the context information, thus reducing the impact of the third question content and the third answer content on the current generation of the first answer content.
[0083] Based on the above, the user question-and-answer interaction method provided by this invention can match the intent of the first question input by the user using a first major language model, and summarize and reflect on the question-and-answer content of a set round using a third major language model, ensuring that the first answer output by the second major language model is more accurate. Furthermore, by dynamically adjusting the priority of intents according to the progress of the dialogue, work efficiency can be improved. Simultaneously, if the current intent is relatively broad, it can be used to generate more refined sub-intents through a thought chain approach. In summary, this invention has high flexibility and intelligence, and can handle more complex and longer-term dialogue tasks.
[0084] To facilitate understanding, the following will be combined with... Figure 4 , Figure 5 and Figure 6 The application process of the user question-and-answer interaction method provided in the embodiments of the present invention is illustrated by the following example:
[0085] S1: Obtain the character description information corresponding to the AI assistant program, determine the role characteristic information corresponding to the AI assistant program based on the character description information, and add the role characteristic information to the first prompt word.
[0086] like Figure 4 As shown, the character description information (i.e., NPC character description information) corresponding to the AI assistant program is "Your name is Tasia, you are a senior in the Psionic Academy, you often hang out in the entertainment area, you are young and full of energy." By extracting features from this character description information, we can determine the character feature information corresponding to the AI assistant program: "Name: Tasia; Gender: Female; Style: Young and full of energy." After adding this character feature information to the first prompt, the content of the first prompt can be "You are an excellent actress, playing a character named Tasia. I hope you will use Tasia's style to communicate and always maintain consistency with Tasia's character setting."
[0087] S2: Extract knowledge from the preset background information and store the extracted background knowledge related to the target application scenario, as well as the user's corresponding role information, into a memory database. For example... Figure 4 As shown, the target application scenario can be a role-playing game scenario. The background information for this scenario is: "In 2070, the junior student enrolled in the academy in the New Noklin district. New Noklin is surrounded by other districts of the city and is the largest entertainment center in Harbor City. As a newly developed metropolis, Harbor City has a relatively short history, resulting in an extremely young population. Noklin originates from the old name of the local natives, meaning a place to enjoy the waves. After being requisitioned by the X6 Group, the entire island began to be forcibly planned, the land was excavated, and filled with asphalt and cement." The user's corresponding character information is: "Junior student, newly enrolled, reporting to the academy."
[0088] S3: The NPC receives the first question input by the user in the target application scenario: "Excuse me, do you have a boyfriend?"
[0089] S4: Based on the content of the first question and the historical interaction information flow preceding it (such as the 20 rounds of questions and answers generated within the 30 minutes prior to the first question, and any "flirting" actions performed by the NPC towards the user within the 30 minutes prior to the first question), the first intent matching the first question content is identified in the established intent library using the first major language model, in order to obtain the response information corresponding to the first intent. Specifically, the 20 rounds of questions and answers generated within the 30 minutes prior to the first question are as follows:
[0090] User: Senior, there's something I'm not sure if it's convenient to ask you?
[0091] NPC: Oh, go ahead and ask. As long as you don't ask if I'm single, I can answer anything else.
[0092] User: Haha, how did you know I wanted to ask that?
[0093] .....”
[0094] For an illustration of the application of the defined intent library, please refer to [link / reference]. Figure 5 ,exist Figure 5 The game contains four intentions: "Greet," "Discuss Music," "Introduce Flowers," and "Inquire about Personal Feelings." Each intention has a corresponding trigger condition, which may be verbal or physical. The "Greet" intention's response includes "Greet the player and introduce yourself in a cool and aloof manner," triggered by a physical action ("Meet"). The "Discuss Music" intention's response includes "Random action: 0.5 chance of introducing your favorite music, 0.5 chance of asking the player what they like," triggered by verbal language ("Inquire about interests"). The "Introduce Flowers" intention's response includes "Introduce what kind of flower this is," triggered by physical action ("Approach the flower"). The response information corresponding to the intention of "asking about personal feelings" includes "teasing the player when the favorability is 70 and inviting the player to go on a date at the bar next time; teasing the player when the favorability is 50 and asking if they want to go out with you; and saying that you are not interested in romance when the favorability is 30". The trigger condition is a verbal trigger ("asking about personal feelings").
[0095] After matching using the first language model, "asking about personal feelings" was determined to be the primary intent matching the content of the first question, and its corresponding response information was obtained. During this process, the prompt word template input from the first language model is as follows:
[0096] "You are now playing as an NPC. Here is a recent dialogue from you:"
[0097] [Time] {A}to{B}: "Conversation" [Emoji]
[0098] [Time] {A} [Behavior]
[0099] [Time] {C} [State]
[0100] Please determine whether B (the target of the dialogue) aligns with the following intentions:
[0101] Intent: ... (This refers to multiple intents from the set intent library);
[0102] If a matching intent name is found, return the name; otherwise, return nothing. Do not return any extra information.
[0103] It should be noted that in practical applications, the above "time", "A", "B", "C", "dialogue", "expression", "behavior" and "state" can be replaced according to the actual situation to generate new prompt words, and no restrictions are imposed here.
[0104] S5: Retrieve contextual information related to the content of the first question from the memory.
[0105] S6: Based on the target application scenario, context information, first intent, response information corresponding to the first intent, and historical interaction information flow, generate the first prompt word and input the first prompt word into the second language model to obtain the first answer content corresponding to the first question content.
[0106] For the specific structure of the first prompt word, please refer to [link / reference]. Figure 4 ,exist Figure 4In this context, the first prompt includes "Scene," "Context," "Current Goal," "Real-time Event Flow," and "Output Format." "Scene" includes relevant information corresponding to the target application scenario, specifically time, location, and characters. "Context" includes the role (i.e., the user's character information), memory (i.e., the historical interaction information flow), and thought (i.e., the thoughts generated based on the historical interaction information flow). "Current Goal" refers to the aforementioned first intention, used to guide the NPC to consistently engage in dialogue with the user around this first intention. "Real-time Event Flow" includes the response information corresponding to the first intention and the historical interaction information flow. "Output Format" is the output format of the first response content. For the first response content, combining the first intention "asking about personal feelings" in the example above, assuming a favorability rating of 70, teasing the player and inviting them to a bar date next time, the first response could be: "Look, we're at the zero-gravity bar right ahead. The lights there are beautiful, like a dream. If you dare, how about we go get it together next time?"
[0107] S7: Based on the target application scenario, contextual information, primary intent, historical interaction information flow, and the first analysis result corresponding to the historical question content contained in the historical interaction information flow, generate a third prompt word and input the third prompt word into the third language model to obtain the second analysis result corresponding to the first question content. The second analysis result contains the third question content proposed based on the third prompt word (corresponding to...). Figure 4 "Deep thinking" in the text, and Figure 6 The "asking a question" in the text and the third answer content corresponding to the third question content retrieved from the memory (corresponding to the third question content in the text) Figure 6 (The "Return Results" in the document).
[0108] The template for the third prompt word is as follows:
[0109] Target application scenario:
[0110] ...(This section includes nouns related to the current application scenario, the timeline of the story within that scenario, and the characters within the scenario.)
[0111] Relevant background:
[0112] ...(This section contains contextual information from the historical interaction flow)
[0113] Character Name: "Character Introduction"
[0114] Context: "retrieval content from the memory"
[0115] think:
[0116] Q: ... (This is the second question regarding historical issues)
[0117] A: ... (This is the second answer to the second question retrieved from the memory.)
[0118] What happened recently is:
[0119] ...(This section contains the historical interaction information stream, as well as the content of the first question currently entered by the user)
[0120] Based on the current situation and objectives, what questions do you need to know before taking the next step? ...
[0122] Q1...
[0123] Q2..." where Q1 and Q2 are the third answer in this application.
[0124] In practical applications, the content in the template for the third prompt word mentioned above can be replaced according to the actual situation, and no restrictions are imposed here.
[0125] S8: Retrieve the third answer content corresponding to the third question content from the memory, and add the third question content and the third answer content to the memory. This will serve as contextual information related to the fourth question content (i.e., the question content entered by the user after the first question content) for subsequent dialogue. The specific execution process of S3-S8 can be found in [link to S8]. Figure 6 .
[0126] exist Figure 6 The system comprises three major language models and a memory bank: the main dialogue language model (the second major language model mentioned above), the subconscious language model (the first major language model mentioned above), and the deep conscious language model (the third major language model mentioned above). In practical applications, each application scenario contains multiple intents, each intent contains multiple rounds of dialogue, and each round of dialogue consists of multiple dialogue sessions. Each round of dialogue begins with the user initiating "dialogue input" and ends with the "dialogue output" output by the main dialogue language model. In specific implementation, each dialogue session between the user and the AI assistant program can include retrieval operations from the memory bank, intent matching operations through the subconscious language model, and third question generation operations based on the deep conscious language model. These three operations can be executed concurrently in each dialogue session, improving the efficiency of user question-and-answer interaction. After each dialogue session, the content of the third question and the third answer can be used as contextual information related to the next user input question for subsequent dialogue.
[0127] Based on this approach, after multiple rounds of dialogue, the question-and-answer content of these rounds is summarized using a deep-conscious large-language model, and the memory bank is updated based on the summary results. Furthermore, after each round of dialogue, the memory bank is also updated based on that dialogue, ensuring that more accurate answers can be continuously provided to user-inputted questions in the future.
[0128] The following will describe in detail one or more embodiments of the user question-and-answer interaction device of the present invention. Those skilled in the art will understand that these devices can all be configured using commercially available hardware components through the steps taught in this solution.
[0129] Figure 7 This is a schematic diagram of the structure of a user question-and-answer interaction device provided in an embodiment of the present invention, as shown below. Figure 7 As shown, the device is used in an artificial intelligence assistant program and includes: a receiving module 11, a retrieval module 12, a recognition module 13, a generation module 14, and an input module 15.
[0130] The receiving module 11 is used to receive the content of the first question input by the user in the target application scenario;
[0131] The retrieval module 12 is used to retrieve contextual information related to the content of the first question from the memory.
[0132] The identification module 13 is used to identify a first intent that matches the first question content in a set intent library through a first language model, based on the first question content and the historical interaction information stream generated before the first question content, so as to obtain the response information corresponding to the first intent. The historical interaction information stream includes at least one round of historical question content and historical answer content generated within a set historical time period, as well as the execution action information of the user and the artificial intelligence assistant program within the set historical time period.
[0133] The generation module 14 is used to generate a first prompt word based on the target application scenario, the context information, the first intent, the response information corresponding to the first intent, and the historical interaction information stream.
[0134] Input module 15 is used to input the first prompt word into the second language model to obtain the first answer content corresponding to the first question content.
[0135] Optionally, the device further includes:
[0136] The acquisition module is used to acquire the persona description information corresponding to the AI assistant program.
[0137] The determination module is used to determine the character feature information corresponding to the artificial intelligence assistant program based on the character description information.
[0138] An add module is used to add the character feature information to the first prompt word.
[0139] Optionally, the process of identifying the first intent includes: generating a second prompt word based on the first question content, the historical interaction information stream, and multiple intents in the intent library, each intent including an intent name and response information; inputting the second prompt word into the first large language model, so that the first large language model identifies a first intent matching the first question content in the intent library. The process of generating the second prompt word includes: determining a second intent matching the historical question content contained in the historical interaction information stream; determining the intent search range of the first question content based on the intent tree corresponding to the intent library and the second intent, wherein the intent tree describes the flow of multiple intents in the intent library, and the intent search range corresponds to the branch where the second intent is located; and generating the second prompt word based on the first question content, the historical interaction information stream, and the intent search range of the first question content.
[0140] Optionally, in the first prompt word, the weight of the first intent and the response information corresponding to the first intent is higher than the weight of the context information.
[0141] Optionally, the device further includes:
[0142] The prompt word generation module is used to generate a third prompt word based on the target application scenario, the context information, the first intent, the historical interaction information stream, and the first analysis result corresponding to the historical question content contained in the historical interaction information stream. The first analysis result includes a second question content proposed in response to the historical question content and a second answer content corresponding to the second question content retrieved from the memory bank.
[0143] The analysis result determination module is used to input the third prompt word into the third language model to obtain the second analysis result corresponding to the first question content. The second analysis result includes the third question content proposed based on the third prompt word and the third answer content corresponding to the third question content retrieved from the memory bank.
[0144] The content adding module is used to add the third question content and the third answer content to the memory bank, so as to serve as context information related to the fourth question content when the user inputs the fourth question content; or, to add the third question content and the third answer content to the context related to the first question content, wherein the fourth question content is the next question content input by the user after the first question content.
[0145] Optionally, the device further includes a summary module, used to summarize the question and answer content of the set round of question and answer interaction through the third language model after the set round of question and answer interaction is executed, and add the summary result to the memory bank.
[0146] Figure 7 The device shown can perform the steps provided in the foregoing embodiments. For detailed execution process and technical effects, please refer to the description in the foregoing embodiments, which will not be repeated here.
[0147] In one possible design, the above Figure 7 The structure of the user question-and-answer interaction device shown can be implemented as an electronic device. For example... Figure 8 As shown, the electronic device may include: a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable code, which, when executed by the processor 21, enables the processor 21 to at least implement the user question-and-answer interaction method provided in the foregoing embodiments.
[0148] In addition, embodiments of the present invention provide a non-transitory machine-readable storage medium storing executable code, which, when executed by a processor of an electronic device, enables the processor to at least implement the user question-and-answer interaction method provided in the foregoing embodiments.
[0149] In addition, embodiments of the present invention provide a computer program product, the computer program product comprising: a computer program, which, when executed by a processor of an electronic device, enables the processor to at least implement the user question-and-answer interaction method provided in the foregoing embodiments.
[0150] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0151] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of a necessary general-purpose hardware platform, or by a combination of hardware and application programs. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A user question-and-answer interaction method, characterized in that, Applications in AI assistant programs include: Receive the first question input by the user in the target application scenario; Retrieve contextual information related to the content of the first question from the memory bank; Based on the content of the first question and the historical interaction information flow generated before the content of the first question, the first intent matching the content of the first question is identified in the set intent library through the first language model, so as to obtain the response information corresponding to the first intent. The historical interaction information flow includes at least one round of historical question content and historical answer content generated within a set historical time period, as well as the execution action information of the user and the artificial intelligence assistant program within the set historical time period. A first prompt word is generated based on the target application scenario, the context information, the first intent, the response information corresponding to the first intent, and the historical interaction information stream. The first prompt word is input into the second language model to obtain the first answer content corresponding to the first question content.
2. The method according to claim 1, characterized in that, The method further includes: Obtain the persona description information corresponding to the AI assistant program; The character feature information corresponding to the AI assistant program is determined based on the character description information; Add the character feature information to the first prompt word.
3. The method according to claim 1, characterized in that, The process of identifying the first intent includes: Based on the content of the first question, the historical interaction information stream, and multiple intents in the intent library, a second prompt word is generated, wherein each intent includes an intent name and response information; The second prompt word is input into the first large language model so that the first large language model can identify a first intent that matches the content of the first question in the intent library.
4. The method according to claim 3, characterized in that, The step of generating a second prompt word based on the content of the first question, the historical interaction information stream, and multiple intents contained in the intent library includes: Determine the second intent that matches the historical question content contained in the historical interaction information stream; Based on the intent tree corresponding to the intent library and the second intent, the intent search range of the first question content is determined, wherein the intent tree is used to describe the flow of multiple intents in the intent library, and the intent search range corresponds to the branch where the second intent is located; A second prompt word is generated based on the content of the first question, the historical interaction information flow, and the intent search range of the first question content.
5. The method according to claim 1, characterized in that, In the first prompt word, the weight of the first intent and the response information corresponding to the first intent is higher than the weight of the context information.
6. The method according to any one of claims 1-5, characterized in that, The method further includes: Based on the target application scenario, the context information, the first intent, the historical interaction information stream, and the first analysis result corresponding to the historical question content contained in the historical interaction information stream, a third prompt word is generated, wherein the first analysis result includes the second question content raised in response to the historical question content and the second answer content corresponding to the second question content retrieved from the memory bank; The third prompt word is input into the third language model to obtain the second analysis result corresponding to the first question content. The second analysis result includes the third question content proposed based on the third prompt word and the third answer content corresponding to the third question content retrieved from the memory bank. The third question content and the third answer content are added to the memory bank to serve as context information related to the fourth question content when the user inputs the fourth question content; or, the third question content and the third answer content are added to the context related to the first question content, wherein the fourth question content is the next question content input by the user after the first question content.
7. The method according to claim 6, characterized in that, The method further includes: After executing a set round of question-and-answer interaction, the question-and-answer content of the set round is summarized by the third language model, and the summary result is added to the memory bank.
8. An electronic device, characterized in that, include: The system includes a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor performs the user question-and-answer interaction method as described in any one of claims 1-7.
9. A non-transitory machine-readable storage medium, characterized in that, The non-transitory machine-readable storage medium stores executable code that, when executed by a processor of an electronic device, causes the processor to perform the user question-and-answer interaction method as described in any one of claims 1-7.
10. A computer program product, characterized in that, include: A computer program, when executed by a processor of an electronic device, causes the processor to perform the user question-and-answer interaction method as described in any one of claims 1-7.