A question-and-answer method, system, device, equipment and storage medium
By configuring structured prompt information and dynamic filtering dialogue examples for the target model, the problem that the general model cannot meet the personalized needs of the enterprise is solved, and the accuracy and efficiency of question-and-answer are improved.
Patent Information
- Application Number
- CN202411487741.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2044-10-23
AI Technical Summary
The general big model cannot meet the personalized needs of the enterprise, resulting in poor Q&A results.
Configure structured prompt information for multiple dialogue examples for the target model. Each dialogue example is associated with dialogue scenarios and role settings. By dynamically filtering the adapted dialogue examples, the target model is called for question-and-answer.
It improves the accuracy and efficiency of the question-and-answer model, reduces computing resources and time consumption, and meets the personalized needs of the enterprise.
Smart Images

Figure CN119441429B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular, to a question-and-answer method, system, device, equipment, and storage medium. Background Art
[0002] The Retrieval-Augmented Generation (RAG) model is a natural language processing model that combines information retrieval and text generation technologies. It retrieves the most relevant information to the input question from a large amount of text data and uses the retrieved information to generate responses or answers. Currently, independently developing a RAG model requires a large amount of time and cost to train the model, with a long R & D cycle and high maintenance costs. Therefore, enterprises usually choose to call the pre-trained general large models provided by large model service providers.
[0003] However, general large models are designed for a wide range of users and often cannot directly meet the personalized needs of enterprises, unable to provide accurate answers for the customers of enterprises, resulting in poor question-and-answer effects of general large models. Summary of the Invention
[0004] Multiple aspects of this application provide a question-and-answer method, system, device, equipment, and storage medium to improve the question-and-answer effect of large models when calling general large models.
[0005] In a first aspect, an embodiment of this application provides a question-and-answer method, including:
[0006] Obtain a target question input by a target user and structured prompt information pre-configured for a target large model. The structured prompt information contains multiple dialogue examples, each dialogue example is associated with a dialogue scenario and a role setting, each dialogue scenario is associated with a question-and-answer generation logic and at least one scenario description word, the role setting associated with the dialogue example is used to represent the role played by the target large model in the dialogue scenario, and the question-and-answer generation logic is used to describe the execution logic for the target large model to generate a reply content for the target question in the dialogue scenario;
[0007] Extract target keywords related to the dialogue scenario from the target question, and based on the target keywords, the multiple dialogue scenarios included in the structured prompt information, and the scenario description words respectively associated with each dialogue scenario, determine a target dialogue scenario adapted to the target question;
[0008] Based on the target dialogue scenario, screen the multiple dialogue examples in the structured prompt information to obtain target dialogue examples adapted to the target dialogue scenario;
[0009] Use an intent recognition model to perform intent recognition on the target question to obtain the target inquiry intent corresponding to the target question;
[0010] When the target inquiry intent is adapted to the target large model, add the target inquiry intent and the target dialogue example to the model call request;
[0011] Call the target large model according to the model call request to execute the question and answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target inquiry intent to generate the reply content for the target question;
[0012] Send the reply content output by the target large model to the target user to answer the target question.
[0013] In a second aspect, an embodiment of the present application further provides a question and answer system, including a client, a server, and a target large model;
[0014] The client is used to obtain the target question input by the target user and provide the target question to the server;
[0015] The server is used to obtain the target question and the structured prompt information pre-configured for the target large model; extract the target keywords related to the dialogue scenario from the target question, and based on the target keywords and the multiple dialogue scenarios included in the structured prompt information and the scenario description words associated with each dialogue scenario, determine the target dialogue scenario adapted to the target question; based on the target dialogue scenario, screen the multiple dialogue examples in the structured prompt information to obtain the target dialogue example adapted to the target dialogue scenario; use an intent recognition model to perform intent recognition on the target question to obtain the target inquiry intent corresponding to the target question; when the target inquiry intent is adapted to the target large model, add the target inquiry intent and the target dialogue example to the model call request; call the target large model according to the model call request;
[0016] Among them, the structured prompt information includes multiple dialogue examples, each dialogue example is associated with a dialogue scenario and a role setting, each dialogue scenario is associated with a question and answer generation logic and at least one scenario description word, the role setting associated with the dialogue example is used to represent the role played by the target large model in the dialogue scenario, and the question and answer generation logic is used to describe the execution logic for the target large model to generate the reply content for the target question in the dialogue scenario;
[0017] The target large model is used to execute the question and answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target inquiry intention to generate the response content of the target question; and provide the response content to the server;
[0018] The server is further used to send the response content output by the target large model to the client;
[0019] The client is further used to display the response content to the target user to answer the target question.
[0020] In a third aspect, an embodiment of the present application further provides a question and answer device, including a data interaction module, an example screening module, an intention recognition module, and a model invocation module;
[0021] The data interaction module is used to obtain the target question input by the target user;
[0022] The example screening module is used to extract target keywords related to the dialogue scenario from the target question, and determine the target dialogue scenario adapted to the target question based on the target keywords and multiple dialogue scenarios included in the structured prompt information pre-configured for the target large model and the scenario description words associated with each dialogue scenario; based on the target dialogue scenario, screen multiple dialogue examples in the structured prompt information to obtain target dialogue examples adapted to the target dialogue scenario;
[0023] Among them, the structured prompt information includes multiple dialogue examples, each dialogue example is associated with a dialogue scenario and a role setting, each dialogue scenario is associated with a question and answer generation logic and at least one scenario description word, the role setting associated with the dialogue example is used to represent the role played by the target large model in the dialogue scenario, and the question and answer generation logic is used to describe the execution logic of the target large model for generating the response content to the target question in the dialogue scenario;
[0024] The intention recognition module uses an intention recognition model to recognize the intention of the target question to obtain the target inquiry intention corresponding to the target question;
[0025] The model invocation module is used to add the target inquiry intention and the target dialogue example to the model invocation request when the target inquiry intention is adapted to the target large model; call the target large model according to the model invocation request to execute the question and answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target inquiry intention to generate the response content of the target question;
[0026] The data interaction module is further configured to send the reply content output by the target large model to the target user to answer the target question.
[0027] Fourthly, an embodiment of the present application further provides a computing device, including: a memory, a processor, and a communication component;
[0028] The memory is used to store one or more computer instructions;
[0029] The processor is coupled to the memory and the communication component, and is configured to execute the one or more computer instructions to execute the foregoing question-and-answer method.
[0030] Fifthly, an embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by one or more processors, cause the one or more processors to execute the foregoing question-and-answer method.
[0031] Sixthly, an embodiment of the present application further provides a computer program product, including a computer program, wherein, when the computer program is executed by a processor, the processor is caused to execute the foregoing question-and-answer method.
[0032] In the embodiment of the present application, structured prompt information including multiple dialogue examples is configured for the target large model. Each dialogue example is associated with a dialogue scenario and a role setting. Different role settings are used to represent different roles played by the target large model in the same / different dialogue scenarios. Based on this structured prompt information, personalized fine-tuning of the target large model can be realized, so that the fine-tuned target large model can meet the personalized needs of the caller itself.
[0033] On this basis, after obtaining the target question input by the target user, target keywords related to the dialogue scenario can be extracted from the target question. Based on the target keywords, the multiple dialogue scenarios included in the structured prompt information, and the scenario description words respectively associated with each dialogue scenario, a target dialogue scenario adapted to the target question is determined. The target dialogue examples in the structured prompt information that are adapted to the target dialogue scenario are screened out, so as to use the model call request carrying the target dialogue examples to call the target large model to reply to the target question. By dynamically screening dialogue examples for the target question, the target large model only needs to learn the dialogue examples related to the target question in each question-and-answer process, which not only helps the target large model accurately understand the current dialogue scenario, but also reduces the Tokens consumed by the target large model, saves more computing resources and time, can quickly generate a reply content for the target question based on the knowledge information related to the target dialogue scenario, improves the accuracy and efficiency of the generated reply content, and further improves the question-and-answer effect of the large model. Description of the Drawings
[0034] The accompanying drawings described herein are used to provide a further understanding of the present application and form a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0035] Figure 1 It is a schematic structural diagram of a question-answering system provided for an exemplary embodiment of the present application;
[0036] Figure 2 It is a schematic structural diagram of another question-answering system provided for another exemplary embodiment of the present application;
[0037] Figure 3 It is a schematic flowchart of a question-answering method provided for another exemplary embodiment of the present application;
[0038] Figure 4 It is a schematic structural diagram of a question-answering device provided for another exemplary embodiment of the present application;
[0039] Figure 5 It is a schematic structural diagram of a computing device provided for another exemplary embodiment of the present application. Detailed Embodiments
[0040] To make the objectives, technical solutions, and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0041] Before starting to elaborate on the technical solutions provided by the embodiments of the present application, several technical concepts involved in the present application are briefly explained as follows.
[0042] The Retrieval-Augmented Generation (RAG) technology can be understood as a system that combines retrieval and generation technologies to improve the prediction quality and accuracy of natural language processing tasks. The large model that supports retrieval-augmented generation is called a retrieval-augmented generation large model, that is, a RAG large model. The working process of the RAG large model mainly includes: receiving the question input by the user, retrieving information related to the question input by the user from a pre-constructed large-scale knowledge base; fusing the retrieved information with the question input by the user, and using the fused information to generate a reply content for the question input by the user.
[0043] Large Language Models (LLMs) are complex neural networks trained on vast amounts of data, capable of capturing and simulating the complexity and diversity of language. They use deep learning techniques, particularly neural networks, to understand and generate natural language. In large language models, "Token" and "Embeddings" are two core concepts. A Token is a basic unit in natural language processing, typically a word, character, or sub-word (wordpiece). Embedding is a technique that converts Tokens into fixed-length vector representations, which capture the semantic and syntactic information of Tokens, enabling the model to understand and process language.
[0044] During the research process, the inventors found that due to the extremely complex and time-consuming training process of large models that support retrieval-augmented generation and the high development costs, large models that have been trained and provided by large model service providers are usually directly invoked. However, the large models provided by the providers are generally general large models and cannot directly meet the personalized needs of enterprises, which may lead to certain deviations in the answers provided to the enterprises' customers, thus resulting in poor question-and-answer effects of the general large models.
[0045] To address this issue, the embodiments of this application provide a solution. The basic idea is to configure structured prompt information containing multiple dialogue examples for the target large model. Each dialogue example is associated with a dialogue scenario and a role setting. Different role settings are used to represent different roles played by the target large model in the same / different dialogue scenarios. Based on this structured prompt information, personalized fine-tuning of the target large model can be achieved, enabling the fine-tuned target large model to meet the personalized needs of the caller itself.
[0046] On this basis, based on the target keywords in the target question and the dialogue scenarios included in the structured prompt information and the scenario description words associated with each dialogue scenario, the target dialogue scenario adapted to the target question can be determined. Determine the target dialogue example adapted to the target dialogue scenario from the structured prompt information, so as to use the model call request carrying the target dialogue example to call the target large model to reply to the target question. Before calling the target large model, the dialogue examples in the structured prompt information can be dynamically filtered according to the target dialogue scenario corresponding to the target question, so that the target large model only needs to learn the dialogue examples related to the target question in each question-and-answer process. This helps the target large model accurately understand the current dialogue scenario and generate a reply content for the target question based on the knowledge information related to the target dialogue scenario, improving the accuracy of the generated reply content. Moreover, filtering the dialogue examples passed to the target large model reduces the Tokens consumed by the target large model, saves more computing resources and time, improves the processing speed of the large model, and thus can improve the question-and-answer effect of the large model.
[0047] The following will combine with the attached drawings to elaborate in detail on the technical solutions provided by each embodiment of the present application.
[0048] Figure 1 It is a schematic structural diagram of a question-and-answer system provided by an exemplary embodiment of the present application. As Figure 1 shown, the system includes: a client 101, a server 102, and a target large model 103. The server 102 is communicatively connected to the client 101 and the target large model 103 respectively, and the communication connection can be a wired or wireless network connection. For example, the client 101 and the server 102 can be within the same local area network or belong to different local area networks respectively, and a communication connection can be established between the server 102 and the target large model 103 through a network protocol. Of course, these are only exemplary and are not limited thereto.
[0049] Among them, the client 101 can be an application program, a web application, a lightweight application, or a cloud application, etc. The server 102 can include servers providing various services. Both the client 101 and the server 102 belong to the model calling party side. The target large model 103 can be a pre-trained large model provided by a large model service provider, and it belongs to the model providing party side. The provider of the large model service (i.e., the model providing party) can provide an Application Programming Interface (API) externally. The model calling party can configure the call logic for the API in the server 102 to realize the call of the target large model 103 by calling the API.
[0050] In practical applications, there can be any number of clients, servers, and target large models in the question-and-answer system. Figure 1Only one client, one server, and one target large model are exemplarily shown herein, but this should not result in a loss of the protection scope of this application.
[0051] The question-and-answer system provided in this embodiment can be applied to various scenarios that require using a large model to perform question-and-answer tasks. For example, scenarios such as using a large model for question consultation and using a large model for article creation. This embodiment does not limit the application scenarios.
[0052] For the server 102, after obtaining the target question input by the target user provided by the client 101, it can extract the target keywords related to the conversation scenario from the target question. The conversation scenario can be used to describe the specific environment and background during the conversation. This includes not only the physical environment (such as location, time, scene, etc.), but also more complex social environments, such as the identities of the interlocutors (such as students, recruiters, job seekers, etc.), relationships (such as friends, colleagues, superiors and subordinates, strangers, etc.), purposes (such as obtaining information, solving problems, conducting social interactions, etc.), emotional states (such as happy, sad, angry, etc.), and the formality of the conversation. The conversation scenario can include, but is not limited to, scenarios such as a home buyer consulting a real estate agent in Beijing about simple home purchases and a job seeker asking a career planner to formulate a clearer career plan for them. The client 101 can display a question-and-answer interface to the target user for the target user to input the target question to be replied on the question-and-answer interface. The target question can be a text-based question or an audio-based question, and the target question can also include pictures, files, links, etc. This embodiment does not limit this.
[0053] In this embodiment, multiple implementation methods can be used to extract the target keywords related to the conversation scenario from the target question.
[0054] In an alternative implementation method, the target question can be segmented to obtain multiple phrases of the target question. Determine the part-of-speech corresponding to each phrase, and use the phrases corresponding to the specified part-of-speech as the target keywords related to the conversation scenario extracted from the target question. Here, the part-of-speech refers to the grammatical role or functional category played by a word in a sentence or text, and is used to describe the position of the word in the sentence structure and its relationship with other words. The part-of-speech includes, but is not limited to, nouns, pronouns, adjectives, adverbs, conjunctions, and verbs, etc. The specified part-of-speech can be a noun, a verb, etc. The segmentation methods used for segmentation include, but are not limited to, segmenting according to morphological rules, using the IK Analyzer for segmentation, using neural networks for segmentation, etc.
[0055] In another alternative implementation, a dataset can be constructed using questions, keywords, and the corresponding dialogue scenarios for the questions, so as to pre-train the keyword extraction model using the constructed dataset. Based on this, the target question can be input into the keyword extraction model, and the output of the keyword extraction model can be used as the target keyword related to the dialogue scenario extracted from the target question.
[0056] Of course, these implementation methods are only exemplary, and other implementation methods can also be used to extract the target keyword related to the dialogue scenario from the target question, and are not limited to the above two implementation methods.
[0057] After obtaining the target question, the server 102 can continue to obtain the structured prompt information pre-configured for the target large model. The structured prompt information is the input text that clearly contains instructions and context information, and is designed to guide the large model to generate text that better meets the user's expectations. The structured prompt information can be stored in the database within the server 102, or can be stored in other databases or cloud databases outside the server 102. The structured prompt information contains multiple dialogue examples, each dialogue example is associated with a dialogue scenario and a role setting, and the role setting associated with the dialogue example is used to represent the role played by the target large model in the dialogue scenario; each dialogue scenario is associated with a question-and-answer generation logic and at least one scenario description word, and the question-and-answer generation logic is used to describe the execution logic of the target large model for generating response content to the target question in the dialogue scenario.
[0058] On this basis, based on the target keyword, the multiple dialogue scenarios included in the structured prompt information, and the scenario description words respectively associated with each dialogue scenario, the target dialogue scenario adapted to the target question can be determined.
[0059] Optionally, the matching degree between the target keyword and any scenario description word in the structured prompt information can be calculated. If the matching degree between any scenario description word and the target keyword is higher than the preset threshold, the dialogue scenario associated with the scenario description word is determined as the target dialogue scenario adapted to the target question. Of course, it is also possible to search for the target scenario description word that exactly matches the target keyword from the multiple scenario description words included in the structured prompt information, and determine the dialogue scenario associated with the target scenario description word as the target dialogue scenario adapted to the target question. This embodiment does not make a limitation on this.
[0060] For the server 102, after determining the target dialogue scenario adapted to the target question, the multiple dialogue examples in the structured prompt information can be filtered based on the target dialogue scenario to obtain the target dialogue example adapted to the target dialogue scenario. The target dialogue example is associated with a role setting, and this role setting is the role setting that the target large model needs to refer to when answering the target question.
[0061] It should be noted that each dialogue example contains a question initiated by the user and a response content that can be referred to by the target large model. The questions and response contents in the dialogue examples are associated with role settings. However, the role setting associated with the question in any dialogue example is "user", such as male user, female user, novice user, expert user, buyer user, seller user, etc. Therefore, the role setting associated with the response content is used as the role setting associated with the dialogue example, so that the role setting associated with the target dialogue example can be directly used to represent the role played by the target large model in the target dialogue scenario. The role settings associated with the dialogue examples include but are not limited to: male, female, novice, expert, buyer, seller, etc.
[0062] Based on this, an intent recognition model can be used to recognize the intent of the target question to obtain the target query intent corresponding to the target question. Intent recognition aims to determine the main purpose or intent expressed in the target question input by the target user. The intent recognition model is pre-trained based on text data with intent labels. The intent recognition models adopted in this embodiment include but are not limited to logistic regression models, convolutional neural network models, recurrent neural network models, etc.
[0063] In the case where the target query intent is adapted to the target large model, the target query intent and the target dialogue example can be added to the model call request to call the target large model according to the model call request. Of course, other parameters can also be included in the model call request, such as the model identifier of the target large model, the address of the target large model, the output format, etc. The situation where the target query intent is adapted to the target large model refers to the situation where the server 102 determines to use the target large model to reply to the target question. Determining that the target query intent is adapted to the target large model includes but is not limited to the target user specifying to use the target large model to reply to the target question, failing to match a reply content adapted to the target query intent from the local knowledge base, and the reply content matched from the local knowledge base being unable to answer the target question, etc. The technical details related to the local knowledge base will be introduced in detail below and will not be elaborated here.
[0064] For the target large model 103, after receiving the model call request, it can respond to the call of the server 102 and execute the question and answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target query intent to generate the reply content for the target question. The output reply content is provided to the server 102 so that the server 102 can send the reply content output by the target large model to the client 101. As recorded above, the client 101 can display a question and answer interface to the target user, and the client 101 can display the reply content to the target user through the question and answer interface to answer the target question input by the target user.
[0065] Optionally, before sending the reply content to the client 101, the server 102 can perform a compliance check on the reply content. If it detects that the reply content contains a violation word, it can perform an adjustment operation on the violation word in the reply content and display the reply content after the adjustment operation to the target user. The violation words can include, but are not limited to, illegal words, words that violate public order and good customs, negative information about the enterprise, etc.
[0066] When performing a compliance check on the reply content, the information in the reply content can be partitioned according to the number of characters first, and then, according to the preset detection rules, the compliance of the content in each partition can be checked to determine whether the content in the partition contains a violation word that does not conform to the detection rules. If it contains a violation word, an adjustment operation such as modification, replacement, or deletion can be performed on the violation word to achieve compliance correction of the reply content. Performing a compliance check on the reply content before presenting it to the target user ensures the compliance of the reply content, can avoid the appearance of bad information, and can also delete the negative information of the model caller, thus maximizing the friendliness of the reply content to the model caller.
[0067] In summary, in this embodiment, the target keyword related to the conversation scenario can be extracted from the target question input by the target user. Based on the target keyword and the multiple conversation scenarios included in the structured prompt information configured for the target large model and the scenario description words associated with each conversation scenario, the target conversation scenario adapted to the target question can be determined. The target conversation examples in the structured prompt information that are adapted to the target conversation scenario are screened out, and the target large model can be called with the model call request carrying the target conversation examples to reply to the target question. By dynamically screening conversation examples for the target question, the target large model only needs to learn the conversation examples related to the target question in each question-and-answer process, which not only helps the target large model accurately understand the current conversation scenario, but also reduces the Tokens consumed by the target large model, saves more computing resources and time, can quickly generate a reply content for the target question based on the knowledge information related to the target conversation scenario, improves the accuracy and efficiency of the generated reply content, and further improves the question-and-answer effect of the large model.
[0068] In the above or the following embodiments, to further improve the accuracy of the inquiry intention corresponding to the target question understood by the target large model, the target inquiry intention carried in the model call request can be rewritten so that the rewritten target inquiry intention can more accurately and comprehensively represent the purpose of the target user.
[0069] Optionally, an intention recognition model can be used to recognize the intention of the target question to obtain the initial query intention. Based on the preset mapping relationship between intentions and slots, at least one slot corresponding to the initial query intention is obtained. A slot refers to an information unit related to a specific intention, and can be used to represent the specific information required to achieve the user's intention, such as time, location, person, item, etc. For any slot, if the target question does not contain the slot information corresponding to the slot, the slot information corresponding to the slot is obtained from the basic information of the target user and the context information of the target question. Based on the obtained slot information, the target question is rewritten, and the intention recognition model is used to recognize the intention of the rewritten target question to obtain the target query intention.
[0070] In practical applications, if the target question is "What are the second-hand houses listed for sale today", recognizing the intention of the target question can determine that the initial query intention of the target question is "second-hand houses listed for sale today". Based on the preset mapping relationship between intentions and slots, the slots corresponding to this target intention can be obtained, including: location, date, house type, and house layout. The target question contains the house type as "second-hand house". From the basic information of the user, it can be determined that the location of the target user is Beijing. According to the context information of the target question, the consultation date can be determined as 2024-06-01. Neither the basic information of the user nor the context information of the target user contains the house layout. Therefore, when rewriting the target question, this slot can be ignored, and the target question is rewritten as "What are the second-hand houses listed for sale in Beijing on 2024-06-01". The intention recognition model is used to recognize the intention of the rewritten target question to obtain the target query intention as "second-hand houses listed for sale in Beijing on 2024-06-01". By supplementing the slot information in the target question, optimization can be carried out in terms of person setting, information timeliness, local positioning, etc., so that the target question contains more information related to the user's query intention, and then the target large model can better understand the specific needs of the target user and provide an accurate response accordingly.
[0071] In addition, since in this embodiment, the large model provided by the model provider is called for question answering, for the large model, each question provided by the target user is independent, and it is impossible to understand the question in combination with the context information of the question, which easily leads to an understanding deviation of the question provided by the target user by the large model.
[0072] To improve this problem, before calling the target large model according to the model call request, the relevance between the target question and the historical questions input by the target user can be judged. Based on the relevance, from the historical questions input by the target user, select the target historical questions with a relevance higher than the preset relevance value, and add the target historical questions and the corresponding historical reply content to the model call request for the target large model to use the target historical questions and historical reply content to assist in understanding the target inquiry intention. By carrying the historical Q&A records related to the target question in the model call request, it can help the target large model accurately understand the inquiry intention of the target question in combination with the context information, so as to give a more accurate reply.
[0073] In summary, in this embodiment, by rewriting the target question, the target inquiry intention corresponding to the target question is enriched and optimized, so that the large model can understand the target inquiry intention more comprehensively and accurately, thereby improving the accuracy and usability of the retrieval. Moreover, passing the historical questions related to the target question to the large model together can assist the large model in understanding the inquiry intention of the target user, and can also improve the coherence and relevance of the large model's answers, making the conversation more natural and fluent.
[0074] In the above or following embodiments, the number of target large models can be multiple, and each target large model is associated with different weight values in different dialogue scenarios. The level of the weight value can be used to reflect the Q&A effect of the target large model in the dialogue scenario. The higher the weight value, the better the Q&A effect of the target large model. In any dialogue scenario, the target large model used to interact with the target user can be selected based on the level of the weight value.
[0075] Figure 2 It is a schematic structural diagram of another Q&A system provided in another exemplary embodiment of the present application. As Figure 2 shown, this Q&A system includes multiple target large models. After determining the target dialogue scenario adapted to the target question, according to the weight value associated with each target large model in the target dialogue scenario, select the target large model with the largest current weight value from the multiple target large models as the primary target large model. Call the primary target large model according to the model call request to execute the Q&A generation logic in the target dialogue scenario according to the role setting and target inquiry intention associated with the target dialogue example to generate the reply content of the target question.
[0076] By associating different weight values with each target large model in different dialogue scenarios, the question-and-answer capabilities of the target large model in different dialogue scenarios can be clearly presented, facilitating the server to screen out the target large model available in the target dialogue scenario according to the current target dialogue scenario of the question-and-answer. Then, according to the weight values of each target large model in the target dialogue scenario, the target large model with the largest weight value is selected from the target large models available in the target dialogue scenario as the primary target large model. In this way, screening multiple target large models from both the dialogue scenario and the question-and-answer effect can ensure that the selected primary target large model has a high enough adaptability to the target question, improving the question-and-answer accuracy of the large model.
[0077] Optionally, during the process of using the primary target large model for question-and-answer, a detection signal can be sent to the primary target large model at regular intervals, and the response signal returned by the primary target large model for the detection signal can be received. Calculate the waiting duration from when the detection signal is sent until the response signal is received. If the waiting duration is greater than the preset duration, then from other target large models that have not processed the target question, select the target large model with the highest weight value in the target dialogue scenario as the backup target large model, and synchronize the historical question-and-answer records generated by the primary target large model for the target user to the backup target large model, so as to use the backup target large model to replace the primary target large model to reply to the target user.
[0078] By introducing this regular detection mechanism, in the case where the primary target large model is unavailable, it can be promptly switched to the backup target large model, ensuring the high availability of the question-and-answer service, thereby improving the user experience.
[0079] In the case of using the backup target large model to replace the primary target large model to reply to the target user, the weight value corresponding to the primary target large model in the target dialogue scenario and the weight value corresponding to the backup target large model in the target dialogue scenario can be obtained. Adjust the weight value corresponding to the primary target large model in the target dialogue scenario and / or the weight value corresponding to the backup target large model in the target dialogue scenario, so that the weight value corresponding to the backup target large model in the target dialogue scenario is higher than the weight value corresponding to the primary target large model in the target dialogue scenario, in order to preferentially use the backup target large model in the target dialogue scenario.
[0080] Among them, the weight values corresponding to the primary target large model and the backup large model can be exchanged; or, the weight value of the primary target large model can be reduced according to a preset ratio, and the weight value of the backup target large model can be increased according to a preset ratio, as long as the weight value corresponding to the backup target large model in the target dialogue scenario is higher than the weight value corresponding to the primary target large model in the target dialogue scenario. The adjustment method of the weight value is not limited here. Adjusting the weight value of the large model accordingly after each model switch can facilitate the selection of subsequent models, enabling the best-performing target large model to be obtained for each question and answer most quickly, and improving the question-and-answer accuracy of the large model.
[0081] It should be noted that the structured prompt information corresponding to different target large models is not exactly the same. When the waiting time of the primary target large model is greater than the preset time, the server 102 can disconnect the communication connection with the primary target large model and send a model call request to the backup target large model. The model call request includes the historical question-and-answer records with the primary target large model and the structured prompt information filtered by the target question. All model switches are executed on the server side, and the interface presented to the target user on the client side will not change at all, enabling the backup large model to continue to complete the reply to the target user without the target user's awareness.
[0082] In the above or following embodiments, a local knowledge base can also be constructed for the server 102.
[0083] In the case where the target large model outputs the reply content, the target question, the target inquiry intention, and the reply content are jointly added to the local knowledge base to enrich the local knowledge base. The local knowledge base stores existing questions, the inquiry intentions corresponding to the existing questions, and the corresponding existing reply contents. The existing questions, the inquiry intentions corresponding to the existing questions, and the corresponding existing reply contents can be stored in the Q&A sub-knowledge base of the local knowledge base. In this way, when encountering the same question subsequently, the Q&A sub-knowledge base in the local knowledge base can be directly used to reply to the user's question, reducing the retrieval dependence on the large model, reducing the waiting time for external service responses, and enabling quick responses to the user's inquiries, thus enhancing the user's inquiry experience.
[0084] Accordingly, before adding the target inquiry intent and the target dialogue example to the model call request, a match can be made in the local knowledge base according to the target inquiry intent. If the response content that matches the target inquiry intent is not matched in the local knowledge base, the target inquiry intent and the target dialogue example are added to the model call request. Each time the target inquiry intent corresponding to the target question is determined, the response content that matches the target inquiry intent is first retrieved in the local knowledge base. If the local knowledge base cannot be used to respond to the target question, the target large model is called to respond to the target question. This reduces the call to the target large model to a certain extent and can significantly reduce costs.
[0085] Continue to refer Figure 2 The local knowledge base can also include the business sub-knowledge base established by the model caller for its own business, so that when facing inquiries related to the company's own business, the local knowledge base can be used directly to respond, without calling the target large model. Using the local knowledge base to answer business inquiries can not only ensure the accuracy of the response, but also reduce the time waiting for the target large model to respond, increase the speed of response to users, and thus improve the user's inquiry experience. In addition, a speech sub-knowledge base can be configured in the local knowledge base. When a meaningless question is identified, the default speech preset in the speech sub-knowledge base is used to respond. The default speech is a preparatory communication strategy that aims to provide a set of alternative plans or explanations when communication encounters obstacles or cannot be responded directly, so as to maintain the continuity and harmony of communication.
[0086] Based on this, in this embodiment, a combination of a local knowledge base, an external big model, and an external knowledge base associated with the external big model is used, and the third-party big model can be used to achieve the effect of model customization without the need for the enterprise to independently develop and train the big model. While using the external big model to achieve comprehensiveness and accuracy of responses, the local knowledge base is also gradually enriched to gradually reduce dependence on the external big model, thereby significantly reducing costs.
[0087] In the above or below embodiments, the question and answer generation logic in the target dialogue scenario may include a variety of question and answer related execution logics.
[0088] Optionally, the Q&A generation logic in the target dialogue scenario may sequentially include intent understanding logic, knowledge matching logic, knowledge rewriting logic, etc. Based on this, when inputting the model call request into the target large model, the intent understanding logic can be executed first to understand the target inquiry intent according to the role setting associated with the target dialogue example; then the knowledge matching logic can be executed to retrieve the target knowledge adapted to the target inquiry intent from the external knowledge base associated with the target large model; finally, the knowledge rewriting logic can be executed to rewrite the target knowledge to obtain the reply content corresponding to the target question. The knowledge rewriting mentioned here can be understood as sorting out the target knowledge retrieved from the external knowledge base to generate the reply content corresponding to the target question. Among them, various knowledge information is stored in the external knowledge base, and the formats of these knowledge information include but are not limited to documents, tables, images, videos, audios, etc.
[0089] In this embodiment, based on the role setting associated with the dynamically screened target dialogue example, the target large model can more accurately understand its own role positioning, and thus can more accurately understand the target inquiry intent of the target user in the target dialogue scenario. Moreover, using the external knowledge base provides an additional information source for the target large model, enabling the target large model to provide more accurate and rich replies. The external knowledge base can be updated in real time according to factual information, which can ensure the credibility and accuracy of the knowledge retrieved from the external knowledge base. Based on the above accurate target inquiry intent and accurate knowledge, the reply content for the target question can be accurately generated, thereby improving the Q&A effect of the large model.
[0090] In this alternative solution, the Q&A generation logic in the target dialogue scenario may further include the content format constraint conditions corresponding to the knowledge rewriting logic. The content format constraint conditions include the style, tone, and word count required for the reply content to meet, as well as the keyword highlighting conditions, etc. Based on this, the knowledge rewriting logic in the Q&A logic can be executed to rewrite the content and format of the target knowledge according to the style, tone, and word count in the content format constraint conditions to obtain the rewritten content, and according to the keyword highlighting conditions in the content format constraint conditions, identify the keywords in the rewritten content that are adapted to the target question, and configure highlighting attribute information for the keywords to obtain the reply content for the target question. The highlighting attribute information is used to highlight the keywords in the reply content when the reply content is displayed. By configuring the style, tone, and word count of the reply content, and highlighting the keywords in the reply content, the generated reply content can have better readability and improve the user experience.
[0091] In addition, the Q&A generation logic in the target dialogue scenario may further include the knowledge base constraints corresponding to the knowledge matching logic. The knowledge base constraints are used to limit the external knowledge base associated with the target large model. According to the knowledge base constraints, the external knowledge base associated with the target large model 103 can be determined. The external knowledge base includes a dedicated knowledge base and a general knowledge base. When the target large model 103 executes the knowledge matching logic, it can first retrieve the target knowledge adapted to the target query intention in the dedicated knowledge base. If the target knowledge is not retrieved in the dedicated knowledge base, it then retrieves the target knowledge adapted to the target query intention from the general knowledge base.
[0092] The general knowledge base is a knowledge base that widely covers multiple fields and topics, and the dedicated knowledge base is a knowledge base in the vertical field corresponding to the target dialogue scenario. The knowledge contained in the professional knowledge base is more relevant to the target questions in the target dialogue scenario. Dividing the external knowledge base into a general knowledge base and a dedicated knowledge base and giving priority to retrieving in the field related to the target dialogue scenario can effectively reduce the retrieval scope, relieve the workload of the target large model, and thus improve the Q&A efficiency of the target large model.
[0093] Continue to refer to Figure 2 The general knowledge base may include multiple sub-knowledge bases, and different sub-knowledge bases correspond to different application fields. In the process of retrieving the target knowledge adapted to the target query intention from the general knowledge base, the available sub-knowledge bases and disabled sub-knowledge bases can be identified from multiple sub-knowledge bases according to the application field to which the target dialogue scenario belongs and the application fields corresponding to the multiple sub-knowledge bases. The target knowledge adapted to the target query intention is retrieved in the available sub-knowledge bases. Among them, the available sub-knowledge base refers to the knowledge base that is advocated to be preferentially used in the retrieval process, and the disabled sub-knowledge base refers to the knowledge base that is prohibited from being used in the retrieval process.
[0094] For example, if the target dialogue scenario corresponding to the target question is to consult the latest housing purchase policies, the information with relatively high authority in the general knowledge base can be classified as the available sub-knowledge base, such as the official information released by authoritative institutions; the information released by unknown netizens can be classified as the disabled sub-knowledge base, such as the speculation information posted by personal accounts. The classification methods of the available sub-knowledge base and the disabled sub-knowledge base include, but are not limited to, classification according to the domain name suffix, classification according to the information publisher, classification according to the information release time, etc. By dividing the external knowledge base into available sub-knowledge bases and disabled sub-knowledge bases, not only can the retrieval efficiency of the target large model be improved, but also the credibility and accuracy of the reply content generated by the target large model for the target question can be effectively guaranteed.
[0095] Figure 3Schematic flowchart of a question - answering method provided for another exemplary embodiment of the present application. This method can be executed by a data processing device, which can be implemented as a combination of software and / or hardware, and can be integrated in a computing device. Refer to Figure 3 , the method includes:
[0096] Step 300, obtain a target question input by a target user and structured prompt information pre - configured for a target large model;
[0097] Among them, the structured prompt information contains multiple dialogue examples. Each dialogue example is associated with a dialogue scenario and a role setting. Each dialogue scenario is associated with a question - and - answer generation logic and at least one scenario description word. The role setting associated with the dialogue example is used to represent the role played by the target large model in the dialogue scenario. The question - and - answer generation logic is used to describe the execution logic for the target large model to generate a reply content for the target question in the dialogue scenario;
[0098] Step 301, extract target keywords related to the dialogue scenario from the target question, and based on the target keywords, the multiple dialogue scenarios included in the structured prompt information, and the scenario description words respectively associated with each dialogue scenario, determine a target dialogue scenario suitable for the target question;
[0099] Step 302, based on the target dialogue scenario, screen the multiple dialogue examples in the structured prompt information to obtain target dialogue examples suitable for the target dialogue scenario;
[0100] Step 303, use an intention recognition model to recognize the intention of the target question to obtain a target inquiry intention corresponding to the target question;
[0101] Step 304, when the target inquiry intention is suitable for the target large model, add the target inquiry intention and the target dialogue example to a model call request;
[0102] Step 305, call the target large model according to the model call request to execute the question - and - answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target inquiry intention to generate a reply content for the target question;
[0103] Step 306, send the reply content output by the target large model to the target user to answer the target question.
[0104] In an optional embodiment, in the process of using an intention recognition model to recognize the intention of the target question to obtain a target inquiry intention corresponding to the target question, the method may further include:
[0105] Use an intent recognition model to recognize the intent of the target question to obtain an initial query intent; based on the preset mapping relationship between intents and slots, obtain at least one slot corresponding to the initial query intent; for any slot, if the target question does not contain the slot information corresponding to the slot, obtain the slot information corresponding to the slot from the basic information of the target user and the context information of the target question; rewrite the target question based on the obtained slot information; use the intent recognition model to recognize the intent of the rewritten target question to obtain the target query intent.
[0106] In an alternative embodiment, the question-answering generation logic in the target dialogue scenario sequentially includes an intent understanding logic, a knowledge matching logic, and a knowledge rewriting logic. In the process of calling the target large model according to the model call request to execute the question-answering generation logic in the target dialogue scenario to generate the response content of the target question according to the role setting associated with the target dialogue example and the target query intent, the method may further include:
[0107] Input the model call request into the target large model, execute the intent understanding logic to understand the target query intent according to the role setting associated with the target dialogue example; execute the knowledge matching logic to retrieve the target knowledge adapted to the target query intent from the external knowledge base associated with the target large model, and various knowledge information is stored in the external knowledge base; execute the knowledge rewriting logic to rewrite the target knowledge to obtain the response content corresponding to the target question.
[0108] In an alternative embodiment, the question-answering generation logic in the target dialogue scenario further includes the knowledge base constraint conditions corresponding to the knowledge matching logic, and the knowledge base constraint conditions are used to limit the external knowledge base associated with the target large model. In the process of executing the knowledge matching logic to retrieve the target knowledge adapted to the target query intent from the external knowledge base associated with the target large model, the method further includes:
[0109] According to the knowledge base constraint conditions, determine the external knowledge base associated with the target large model. The external knowledge base includes a dedicated knowledge base and a general knowledge base. The dedicated knowledge base is the knowledge base in the vertical domain corresponding to the target dialogue scenario; execute the knowledge matching logic, and preferentially retrieve the target knowledge adapted to the target query intent from the dedicated knowledge base. If the target knowledge is not retrieved from the dedicated knowledge base, retrieve the target knowledge adapted to the target query intent from the general knowledge base.
[0110] In an alternative embodiment, the general knowledge base includes multiple sub-knowledge bases, and different sub-knowledge bases correspond to different application fields. In the process of retrieving the target knowledge adapted to the target query intent from the general knowledge base, the method further includes:
[0111] Identify available sub-knowledge bases and disabled sub-knowledge bases from multiple sub-knowledge bases according to the application field to which the target dialogue scenario belongs and the application fields corresponding to the multiple sub-knowledge bases; retrieve in the available sub-knowledge bases according to the target query intention to obtain target knowledge adapted to the target query intention.
[0112] In an optional embodiment, the question and answer generation logic in the target dialogue scenario further includes content format constraint conditions corresponding to the knowledge rewriting logic. The content format constraint conditions include the style, tone, and word count that the reply content is required to meet, as well as the keyword highlighting condition. When executing the knowledge rewriting logic to rewrite the target knowledge to obtain the reply content corresponding to the target question, the method further includes:
[0113] Execute the knowledge rewriting logic to perform content and format rewriting on the target knowledge according to the style, tone, and word count in the content format constraint conditions to obtain the rewritten content, and identify the keywords in the rewritten content that are adapted to the target question according to the keyword highlighting condition in the content format constraint conditions, and configure highlighting attribute information for the keywords to obtain the reply content of the target question; the highlighting attribute information is used to highlight the keywords in the reply content when displaying the reply content.
[0114] In an optional embodiment, before calling the target large model according to the model call request, the method further includes:
[0115] Calculate the relevance between the target question and the historical questions input by the target user; based on the relevance, select target historical questions from the historical questions input by the target user whose relevance is higher than the preset relevance value; add the target historical questions and the corresponding historical reply contents to the model call request for the target large model to use the target historical questions and historical reply contents to assist in understanding the target query intention.
[0116] In an optional embodiment, the number of target large models is multiple, and each target large model is associated with different weight values in different dialogue scenarios. When calling the target large model according to the model call request to execute the question and answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target query intention to generate the reply content of the target question, the method further includes:
[0117] Select the target large model with the largest current weight value from the multiple target large models as the primary target large model according to the weight value associated with each target large model in the target dialogue scenario; call the primary target large model according to the model call request to execute the question and answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target query intention to generate the reply content of the target question.
[0118] In an optional embodiment, during the process of performing question and answer using the primary target large model, a detection signal may be periodically sent to the primary target large model; a response signal returned by the primary target large model for the detection signal is received; the waiting duration from sending the detection signal to receiving the response signal is calculated; if the waiting duration is greater than a preset duration, then from other target large models that have not processed the target question, the target large model with the highest weight value in the target dialogue scenario is selected as the backup target large model; the historical question and answer records generated by the primary target large model for the target user are synchronized to the backup target large model, so as to use the backup target large model to replace the primary target large model to reply to the target user.
[0119] In an optional embodiment, in the case of using the backup target large model to replace the primary target large model to reply to the target user, the weight value of the primary target large model corresponding to the target dialogue scenario and the weight value of the backup target large model corresponding to the target dialogue scenario are obtained; the weight value of the primary target large model corresponding to the target dialogue scenario and / or the weight value of the backup target large model corresponding to the target dialogue scenario are adjusted, so that the weight value of the backup target large model corresponding to the target dialogue scenario is higher than the weight value of the primary target large model corresponding to the target dialogue scenario, so as to preferentially use the backup target large model in the target dialogue scenario.
[0120] In an optional embodiment, during the process of adding the target inquiry intention and the target dialogue example to the model call request, the method further includes:
[0121] Match according to the target inquiry intention in the local knowledge base, where the local knowledge base stores existing questions, the inquiry intentions corresponding to the existing questions, and the corresponding existing reply contents; if no reply content adapted to the target inquiry intention is matched in the local knowledge base, add the target inquiry intention and the target dialogue example to the model call request;
[0122] The method further includes: in the case where the target large model outputs the reply content, jointly add the target question, the target inquiry intention, and the reply content to the local knowledge base to enrich the local knowledge base.
[0123] For the technical details in the embodiments of the above question and answer method, reference may be made to the relevant descriptions of the actions of the server in the embodiments of the foregoing question and answer system. To save space, they will not be elaborated here, but this should not cause loss of the protection scope of this application.
[0124] It should be noted that the execution subject of each step of the method provided in the above embodiments may be the same device, or the method may also be executed by different devices as the execution subject. For example, the execution subject of steps 301 to 303 may be device A; for another example, the execution subject of steps 301 and 302 may be device A, and the execution subject of step 303 may be device B, etc.
[0125] In addition, in some of the processes described in the above embodiments and the accompanying drawings, a plurality of operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order in which they appear herein or may be executed in parallel. The serial numbers of the operations, such as 301, 202, etc., are only used to distinguish the different operations, and the serial numbers themselves do not represent any order of execution. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel.
[0126] Figure 4 The figure is a schematic structural diagram of a question-and-answer device provided for another exemplary embodiment of the present application. As Figure 4 shown, the question-and-answer device 40 includes a data interaction module 41, an example screening module 42, an intention recognition module 43, and a model calling module 44.
[0127] The data interaction module 41 can be used to obtain the target question input by the target user.
[0128] The example screening module 42 can be used to extract target keywords related to the conversation scenario from the target question, and based on the target keywords and multiple conversation scenarios included in the structured prompt information pre-configured for the target large model and the scenario description words associated with each conversation scenario, determine the target conversation scenario suitable for the target question; based on the target conversation scenario, screen the multiple conversation examples in the structured prompt information to obtain the target conversation examples adapted to the target conversation scenario.
[0129] Among them, the structured prompt information includes multiple conversation examples, each conversation example is associated with a conversation scenario and a role setting, each conversation scenario is associated with a question-and-answer generation logic and at least one scenario description word, the role setting associated with the conversation example is used to represent the role played by the target large model in the conversation scenario, and the question-and-answer generation logic is used to describe the execution logic for the target large model to generate a reply content for the target question in the conversation scenario.
[0130] The intention recognition module 43 can be used to use the intention recognition model to recognize the intention of the target question to obtain the target inquiry intention corresponding to the target question.
[0131] The model calling module 44 can be used to add the target inquiry intention and the target conversation example to the model calling request when the target inquiry intention is adapted to the target large model; call the target large model according to the model calling request to execute the question-and-answer generation logic in the target conversation scenario according to the role setting associated with the target conversation example and the target inquiry intention to generate the reply content of the target question.
[0132] The data interaction module 41 is also used to send the reply content output by the target large model to the target user to answer the target question.
[0133] It should be noted that for the technical details in the above embodiments of the question-and-answer device, reference can be made to the relevant descriptions of the actions of the data processing device in the above embodiments of the question-and-answer method. To save space, they will not be elaborated here, but this should not cause loss of the protection scope of this application. The data processing device in the foregoing embodiments can be implemented as software or as a combination of software and hardware, and the data processing device can be integrally provided in a computing device.
[0134] Figure 5 This is a schematic structural diagram of a computing device provided by another exemplary embodiment of this application. As Figure 5 shown, the computing device includes: a memory 50, a processor 51, and a communication component 52.
[0135] The processor 51 is coupled to the memory 50 and is used to execute the computer program in the memory 50 for:
[0136] Obtain the target question input by the target user and the structured prompt information pre-configured for the target large model through the communication component 52. The structured prompt information contains multiple dialogue examples. Each dialogue example is associated with a dialogue scenario and a role setting. Each dialogue scenario is associated with a question-and-answer generation logic and at least one scenario description word. The role setting associated with the dialogue example is used to represent the role played by the target large model in the dialogue scenario, and the question-and-answer generation logic is used to describe the execution logic for the target large model to generate a reply content for the target question in the dialogue scenario;
[0137] Extract the target keyword related to the dialogue scenario from the target question, and determine the target dialogue scenario adapted to the target question based on the target keyword, the multiple dialogue scenarios included in the structured prompt information, and the scenario description words respectively associated with each dialogue scenario;
[0138] Based on the target dialogue scenario, screen the multiple dialogue examples in the structured prompt information to obtain the target dialogue example adapted to the target dialogue scenario;
[0139] Use the intention recognition model to recognize the intention of the target question to obtain the target inquiry intention corresponding to the target question;
[0140] When the target inquiry intention is adapted to the target large model, add the target inquiry intention and the target dialogue example to the model call request;
[0141] Call the target large model according to the model call request to execute the question-and-answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target inquiry intention to generate the reply content of the target question;
[0142] Send the response content output by the target large model to the target user to answer the target question.
[0143] In an optional embodiment, during the process of using the intent recognition model to recognize the intent of the target question to obtain the target query intent corresponding to the target question, the processor 51 is further configured to:
[0144] Use the intent recognition model to recognize the intent of the target question to obtain an initial query intent;
[0145] Based on the preset mapping relationship between intents and slots, obtain at least one slot corresponding to the initial query intent;
[0146] For any slot, if the slot information corresponding to the slot is not included in the target question, obtain the slot information corresponding to the slot from the basic information of the target user and the context information of the target question;
[0147] Rewrite the target question based on the obtained slot information;
[0148] Use the intent recognition model to recognize the intent of the rewritten target question to obtain the target query intent.
[0149] In an optional embodiment, the question and answer generation logic in the target dialogue scenario sequentially includes an intent understanding logic, a knowledge matching logic, and a knowledge rewriting logic. During the process of calling the target large model according to the model call request to execute the question and answer generation logic in the target dialogue scenario to generate the response content of the target question according to the role setting associated with the target dialogue example and the target query intent, the processor 51 is further configured to:
[0150] Input the model call request into the target large model, execute the intent understanding logic, and understand the target query intent according to the role setting associated with the target dialogue example;
[0151] Execute the knowledge matching logic to retrieve the target knowledge adapted to the target query intent in the external knowledge base associated with the target large model, and various knowledge information is stored in the external knowledge base;
[0152] Execute the knowledge rewriting logic to rewrite the target knowledge to obtain the response content corresponding to the target question.
[0153] In an optional embodiment, the question and answer generation logic in the target dialogue scenario further includes the knowledge base constraint conditions corresponding to the knowledge matching logic, and the knowledge base constraint conditions are used to limit the external knowledge base associated with the target large model. During the process of executing the knowledge matching logic to retrieve the target knowledge adapted to the target query intent in the external knowledge base associated with the target large model, the processor 51 is further configured to:
[0154] According to the knowledge base constraints, determine the external knowledge bases associated with the target large model. The external knowledge bases include a dedicated knowledge base and a general knowledge base. The dedicated knowledge base is the knowledge base in the vertical domain corresponding to the target dialogue scenario;
[0155] Execute the knowledge matching logic. First, retrieve the target knowledge that matches the target inquiry intention in the dedicated knowledge base. If the target knowledge is not retrieved in the dedicated knowledge base, retrieve the target knowledge that matches the target inquiry intention from the general knowledge base.
[0156] In an optional embodiment, the general knowledge base includes multiple sub-knowledge bases, and different sub-knowledge bases correspond to different application fields. During the process of retrieving the target knowledge that matches the target inquiry intention from the general knowledge base, the processor 51 is further configured to:
[0157] Identify the available sub-knowledge bases and the disabled sub-knowledge bases from the multiple sub-knowledge bases according to the application field to which the target dialogue scenario belongs and the application fields corresponding to the multiple sub-knowledge bases;
[0158] Retrieve in the available sub-knowledge bases according to the target inquiry intention to obtain the target knowledge that matches the target inquiry intention.
[0159] In an optional embodiment, the question and answer generation logic in the target dialogue scenario further includes the content format constraints corresponding to the knowledge rewriting logic. The content format constraints include the style, tone, and word count that the reply content is required to meet, as well as the keyword highlighting conditions. During the process of executing the knowledge rewriting logic to rewrite the target knowledge to obtain the reply content corresponding to the target question, the processor 51 is further configured to:
[0160] Execute the knowledge rewriting logic to perform content and format rewriting on the target knowledge according to the style, tone, and word count in the content format constraints to obtain the rewritten content, and identify the keywords in the rewritten content that match the target question according to the keyword highlighting conditions in the content format constraints, and configure highlighting attribute information for the keywords to obtain the reply content of the target question; the highlighting attribute information is used to highlight the keywords in the reply content when displaying the reply content.
[0161] In an optional embodiment, before calling the target large model according to the model call request, the processor 51 is further configured to:
[0162] Calculate the correlation between the target question and the historical questions input by the target user;
[0163] Based on the correlation, select the target historical questions from the historical questions input by the target user whose correlation is higher than the preset correlation value;
[0164] Add the target historical question and the historical reply content corresponding to the target historical question to the model call request for the target large model to use the target historical question and the historical reply content to assist in understanding the target query intention.
[0165] In an alternative embodiment, the number of target large models is multiple, and each target large model is associated with different weight values in different dialogue scenarios. When calling the target large model according to the model call request to execute the question and answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target query intention to generate the reply content for the target question, the processor 51 is further configured to:
[0166] Select the target large model with the largest current weight value from multiple target large models as the primary target large model according to the weight value associated with each target large model in the target dialogue scenario;
[0167] Call the primary target large model according to the model call request to execute the question and answer generation logic in the target dialogue scenario according to the role setting associated with the target dialogue example and the target query intention to generate the reply content for the target question.
[0168] In an alternative embodiment, the processor 51 is further configured to:
[0169] During the process of using the primary target large model for question and answer, periodically send a detection signal to the primary target large model;
[0170] Receive the response signal returned by the primary target large model for the detection signal;
[0171] Calculate the waiting duration between sending the detection signal and receiving the response signal;
[0172] If the waiting duration is greater than the preset duration, select the target large model with the highest weight value in the target dialogue scenario from other target large models that have not processed the target question as the backup target large model;
[0173] Synchronize the historical question and answer records generated by the primary target large model for the target user to the backup target large model to use the backup target large model to reply to the target user instead of the primary target large model.
[0174] In an alternative embodiment, the processor 51 is further configured to:
[0175] In the case of using the backup target large model to reply to the target user instead of the primary target large model, obtain the weight value corresponding to the primary target large model in the target dialogue scenario and the weight value corresponding to the backup target large model in the target dialogue scenario;
[0176] Adjust the weight value corresponding to the primary target large model in the target dialogue scenario and / or the weight value corresponding to the backup target large model in the target dialogue scenario, so that the weight value corresponding to the backup target large model in the target dialogue scenario is higher than the weight value corresponding to the primary target large model in the target dialogue scenario, and the backup target large model is preferentially used in the target dialogue scenario.
[0177] In an alternative embodiment, during the process of adding the target query intention and the target dialogue example to the model call request, the processor 51 is further configured to:
[0178] Match according to the target query intention in the local knowledge base, where the local knowledge base stores existing questions, the query intentions corresponding to the existing questions, and the corresponding existing reply contents;
[0179] If no reply content adapted to the target query intention is matched in the local knowledge base, add the target query intention and the target dialogue example to the model call request;
[0180] The processor 51 is further configured to:
[0181] In the case where the target large model outputs reply content, jointly add the target question, the target query intention, and the reply content to the local knowledge base to enrich the local knowledge base.
[0182] Furthermore, as Figure 5 shown, the computing device further includes: a display 53, a power supply component 54, an audio component 55, and other components. Figure 5 Only some components are schematically shown in Figure 5 and it does not mean that the computing device only includes
[0183] It should be noted that for the technical details in the embodiments of the computing device above, reference can be made to the relevant descriptions of the actions of the computing device in the embodiments of the foregoing question-and-answer method. To save space, they are not elaborated here, but this should not cause loss of the protection scope of this application.
[0184] An embodiment of this application further provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps in the foregoing question-and-answer method can be implemented. It should be noted that the technical solution of this computer program and the technical solution of the foregoing question-and-answer method belong to the same concept. For the details not described in the technical solution of the computer program, reference can be made to the description of the technical solution of the foregoing question-and-answer method.
[0185] Correspondingly, an embodiment of this application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed, each step that can be executed by the computing device in the foregoing method embodiment can be implemented.
[0186] The foregoingFigure 5 The memory in Figure 5 is used to store computer programs and can be configured to store various other data to support operations on the computing platform. Examples of such data include instructions for any application or method operating on the computing platform, contact data, phone book data, messages, pictures, videos, etc. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disks, or optical disks.
[0187] The above Figure 5 The communication component in Figure 5 is configured to facilitate communication between the device where the communication component is located and other devices in a wired or wireless manner. The device where the communication component is located can access a wireless network based on communication standards, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0188] The above Figure 5 The display in Figure 5 includes a screen, and the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation.
[0189] The above Figure 5 The power component in Figure 5 provides power to various components of the device where the power component is located. The power component can include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the device where the power component is located.
[0190] The above Figure 5The audio component therein can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC). When the device where the audio component is located is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive external audio signals. The received audio signals can be further stored in a memory or sent via a communication component. In some embodiments, the audio component further includes a speaker for outputting audio signals.
[0191] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application 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.) that contain computer-usable program code.
[0192] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the specified functions in Figure 1 one or more flows and / or Figure 1 blocks.
[0193] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implements the specified functions in Figure 1 one or more flows and / or Figure 1 blocks.
[0194] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the specified functions in Figure 1 one or more flows and / or Figure 1 blocks.
[0195] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0196] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0197] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0198] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0199] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A question-and-answer method, characterized in that, Applicable to the server side, including: Obtain the target question input by the target user and the structured prompt information pre-configured for the target large model. The structured prompt information contains multiple conversation examples, each conversation example is associated with a conversation scenario and a role setting. Each conversation scenario is associated with a question-and-answer generation logic and at least one scenario description word. The role setting associated with the conversation example is used to represent the role played by the target large model in the conversation scenario. The question-and-answer generation logic is used to describe the execution logic for the target large model to generate a response content for the target question in the conversation scenario; Extract the target keyword related to the conversation scenario from the target question, and based on the target keyword, the multiple conversation scenarios included in the structured prompt information, and the scenario description words respectively associated with each conversation scenario, determine the target conversation scenario suitable for the target question; Based on the target conversation scenario, screen the multiple conversation examples in the structured prompt information to obtain the target conversation example adapted to the target conversation scenario; Use an intent recognition model to perform intent recognition on the target question to obtain the target inquiry intent corresponding to the target question; When the target inquiry intent is adapted to the target large model, add the target inquiry intent and the target conversation example to the model call request; Call the target large model according to the model call request to execute the question-and-answer generation logic in the target conversation scenario according to the role setting associated with the target conversation example and the target inquiry intent to generate the response content for the target question; Send the response content output by the target large model to the target user to answer the target question; Among them, using an intent recognition model to perform intent recognition on the target question to obtain the target inquiry intent corresponding to the target question includes: Use an intent recognition model to perform intent recognition on the target question to obtain an initial inquiry intent; Based on the preset mapping relationship between intents and slots, obtain at least one slot corresponding to the initial inquiry intent; For any slot, if the target question does not contain the slot information corresponding to the slot, obtain the slot information corresponding to the slot from the basic information of the target user and the context information of the target question; Rewrite the target question based on the obtained slot information; Use the intent recognition model to perform intent recognition on the rewritten target question to obtain the target inquiry intent.
2. The method according to claim 1, wherein The question-and-answer generation logic in the target conversation scenario sequentially includes an intent understanding logic, a knowledge matching logic, and a knowledge rewriting logic; calling the target large model according to the model call request to execute the question-and-answer generation logic in the target conversation scenario according to the role setting associated with the target conversation example and the target inquiry intent to generate the response content for the target question includes: Input the model call request into the target large model and execute the intent understanding logic to understand the target inquiry intent according to the role setting associated with the target conversation example; Execute the knowledge matching logic to retrieve target knowledge that matches the target inquiry intention in the external knowledge base associated with the target large model, where various knowledge information is stored in the external knowledge base; Execute the knowledge rewriting logic to rewrite the target knowledge to obtain the response content corresponding to the target question.
3. The method according to claim 2, wherein, The question and answer generation logic in the target dialogue scenario further includes the knowledge base constraint conditions corresponding to the knowledge matching logic, and the knowledge base constraint conditions are used to limit the external knowledge base associated with the target large model; Execute the knowledge matching logic to retrieve target knowledge that matches the target inquiry intention in the external knowledge base associated with the target large model, including: Determine the external knowledge base associated with the target large model according to the knowledge base constraint conditions. The external knowledge base includes a dedicated knowledge base and a general knowledge base, and the dedicated knowledge base is the knowledge base of the vertical domain corresponding to the target dialogue scenario; Execute the knowledge matching logic, and first retrieve target knowledge that matches the target inquiry intention in the dedicated knowledge base. If the target knowledge is not retrieved in the dedicated knowledge base, retrieve target knowledge that matches the target inquiry intention from the general knowledge base.
4. The method according to claim 3, characterized in that The general knowledge base includes multiple sub-knowledge bases, and different sub-knowledge bases correspond to different application fields. Then, retrieving target knowledge that matches the target inquiry intention from the general knowledge base includes: Identify the available sub-knowledge bases and the disabled sub-knowledge bases from the multiple sub-knowledge bases according to the application field to which the target dialogue scenario belongs and the application fields corresponding to the multiple sub-knowledge bases; Retrieve in the available sub-knowledge bases according to the target inquiry intention to obtain target knowledge that matches the target inquiry intention.
5. The method according to claim 2, wherein The question and answer generation logic in the target dialogue scenario further includes the content format constraint conditions corresponding to the knowledge rewriting logic. The content format constraint conditions include the style, tone, and word count that the response content is required to meet, as well as the keyword highlighting conditions; Execute the knowledge rewriting logic to rewrite the target knowledge to obtain the response content corresponding to the target question, including: Execute the knowledge rewriting logic to perform content and format rewriting on the target knowledge according to the style, tone, and word count in the content format constraint conditions to obtain the rewritten content, and identify the keywords in the rewritten content that match the target question according to the keyword highlighting conditions in the content format constraint conditions, and configure highlighting attribute information for the keywords to obtain the response content of the target question; The highlighting attribute information is used to highlight the keywords in the response content when the response content is displayed.
6. The method according to claim 1, characterized in that Before invoking the target large model according to the model invocation request, it further includes: Calculate the relevance between the target question and the historical questions input by the target user; Based on the relevance, select target historical questions from the historical questions input by the target user whose relevance is higher than the preset relevance value; Add the target historical question and the corresponding historical reply content of the target historical question to the model call request, so that the target large model can use the target historical question and the historical reply content to assist in understanding the target inquiry intention.
7. The method according to claim 1, wherein The number of target large models is multiple, and each target large model is associated with different weight values in different conversation scenarios. Call the target large model according to the model call request to execute the question and answer generation logic in the target conversation scenario according to the role setting associated with the target conversation example and the target inquiry intention to generate the reply content of the target question, including: According to the weight value associated with each target large model in the target conversation scenario, select the target large model with the largest current weight value from multiple target large models as the primary target large model; Call the primary target large model according to the model call request to execute the question and answer generation logic in the target conversation scenario according to the role setting associated with the target conversation example and the target inquiry intention to generate the reply content of the target question.
8. The method according to claim 7, characterized in that The method further includes: During the process of using the primary target large model for question and answer, send a detection signal to the primary target large model at regular intervals; Receive the response signal returned by the primary target large model for the detection signal; Calculate the waiting duration from the time when the detection signal is sent to the time when the response signal is received; If the waiting duration is greater than the preset duration, select the target large model with the highest weight value in the target conversation scenario from other target large models that have not processed the target question as the backup target large model; Synchronize the historical question and answer records generated by the primary target large model for the target user to the backup target large model, so as to use the backup target large model to replace the primary target large model to reply to the target user.
9. The method according to claim 8, wherein It further includes: In the case of using the backup target large model to replace the primary target large model to reply to the target user, obtain the weight value corresponding to the primary target large model in the target conversation scenario and the weight value corresponding to the backup target large model in the target conversation scenario; Adjust the weight value corresponding to the primary target large model in the target conversation scenario and / or the weight value corresponding to the backup target large model in the target conversation scenario, so that the weight value corresponding to the backup target large model in the target conversation scenario is higher than the weight value corresponding to the primary target large model in the target conversation scenario, so as to preferentially use the backup target large model in the target conversation scenario.
10. The method according to any one of claims 1-9, characterized in that, Adding the target inquiry intention and the target conversation example to the model call request includes: Match according to the target inquiry intention in the local knowledge base, and the local knowledge base stores existing questions, the corresponding inquiry intentions of the existing questions, and the corresponding existing reply content; If no reply content adapted to the target inquiry intention is matched in the local knowledge base, add the target inquiry intention and the target conversation example to the model call request; The method further includes: When the target large model outputs the reply content, the target question, the target inquiry intention, and the reply content are jointly added to the local knowledge base to enrich the local knowledge base.
11. A question and answer system, characterized in that, It includes a client, a server, and a target large model; The client is used to obtain the target question input by the target user and provide the target question to the server; The server is used to obtain the target question and the structured prompt information pre-configured for the target large model; Extract the target keywords related to the conversation scenario from the target question, and based on the target keywords, the multiple conversation scenarios included in the structured prompt information, and the scenario description words associated with each conversation scenario, determine the target conversation scenario suitable for the target question; Based on the target conversation scenario, screen the multiple conversation examples in the structured prompt information to obtain the target conversation examples suitable for the target conversation scenario; Use an intention recognition model to recognize the intention of the target question to obtain the target inquiry intention corresponding to the target question; When the target inquiry intention is suitable for the target large model, add the target inquiry intention and the target conversation example to the model call request; Call the target large model according to the model call request; Among them, the structured prompt information includes multiple conversation examples, each conversation example is associated with a conversation scenario and a role setting, each conversation scenario is associated with a question and answer generation logic and at least one scenario description word, and the role setting associated with the conversation example is used to represent the role played by the target large model in the conversation scenario, and the question and answer generation logic is used to describe the execution logic for the target large model to generate a reply content for the target question in the conversation scenario; Among them, when the server uses an intention recognition model to recognize the intention of the target question to obtain the target inquiry intention corresponding to the target question, it specifically uses: use the intention recognition model to recognize the intention of the target question to obtain the initial inquiry intention; based on the preset mapping relationship between the intention and the slot, obtain at least one slot corresponding to the initial inquiry intention; for any slot, if the target question does not include the slot information corresponding to the slot, obtain the slot information corresponding to the slot from the basic information of the target user and the context information of the target question; based on the obtained slot information, rewrite the target question; use the intention recognition model to recognize the intention of the rewritten target question to obtain the target inquiry intention; The target large model is used to execute the question and answer generation logic in the target conversation scenario according to the role setting associated with the target conversation example and the target inquiry intention to generate the reply content of the target question; provide the reply content to the server; The server is also used to send the reply content output by the target large model to the client; The client is also used to display the reply content to the target user to answer the target question.
12. A question-and-answer device, characterized in that, It includes a data interaction module, an example screening module, an intent recognition module, and a model invocation module; The data interaction module is used to obtain the target question input by the target user; The example screening module is used to extract target keywords related to the conversation scenario from the target question, and determine the target conversation scenario adapted to the target question based on multiple conversation scenarios included in the structured prompt information pre-configured for the target large model, scenario description words associated with each conversation scenario, and the target keywords; Based on the target conversation scenario, screen multiple conversation examples in the structured prompt information to obtain target conversation examples adapted to the target conversation scenario; Among them, the structured prompt information contains multiple conversation examples, each conversation example is associated with a conversation scenario and a role setting, each conversation scenario is associated with a question-and-answer generation logic and at least one scenario description word, the role setting associated with the conversation example is used to represent the role played by the target large model in the conversation scenario, and the question-and-answer generation logic is used to describe the execution logic for the target large model to generate a reply content for the target question in the conversation scenario; When the intent recognition module is used to perform intent recognition on the target question by using an intent recognition model to obtain the target inquiry intent corresponding to the target question, it is specifically used to: perform intent recognition on the target question by using an intent recognition model to obtain an initial inquiry intent; based on a preset mapping relationship between intents and slots, obtain at least one slot corresponding to the initial inquiry intent; for any slot, if the target question does not contain the slot information corresponding to the slot, obtain the slot information corresponding to the slot from the basic information of the target user and the context information of the target question; rewrite the target question based on the obtained slot information; perform intent recognition on the rewritten target question by using the intent recognition model to obtain the target inquiry intent; The model invocation module is used to add the target inquiry intent and the target conversation example to a model invocation request when the target inquiry intent is adapted to the target large model; call the target large model according to the model invocation request to execute the question-and-answer generation logic in the target conversation scenario according to the role setting associated with the target conversation example and the target inquiry intent to generate a reply content for the target question; The data interaction module is further used to send the reply content output by the target large model to the target user to answer the target question.
13. A computing device, characterized in that, It includes a memory, a processor, and a communication component; The memory is used to store one or more computer instructions; The processor is coupled to the memory and the communication component and is used to execute the one or more computer instructions to execute the question-and-answer method according to any one of claims 1-10.
14. A computer-readable storage medium storing computer instructions, characterized in that, When the computer instructions are executed by one or more processors, the one or more processors are caused to execute the question-and-answer method according to any one of claims 1-10.
Citation Information
Patent Citations
Question and answer information processing method and device, commodity information display method and device and storage medium
CN113869969A
Intent recognition method and apparatus, and device and readable storage medium
WO2024093403A1
Cited By
Intelligent customer service script recommendation method and system fusing emotional problems
CN122796088A