Question and answer method, system, device and equipment and storage medium
By configuring structured prompt information and dynamically filtering dialogue examples for the big model, the problem that the general big 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
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-10-23
AI Technical Summary
The existing general model cannot directly meet the personalized needs of the enterprise, resulting in poor Q&A results.
Configure structured prompt information containing multiple dialogue examples for the target model. Each dialogue example is associated with dialogue scenarios and role settings. By extracting keywords in the target problem and dialogue scenarios in the structured prompt information, dynamic filtering is performed. A matching dialogue example to call the big model.
By personalized fine-tuning the big model, it can meet the personalized needs of the enterprise, improve the accuracy and efficiency of question-and-answer, and reduce the consumption of computing resources and time.
Smart Images

Figure CN119441429A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering method, system, device, equipment and storage medium. Background Art
[0002] Retrieval-Augmented Generation (RAG) is a natural language processing model that combines information retrieval and text generation technology. 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. At present, it takes a lot of time and cost to train the RAG model independently developed, with a long development cycle and high maintenance costs. Therefore, enterprises usually choose to call the already 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, and cannot provide accurate answers to the company's customers, resulting in poor question-and-answer effects of general large models. Summary of the invention
[0004] Multiple aspects of the present application provide a question-answering method, system, apparatus, device and storage medium for improving the question-answering effect of a large model when a general large model is called.
[0005] In a first aspect, an embodiment of the present application provides a question-answering method, comprising:
[0006] Obtaining a target question input by a target user and structured prompt information pre-configured for a target macromodel, wherein the structured prompt information includes a plurality of 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 characterize the role played by the target macromodel in the dialogue scenario, and the question-and-answer generation logic is used to describe the execution logic of the target macromodel generating a reply content for the target question in the dialogue scenario;
[0007] Extracting target keywords related to the dialogue scenario from the target question, and determining a target dialogue scenario that matches the target question based on the target keywords and multiple dialogue scenarios included in the structured prompt information and scenario description words associated with each dialogue scenario;
[0008] Based on the target dialogue scenario, multiple dialogue examples in the structured prompt information are screened to obtain a target dialogue example adapted to the target dialogue scenario;
[0009] Using the intention recognition model to perform intention recognition on the target question to obtain the target inquiry intention corresponding to the target question;
[0010] In the case where the target query intention is adapted to the target large model, adding the target query intention and the target dialogue example to the model call request;
[0011] Calling the target big model according to the model calling 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;
[0012] The reply content output by the target large model is sent to the target user to answer the target question.
[0013] In a second aspect, an embodiment of the present application further provides a question-answering system, including a client, a server, and a target large model;
[0014] The client is used to obtain a target question input by a 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 big model; extract the target keywords related to the dialogue scenario from the target question, and determine the target dialogue scenario that is adapted to the target question based on the target keywords and the multiple dialogue scenarios contained in the structured prompt information and the scenario description words associated with each dialogue scenario; based on the target dialogue scenario, screen the multiple dialogue examples in the structured prompt information to obtain the target dialogue example that is adapted to the target dialogue scenario; use the intent recognition model to perform intent recognition on the target question to obtain the target inquiry intent corresponding to the target question; if the target inquiry intent is adapted to the target big model, add the target inquiry intent and the target dialogue example to the model call request; call the target big model according to the model call request;
[0016] The structured prompt information includes a plurality of dialogue examples, each of which is associated with a dialogue scenario and a role setting, each of which 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 characterize the role played by the target macromodel in the dialogue scenario, and the question-and-answer generation logic is used to describe the execution logic of the target macromodel generating a reply content for the target question in the dialogue scenario;
[0017] The target big model is used to execute the question-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; and provide the reply content to the server;
[0018] The server is further configured to send the reply content output by the target large model to the client;
[0019] The client is also used to display the reply 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-answering device, including a data interaction module, an example screening module, an intention recognition module, and a model calling 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, determine the target dialogue scenario that is suitable for the target question based on the target keywords and multiple dialogue scenarios contained in the structured prompt information pre-configured for the target macro 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 a target dialogue example that is suitable for the target dialogue scenario;
[0023] The structured prompt information includes a plurality of dialogue examples, each of which is associated with a dialogue scenario and a role setting, each of which 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 characterize the role played by the target macromodel in the dialogue scenario, and the question-and-answer generation logic is used to describe the execution logic of the target macromodel generating a reply content for the target question in the dialogue scenario;
[0024] The intention recognition module uses the intention recognition model to perform intention recognition on the target question to obtain the target inquiry intention corresponding to the target question;
[0025] The model calling module is used to add the target inquiry intention and the target dialogue example to the model calling request when the target inquiry intention is adapted to the target big model; call the target big model according to the model calling 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;
[0026] The data interaction module is also used to send the reply content output by the target large model to the target user to answer the target question.
[0027] In a fourth aspect, 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 perform the aforementioned question-and-answer method.
[0030] In a fifth aspect, an embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by one or more processors, causes the one or more processors to execute the aforementioned question-and-answer method.
[0031] In a sixth aspect, an embodiment of the present application further provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the processor is caused to execute the aforementioned question-and-answer method.
[0032] In the embodiment of the present application, the target large model is configured with structured prompt information including multiple dialogue examples, each dialogue example is associated with a dialogue scenario and role setting, and different role settings are used to characterize the 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, 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, the target keywords related to the dialogue scenario can be extracted from the target question, and the target dialogue scenario that is suitable for the target question can be determined based on the target keywords and the multiple dialogue scenarios contained in the structured prompt information and the scenario description words associated with each dialogue scenario. The target dialogue examples that are suitable for the target dialogue scenario in the structured prompt information are screened out, so as to use the model call request carrying the target dialogue example to call the target big model to reply to the target question. By dynamically filtering dialogue examples for the target question, the target big model only needs to learn dialogue examples related to the target question in each question-and-answer process, which not only helps the target big model to accurately understand the current dialogue scenario, but also reduces the tokens consumed by the target big model, saves more computing resources and time, and can quickly generate reply content for the target question based on the knowledge information related to the target dialogue scenario, improves the accuracy and efficiency of generating reply content, and thus improves the question-and-answer effect of the big model. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0035] Figure 1 A structural diagram of a question-answering system provided by an exemplary embodiment of the present application;
[0036] Figure 2 A schematic diagram of the structure of another question-answering system provided for another exemplary embodiment of the present application;
[0037] Figure 3 A flowchart of a question-and-answer method provided for another exemplary embodiment of the present application;
[0038] Figure 4 A structural schematic diagram of a question-and-answer device provided for another exemplary embodiment of the present application;
[0039] Figure 5 A schematic diagram of the structure of a computing device is provided for yet another exemplary embodiment of the present application. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0041] Before starting to explain in detail 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] Retrieval-Augmented Generation (RAG) 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 the retrieval-augmented generation large model, or RAG large model. The workflow of the RAG large model mainly includes: receiving questions input by users, retrieving information related to the questions input by users from a pre-built large-scale knowledge base; fusing the retrieved information with the questions input by users, and using the fused information to generate responses to the questions input by users.
[0043] Large Language Models (LLMs) are complex neural networks trained on large amounts of data that can capture and simulate the complexity and diversity of language. They use deep learning techniques, especially 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, usually a word, character, or wordpiece. Embedding is a technique that converts a token into a fixed-length vector representation that captures the semantic and grammatical information of the token, enabling the model to understand and process language.
[0044] During the research, the inventors found that since the training process of the big model supporting search enhancement generation is extremely complex and lengthy, and the development cost is high, the trained big model provided by the big model service provider is usually directly called. However, the big model provided by the provider is generally a general big model, which cannot directly meet the personalized needs of the enterprise, and will lead to certain deviations in the answers provided to the enterprise's customers, resulting in poor question-answering effect of the general big model.
[0045] To improve this problem, the embodiment of the present application provides 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 role setting. Different role settings are used to characterize the 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, so that the fine-tuned target large model can 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 contained in the structured prompt information and the scenario description words associated with each dialogue scenario, the target dialogue scenario that is suitable for the target question can be determined. The target dialogue example that is suitable for the target dialogue scenario is determined from the structured prompt information, so that the target large model is called to reply to the target question using the model call request carrying the target dialogue example. Before calling the target large model, the dialogue examples in the structured prompt information can be dynamically screened 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 during each question-answering process. This helps the target large model to accurately understand the current dialogue scenario, and generate reply content for the target question based on the knowledge information related to the target dialogue scenario, thereby improving the accuracy of the generated reply content. In addition, the dialogue examples passed to the target large model are screened, which 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 improves the question-answering effect of the large model.
[0047] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0048] Figure 1 The following is a schematic diagram of a question-answering system provided by an exemplary embodiment of the present application. Figure 1 As shown, the system includes: a client 101, a server 102 and a target large model 103. The server 102 is connected to the client 101 and the target large model 103 in communication, and the communication connection can be a wired or wireless network connection. For example, the client 101 and the server 102 can be in the same local area network or belong to different local area networks, and the server 102 and the target large model 103 can establish a communication connection through a network protocol. Of course, these are only exemplary and are not limited to this.
[0049] Among them, the client 101 can be an application, a web application, a light application or a cloud application, etc., and the server 102 can include a server that provides various services. Both the client 101 and the server 102 belong to the model caller side. The target large model 103 can be a trained large model provided by a large model service provider, which belongs to the model provider side. The provider of the large model service (i.e., the model provider) can provide an application programming interface (Application Programming Interface, API) to the outside world, and the model caller can configure the calling logic of the API in the server 102 to implement the call to the target large model 103 by calling the API.
[0050] In practical applications, the question-answering system can have any number of clients, servers, and target models. Figure 1Only a client, a server and a target large model are shown exemplarily, but this should not cause loss of the protection scope of this application.
[0051] The question-answering system provided in this embodiment can be applied to various scenarios that require the use of a large model to perform question-answering tasks, such as scenarios where a large model is used for question consultation, scenarios where a large model is used for article creation, etc. This embodiment does not limit the application scenario.
[0052] For the server 102, after obtaining the target question input by the target user provided by the client 101, the target keywords related to the dialogue scenario can be extracted from the target question. The dialogue scenario can be used to describe the specific environment and background of the dialogue communication, which not only includes the physical environment (such as location, time, scene, etc.), but also covers more complex social environments, such as the identity of the interlocutor (such as students, recruiters, job seekers, etc.), relationships (such as friends, colleagues, superiors and subordinates, strangers, etc.), purposes (such as obtaining information, solving problems, social interaction, etc.), emotional states (such as happiness, sadness, anger, etc.), and the formality of the dialogue. The dialogue scenario may include but is not limited to the scenario of a home buyer conducting a simple home purchase consultation with a real estate agent in Beijing, and the scenario of a job seeker asking a career planner to develop a clearer career plan for him. The client 101 can display a question-and-answer interface to the target user, so that the target user can enter the target question to be answered on the question-and-answer interface. The target question can be a question in text form or in audio form, and the target question can also contain pictures, files, links, etc., which are not limited in this embodiment.
[0053] In this embodiment, a variety of implementation methods can be used to extract target keywords related to the dialogue scenario from the target question.
[0054] In an optional implementation, the target question can be segmented to obtain multiple phrases of the target question. The part of speech corresponding to each phrase is determined, and the phrase corresponding to the specified part of speech is used as the target keyword related to the dialogue scenario extracted from the target question. Part of speech refers to the grammatical role or functional category played by a word in a sentence or text, which is used to describe the position of the word in the sentence structure and its relationship with other words. Parts of speech include but are not limited to nouns, pronouns, adjectives, adverbs, conjunctions and verbs, etc. The specified part of speech can be nouns, verbs, etc. The segmentation methods used for word segmentation include but are not limited to segmentation according to lexical rules, segmentation using IK Analyzer, segmentation using neural networks, etc.
[0055] In another optional implementation, a data set can be constructed using questions, keywords, and conversation scenarios corresponding to the questions, so as to pre-train the keyword extraction model using the constructed data set. 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 conversation scenario extracted from the target question.
[0056] Of course, these implementations are merely exemplary, and other implementations may be used to extract target keywords related to the dialogue scenario from the target question, without being limited to the above two implementations.
[0057] After obtaining the target question, the server 102 can continue to obtain the structured prompt information pre-configured for the target big model. The structured prompt information is an input text that explicitly contains instructions and context information, and is intended to guide the big model to generate text that better meets the user's expectations. The structured prompt information can be stored in a database within the server 102, or in other databases or cloud databases outside the server 102. The structured prompt information includes multiple dialogue examples, each of which is associated with a dialogue scenario and a role setting. The role setting associated with the dialogue example is used to characterize the role played by the target big model in the dialogue scenario; each dialogue scenario is associated with 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 big model to generate a response content for the target question in the dialogue scenario.
[0058] On this basis, the target dialogue scenario that matches the target question can be determined based on the target keywords and multiple dialogue scenarios contained in the structured prompt information and the scenario description words associated with each dialogue scenario.
[0059] Optionally, the degree of match between the target keyword and any scenario description word in the structured prompt information may be calculated. If the degree of match between any scenario description word and the target keyword is higher than a preset threshold, the conversation scenario associated with the scenario description word is determined as the target conversation scenario that matches the target question. Of course, it is also possible to search for a target scenario description word that completely matches the target keyword from among the multiple scenario description words included in the structured prompt information, and determine the conversation scenario associated with the target scenario description word as the target conversation scenario that matches the target question. This embodiment does not limit this.
[0060] For the server 102, after determining the target dialogue scenario that matches the target question, the server 102 can filter multiple dialogue examples in the structured prompt information based on the target dialogue scenario to obtain the target dialogue example that matches the target dialogue scenario. The target dialogue example is associated with a role setting, which is the role setting that the target macro model needs to refer to when answering the target question.
[0061] It should be noted that each dialogue example contains a question initiated by a user and a reply content that can be referenced by the target big model. The questions and reply content in the dialogue example are associated with role settings, but the role settings associated with the questions in any dialogue example are "users", such as male users, female users, novice users, expert users, buyer users and seller users, etc. Therefore, the role settings associated with the reply content are used as the role settings associated with the dialogue example, so that the role settings associated with the target dialogue example can be directly used to characterize the role played by the target big model in the target dialogue scenario. The role settings associated with the dialogue example include but are not limited to: male, female, novice, expert, buyer and seller, etc.
[0062] Based on this, the intent recognition model can be used to recognize the intent of the target question to obtain the target inquiry intent corresponding to the target question. Intent recognition aims to determine the main purpose or intention 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 model used in this embodiment includes but is not limited to a logistic regression model, a convolutional neural network model, a recurrent neural network model, and the like.
[0063] In the case where the target inquiry intention is adapted to the target large model, the target inquiry intention 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, the model call request may also include other parameters, such as the model identifier of the target large model, the address of the target large model, the output format, etc. The case where the target inquiry intention is adapted to the target large model refers to the case where the server 102 determines to use the target large model to reply to the target question. The determination of the target inquiry intention to adapt 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, the failure to match the reply content adapted to the target inquiry intention from the local knowledge base, and the reply content matched to the target inquiry intention from the local knowledge base cannot answer the target question. Among them, the technical details related to the local knowledge base will be introduced in detail below and will not be described in detail 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 under 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. The output reply content is provided to the server 102, so that the server 102 sends the reply content output by the target large model to the client 101. As described above, the client 101 can display the 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, the server 102 may perform compliance detection on the reply content before sending it to the client 101. If it is detected that the reply content contains illegal words, the server 102 may adjust the illegal words in the reply content and display the reply content after the adjustment operation to the target user. The illegal words may include but are not limited to illegal words, words that violate public order and morality, negative information about the company, etc.
[0066] When checking the compliance of the reply content, you can first partition the information in the reply content according to the number of characters, and then perform a compliance check on the content of each partition according to the preset detection rules to determine whether the content in the partition contains illegal words that do not comply with the detection rules. If illegal words are included, the illegal words are modified, replaced, or deleted to achieve compliance correction of the reply content. Before displaying the reply content to the target user, the reply content is checked for compliance to ensure the compliance of the reply content, avoid the appearance of bad information, and delete negative information about the model caller, thereby maximizing the guarantee that the reply content is friendly to the model caller.
[0067] In summary, in this embodiment, the target keywords related to the dialogue scenario can be extracted from the target question input by the target user, and the target dialogue scenario adapted to the target question can be determined based on the target keywords and the multiple dialogue scenarios contained in the structured prompt information configured for the target large model and the scenario description words associated with each dialogue scenario. The target dialogue examples adapted to the target dialogue scenario in the structured prompt information are screened out, so as to call the target large model to reply to the target question using the model call request carrying the target dialogue example. By dynamically screening dialogue examples for the target question, the target large model only needs to learn dialogue examples related to the target question in each question-and-answer process, which not only helps the target large model to accurately understand the current dialogue scenario, but also reduces the tokens consumed by the target large model, saves more computing resources and time, and can quickly generate reply content for the target question based on the knowledge information related to the target dialogue scenario, improves the accuracy and efficiency of generating reply content, and thus improves the question-and-answer effect of the large model.
[0068] In the above or following embodiments, in order to further improve the accuracy of the inquiry intent corresponding to the target question understood by the target large model, the target inquiry intent carried in the model call request can be rewritten so that the rewritten target inquiry intent can more accurately and comprehensively represent the purpose of the target user.
[0069] Optionally, the intent recognition model can be used to identify the intent of the target question to obtain the initial inquiry intent. Based on the mapping relationship between the preset intent and the slot, at least one slot corresponding to the initial inquiry intent is obtained. The slot refers to an information unit related to a specific intent. The slot can be used to represent the specific information required to realize the user's intent, such as time, place, person, object, 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 intent recognition model is used to identify the intent of the rewritten target question to obtain the target inquiry intent.
[0070] In actual applications, if the target question is "What second-hand houses are on sale today", the target question can be identified by intent recognition to determine that the initial query intent of the target question is "What second-hand houses are on sale today". Based on the mapping relationship between the preset intent and the slot, the slots corresponding to the target intent can be obtained, including: location, date, house type, and house layout. The target question contains the house type "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, it can be determined that the consultation date is 2024-06-01, and the basic information of the user and the following information of the target user do not contain the house layout. Therefore, when rewriting the target question, this slot can be ignored, and the target question can be rewritten as "What second-hand houses are on sale in Beijing on 2024-06-01". The intent recognition model is used to perform intent recognition on the rewritten target question to obtain the target query intent of "Second-hand houses on sale in Beijing on 2024-06-01". By supplementing the slot information in the target question, optimization can be performed in terms of character setting, information timeliness, local positioning, etc., so that the target question contains more information related to the user's inquiry intention, thereby enabling the target big model to better understand the specific needs of the target user and provide accurate responses accordingly.
[0071] In addition, since the present embodiment uses a big model provided by the model provider to conduct question-answering, each question provided by the target user is independent to the big model, and it is impossible to understand the question in combination with the contextual information of the question, which may easily lead to deviations in the big model's current understanding of the question provided by the target user.
[0072] To improve this problem, before calling the target large model according to the model call request, the correlation between the target question and the historical questions input by the target user can be determined. Based on the correlation, the target historical questions with a correlation higher than the preset correlation value are selected from the historical questions input by the target user, and the target historical questions and the historical reply content corresponding to the target historical questions are added to the model call request, so that the target large model can use the target historical questions and historical reply content to assist in understanding the target inquiry intent. By carrying the historical question and answer records related to the target question in the model call request, it can help the target large model to accurately understand the inquiry intent of the target question in combination with the contextual information, so as to give a more accurate reply.
[0073] In summary, in this embodiment, by rewriting the target question, the target query intent corresponding to the target question is enriched and optimized, so that the big model can understand the target query intent more comprehensively and accurately, thereby improving the accuracy and usability of the retrieval. In addition, passing the historical questions related to the target question to the big model can assist the big model in understanding the query intent of the target user, and can also improve the coherence and relevance of the big model's answers, making the conversation more natural and smooth.
[0074] In the above or following embodiments, there may be multiple target macro models, and each target macro model is associated with a different weight value in different dialogue scenarios. The weight value can be used to reflect the question-answering effect of the target macro model in the dialogue scenario. The higher the weight value, the better the question-answering effect of the target macro model. In any dialogue scenario, the target macro model for interacting with the target user can be selected based on the weight value.
[0075] Figure 2 This is a schematic diagram of the structure of another question-answering system provided by another exemplary embodiment of the present application. Figure 2 As shown, the question-answering system includes multiple target big models. After determining the target dialogue scenario that is suitable for the target question, the target big model with the largest current weight value can be selected from the multiple target big models as the main target big model according to the weight value associated with each target big model in the target dialogue scenario. The main target big model is called according to the model call request to execute the question-answering 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 for each target big model in different dialogue scenarios, the question-answering capabilities of the target big model in different dialogue scenarios can be clearly presented, making it easier for the server to screen out the target big models available in the target dialogue scenario based on the target dialogue scenario in which the current question and answer is located. Then, based on the weight values of each target big model in the target dialogue scenario, the target big model with the largest weight value is selected from the target big models available in the target dialogue scenario as the main target big model. In this way, by screening multiple target big models from the perspectives of dialogue scenario and question-answering effect, it can be ensured that the selected main target big model is sufficiently compatible with the target question, thereby improving the accuracy of the big model's question and answer.
[0077] Optionally, in the process of using the main target big model for question and answer, a detection signal can be periodically sent to the main target big model, and a response signal returned by the main target big model for the detection signal can be received. The waiting time from sending the detection signal to receiving the response signal is calculated. If the waiting time is longer than the preset time, the target big model with the highest weight value in the target dialogue scenario is selected from other target big models that have not handled the target question as the backup target big model, and the historical question and answer records generated by the main target big model for the target user are synchronized to the backup target big model, so that the backup target big model can be used to reply to the target user instead of the main target big model.
[0078] By introducing this timing detection mechanism, when the main target large model is unavailable, it can be switched to the backup target large model in time, ensuring the high availability of the question-and-answer service, thereby improving the user experience.
[0079] In the case where the backup target big model is used to reply to the target user instead of the main target big model, the weight value corresponding to the main target big model in the target dialogue scenario and the weight value corresponding to the backup target big model in the target dialogue scenario can be obtained. The weight value corresponding to the main target big model in the target dialogue scenario and / or the weight value corresponding to the backup target big model in the target dialogue scenario are adjusted so that the weight value corresponding to the backup target big model in the target dialogue scenario is higher than the weight value corresponding to the main target big model in the target dialogue scenario, so that the backup target big model is used preferentially in the target dialogue scenario.
[0080] Among them, the weight value corresponding to the main target large model and the weight value corresponding to the backup large model can be exchanged; or, the weight value of the main 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 can be higher than the weight value corresponding to the main target large model in the target dialogue scenario, the weight value adjustment method is not limited here. Adjusting the weight value of the large model accordingly after each model switch can facilitate the selection of subsequent models, so that each question and answer can quickly obtain the target large model with the best question and answer effect, thereby 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 main target large model is longer than the preset time, the server 102 can disconnect the communication connection with the main target large model and send a model call request to the backup target large model. The model call request contains the historical question and answer records with the main target large model and the structured prompt information after the target question is filtered. The switching of the large model is all executed on the server side, and the interface displayed to the target user on the client side will not change, so that the backup large model can take over the target large model and continue to complete the reply to the target user without the target user's perception.
[0082] In the above or below embodiments, a local knowledge base may also be constructed for the server 102 .
[0083] When the target large model outputs the reply content, the target question, target inquiry intention and reply content are jointly added to the local knowledge base to enrich the local knowledge base. The local knowledge base stores existing questions, inquiry intentions corresponding to existing questions and corresponding existing reply content. Existing questions, inquiry intentions corresponding to existing questions and corresponding existing reply content can be stored in the question-and-answer sub-knowledge base in the local knowledge base. In this way, when the same question is encountered later, the question-and-answer sub-knowledge base in the local knowledge base can be directly used to reply to the user's question, which reduces the retrieval dependence on the large model and the time waiting for external service responses. It can quickly respond to user inquiries and improve 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 question and answer generation logic in the target dialogue scenario may include intent understanding logic, knowledge matching logic, knowledge rewriting logic, etc. Based on this, the model call request is input into the target big model, and the intent understanding logic may 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 is executed to retrieve the target knowledge adapted to the target inquiry intent in the external knowledge base associated with the target big model; finally, the knowledge rewriting logic is executed to rewrite the target knowledge to obtain the response content corresponding to the target question. The knowledge rewriting mentioned here can be understood as organizing the target knowledge retrieved from the external knowledge base to generate the response 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, audio, etc.
[0089] In this embodiment, the target big model can more accurately understand its own role positioning based on the role settings associated with the dynamically screened target dialogue examples, and thus can more accurately understand the target user's target inquiry intention in the target dialogue scenario. In addition, the use of an external knowledge base provides an additional information source for the target big model, so that the target big model can provide more accurate and rich responses. The external knowledge base can be updated in real time based on 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 intention and accurate knowledge, the response content can be accurately generated for the target question, thereby improving the question-answering effect of the big model.
[0090] In this optional solution, the question-answer generation logic under the target dialogue scenario may also include content format constraints corresponding to the knowledge rewriting logic, and the content format constraints include the style, tone and word count required for the reply content, as well as keyword highlighting conditions, etc. Based on this, the knowledge rewriting logic in the question-answering 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 constraints to obtain the rewritten content, and to identify the keywords in the rewritten content that are adapted to 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. 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 be made more readable, which improves the user experience.
[0091] In addition, the question-answer generation logic in the target dialogue scenario may also include knowledge base constraints corresponding to the knowledge matching logic, and the knowledge base constraints are used to limit the external knowledge base associated with the target macro model. According to the knowledge base constraints, the external knowledge base associated with the target macro model 103 can be determined, and the external knowledge base includes a dedicated knowledge base and a general knowledge base. When executing the knowledge matching logic, the target macro model 103 may preferentially retrieve the target knowledge that is adapted to the target inquiry intent in the dedicated knowledge base. If the target knowledge is not retrieved in the dedicated knowledge base, the target knowledge that is adapted to the target inquiry intent is retrieved from the general knowledge base.
[0092] The general knowledge base is a knowledge base that covers a wide range of fields and topics, and the specialized knowledge base is a knowledge base in the vertical field corresponding to the target dialogue scenario. The knowledge contained in the specialized knowledge base is more relevant to the target question in the target dialogue scenario. Dividing the external knowledge base into general knowledge base and specialized knowledge base, and prioritizing retrieval in fields related to the target dialogue scenario can effectively reduce the retrieval scope and reduce the workload of the target large model, thereby improving the question-answering efficiency of the target large model.
[0093] Continue to refer Figure 2 , a general knowledge base may include multiple sub-knowledge bases, and different sub-knowledge bases correspond to different application fields. In the process of retrieving target knowledge adapted to the target inquiry intent from the general knowledge base, available sub-knowledge bases and disabled sub-knowledge bases may 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. According to the target inquiry intent, a search is performed in the available sub-knowledge bases to obtain the target knowledge adapted to the target inquiry intent. Among them, the available sub-knowledge base refers to the knowledge base that is advocated for priority use during the retrieval process, and the disabled sub-knowledge base refers to the knowledge base that is prohibited from being used during the retrieval process.
[0094] For example, if the target conversation scenario corresponding to the target question is to consult the latest housing purchase policy, the information with higher authority in the general knowledge base can be divided into available sub-knowledge bases, such as official information released by authoritative institutions; and the information released by unknown netizens can be divided into prohibited sub-knowledge bases, such as speculative information released by personal accounts. The division methods of available sub-knowledge bases and prohibited sub-knowledge bases include but are not limited to division according to domain name suffixes, division according to information publishers, division according to information release time, etc. By dividing the external knowledge base into available sub-knowledge bases and prohibited sub-knowledge bases, not only the retrieval efficiency of the target large model can be improved, but also the credibility and accuracy of the response content generated by the target large model for the target question can be effectively guaranteed.
[0095] Figure 3A flowchart of a question-answering method provided for another exemplary embodiment of the present application. The method may be executed by a data processing device, which may be implemented as a combination of software and / or hardware, and the data processing device may be integrated in a computing device. Figure 3 , the method comprising:
[0096] Step 300, obtaining a target question input by a target user and structured prompt information pre-configured for a target large model;
[0097] The structured prompt information includes multiple dialogue examples, each of which is associated with a dialogue scenario and a role setting, each of which 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 characterize the role played by the target macro model in the dialogue scenario, and the question-and-answer generation logic is used to describe the execution logic of the target macro model in generating a response content for a target question in the dialogue scenario;
[0098] Step 301, extracting target keywords related to the dialogue scenario from the target question, and determining a target dialogue scenario that matches the target question based on the target keywords and multiple dialogue scenarios included in the structured prompt information and the scenario description words associated with each dialogue scenario;
[0099] Step 302, based on the target dialogue scenario, multiple dialogue examples in the structured prompt information are screened to obtain a target dialogue example adapted to the target dialogue scenario;
[0100] Step 303, using the intention recognition model to perform intention recognition on the target question to obtain the target inquiry intention corresponding to the target question;
[0101] Step 304, when the target inquiry intent is adapted to the target large model, the target inquiry intent and the target dialogue example are added to the model call request;
[0102] Step 305, calling the target big model according to the model calling request, so as to execute the question and answer generation logic under the target dialogue scenario according to the role setting and the target inquiry intention associated with the target dialogue example to generate the reply content of the target question;
[0103] Step 306, sending 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 the intention recognition model to recognize the intention of the target question to obtain the target inquiry intention corresponding to the target question, the method may further include:
[0105] The intent of the target question is identified by using the intent recognition model to obtain the initial inquiry intent; based on the mapping relationship between the preset intent and the slot, at least one slot corresponding to the initial inquiry intent is obtained; 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; the intent of the rewritten target question is identified by using the intent recognition model to obtain the target inquiry intent.
[0106] In an optional embodiment, the question and answer generation logic in the target dialogue scenario includes intention understanding logic, knowledge matching logic and knowledge rewriting logic in sequence. In the process of calling the target big 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 and the target inquiry intention associated with the target dialogue example to generate the reply content of the target question, the method may also include:
[0107] The model call request is input into the target big model, and the intention understanding logic is executed to understand the target inquiry intention according to the role setting associated with the target dialogue example; the knowledge matching logic is executed to retrieve the target knowledge adapted to the target inquiry intention in the external knowledge base associated with the target big model, and the external knowledge base stores various knowledge information; the knowledge rewriting logic is executed to rewrite the target knowledge to obtain the response content corresponding to the target question.
[0108] In an optional embodiment, the question-answer generation logic in the target dialogue scenario also includes a knowledge base constraint corresponding to the knowledge matching logic, and the knowledge base constraint is 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 inquiry intention in the external knowledge base associated with the target large model, the method also includes:
[0109] According to the constraints of the knowledge base, 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 a knowledge base in the vertical field corresponding to the target dialogue scenario. Execute the knowledge matching logic and prioritize retrieving the target knowledge that is adapted to the target inquiry intent from the dedicated knowledge base. If the target knowledge is not retrieved from the dedicated knowledge base, retrieve the target knowledge that is adapted to the target inquiry intent from the general knowledge base.
[0110] In an optional 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 target knowledge adapted to the target query intent from the general knowledge base, the method further includes:
[0111] According to the application domain to which the target dialogue scenario belongs and the application domains corresponding to the multiple sub-knowledge bases, available sub-knowledge bases and disabled sub-knowledge bases are identified from the multiple sub-knowledge bases; according to the target inquiry intent, a search is performed in the available sub-knowledge bases to obtain target knowledge adapted to the target inquiry intent.
[0112] In an optional embodiment, the question-answer generation logic in the target dialogue scenario also includes content format constraints corresponding to the knowledge rewriting logic, and the content format constraints include the style, tone and word count required for the reply content, as well as keyword highlighting conditions. In the process of executing the knowledge rewriting logic to rewrite the target knowledge to obtain the reply content corresponding to the target question, the method also includes:
[0113] Execute the knowledge rewriting logic to rewrite the target knowledge in terms of content and format according to the style, tone and word count in the content format constraints to obtain rewritten content, and identify the keywords in the rewritten content that are adapted to the target question according to the keyword highlighting conditions in the content format constraints, and configure highlighting attribute information for the keywords to obtain reply content for 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 calling request, the method further includes:
[0115] Calculate the correlation between the target question and the historical questions input by the target user; based on the correlation, select the target historical questions with a correlation higher than a preset correlation value from the historical questions input by the target user; add the target historical questions and the historical reply content corresponding to the target historical questions to the model call request, so that the target large model can use the target historical questions and historical reply content to assist in understanding the target inquiry intention.
[0116] In an optional embodiment, there are multiple target big models, each target big model is associated with a different weight value in different dialogue scenarios, and in the process of calling the target big model according to the model calling request, so as to execute the question and answer generation logic in the target dialogue scenario according to the role setting and the target inquiry intention associated with the target dialogue example to generate the reply content of the target question, the method also includes:
[0117] According to the weight value associated with each target big model in the target dialogue scenario, the target big model with the largest current weight value is selected from multiple target big models as the main target big model; the main target big model is called according to the model call request to execute the question and answer 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 response content of the target question.
[0118] In an optional embodiment, in the process of using the main target big model for question and answer, a detection signal can be sent to the main target big model at regular intervals; a response signal returned by the main target big model for the detection information is received; the waiting time from the sending of the detection signal to the receiving of the response signal is calculated; if the waiting time is longer than the preset time, the target big model with the highest weight value in the target dialogue scenario is selected from other target big models that have not handled the target problem as the backup target big model; the historical question and answer records generated by the main target big model for the target user are synchronized to the backup target big model, so that the backup target big model can be used to reply to the target user instead of the main target big model.
[0119] In an optional embodiment, when the backup target big model is used instead of the main target big model to reply to the target user, the weight value corresponding to the main target big model in the target dialogue scenario and the weight value corresponding to the backup target big model in the target dialogue scenario are obtained; the weight value corresponding to the main target big model in the target dialogue scenario and / or the weight value corresponding to the backup target big model in the target dialogue scenario are adjusted so that the weight value corresponding to the backup target big model in the target dialogue scenario is higher than the weight value corresponding to the main target big model in the target dialogue scenario, so that the backup target big model is used preferentially in the target dialogue scenario.
[0120] In an optional embodiment, in the process of adding the target query intention and the target dialogue example to the model call request, the method further includes:
[0121] Match the target query intent in the local knowledge base, which stores existing questions, query intents corresponding to existing questions, and corresponding existing responses. If no response content matching the target query intent is found in the local knowledge base, the target query intent and target dialogue example are added to the model call request.
[0122] The method also includes: when the target large model outputs the reply content, jointly adding the target question, the target inquiry intention and the reply content to the local knowledge base to enrich the local knowledge base.
[0123] The technical details in each embodiment of the above-mentioned question-and-answer method can be referred to the relevant description of the actions of the server in each embodiment of the aforementioned question-and-answer system. In order to save space, they will not be repeated here, but this should not cause a 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 embodiment can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 301 to 303 can be device A; for another example, the execution subject of steps 301 and 302 can be device A, and the execution subject of step 303 can be device B, etc.
[0125] In addition, in some of the processes described in the above embodiments and the accompanying drawings, multiple operations appearing in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this document or may be executed in parallel, and the sequence numbers of the operations, such as 301, 202, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel.
[0126] Figure 4 A structural diagram of a question-answering device provided by another exemplary embodiment of the present application is shown below. Figure 4 As shown, the question-answering 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 may be used to obtain a target question input by a target user.
[0128] The example screening module 42 can be used to extract target keywords related to the dialogue scenario from the target question, and determine the target dialogue scenario that is suitable for the target question based on the target keywords and multiple dialogue scenarios contained 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, multiple dialogue examples in the structured prompt information are screened to obtain target dialogue examples that are suitable for the target dialogue scenario.
[0129] Among them, the structured prompt information includes multiple dialogue examples, each dialogue example is associated with a dialogue scenario and role setting, each dialogue scenario is associated with question and answer generation logic and at least one scenario description word, the role setting associated with the dialogue example is used to characterize the role played by the target big model in the dialogue scenario, and the question and answer generation logic is used to describe the execution logic of the target big model to generate response content for the target question in the dialogue scenario.
[0130] The intention recognition module 43 may be used to perform intention recognition on the target question using the intention recognition model 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 intent and the target dialogue example to the model calling request when the target inquiry intent 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 under the target dialogue scenario according to the role setting and the target inquiry intent associated with the target dialogue example to generate the response 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 is worth noting that the technical details of the above-mentioned question-answering device in each embodiment can refer to the relevant description of the action of the data processing device in each embodiment of the question-answering method, and will not be repeated here to save space, but this should not cause loss of the protection scope of this application. The data processing device in the above-mentioned embodiment can be implemented as software or as a combination of software and hardware, and the data processing device can be integrated in a computing device.
[0134] Figure 5 A schematic diagram of a computing device provided as another exemplary embodiment of the present application is shown in FIG. Figure 5 As 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 to:
[0136] The target question input by the target user and the structured prompt information pre-configured for the target macro model are obtained through the communication component 52. 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 characterize the role played by the target macro model in the dialogue scenario. The question-and-answer generation logic is used to describe the execution logic of the target macro model generating a reply content for the target question in the dialogue scenario.
[0137] Extract target keywords related to the dialogue scenario from the target question, and determine a target dialogue scenario that matches the target question based on the target keywords and multiple dialogue scenarios contained in the structured prompt information and the scenario description words associated with each dialogue scenario;
[0138] Based on the target dialogue scenario, multiple dialogue examples in the structured prompt information are screened to obtain a target dialogue example that is suitable for the target dialogue scenario;
[0139] Use the intention recognition model to identify the intention of the target question to obtain the target inquiry intention corresponding to the target question;
[0140] When the target query intent is adapted to the target large model, the target query intent and the target dialogue example are added to the model call request;
[0141] The target big model is called according to the model call request to execute the question-answer generation logic in the target dialogue scenario according to the role setting and the target inquiry intention associated with the target dialogue example to generate the response content of the target question;
[0142] The response content output by the target large model is sent to the target user to answer the target question.
[0143] In an optional embodiment, in the process of performing intent recognition on the target question using the intent recognition model to obtain the target inquiry intent corresponding to the target question, the processor 51 is further configured to:
[0144] Use the intent recognition model to identify the target question and obtain the initial inquiry intent;
[0145] Based on a preset mapping relationship between intent and slot, obtaining at least one slot corresponding to the initial query intent;
[0146] 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;
[0147] Rewrite the target question based on the obtained slot information;
[0148] The intent recognition model is used to identify the intent of the rewritten target question to obtain the target inquiry intent.
[0149] In an optional embodiment, the question and answer generation logic in the target dialogue scenario includes intention understanding logic, knowledge matching logic and knowledge rewriting logic in sequence. In 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 according to the role setting and the target inquiry intention associated with the target dialogue example to generate the reply content of the target question, the processor 51 is also used to:
[0150] Input the model call request into the target big model and execute the intent understanding logic to understand the target inquiry intent according to the role setting associated with the target dialogue example;
[0151] Execute knowledge matching logic to retrieve target knowledge that matches the target query intent from an external knowledge base associated with the target large model, where various knowledge information is stored;
[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-answer generation logic in the target dialogue scenario also includes a knowledge base constraint corresponding to the knowledge matching logic, and the knowledge base constraint is used to limit the external knowledge base associated with the target macro model. In the process of executing the knowledge matching logic to retrieve the target knowledge adapted to the target inquiry intention in the external knowledge base associated with the target macro model, the processor 51 is also used to:
[0154] According to the knowledge base constraints, 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 a knowledge base in the vertical field corresponding to the target dialogue scenario.
[0155] Execute the knowledge matching logic, and first retrieve the target knowledge that is compatible with the target query intent in the dedicated knowledge base. If the target knowledge is not retrieved in the dedicated knowledge base, retrieve the target knowledge that is compatible with the target query intent 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. In the process of retrieving target knowledge adapted to the target query intention from the general knowledge base, the processor 51 is also used to:
[0157] According to the application domain to which the target dialogue scenario belongs and the application domains corresponding to the multiple sub-knowledge bases, identifying available sub-knowledge bases and disabled sub-knowledge bases from the multiple sub-knowledge bases;
[0158] According to the target query intent, a search is performed in the available sub-knowledge base to obtain the target knowledge that is adapted to the target query intent.
[0159] In an optional embodiment, the question-answer generation logic in the target dialogue scenario also includes content format constraints corresponding to the knowledge rewriting logic, and the content format constraints include the style, tone and word count required for the reply content, and keyword highlighting conditions. In 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 also used to:
[0160] Execute the knowledge rewriting logic to rewrite the target knowledge in terms of content and format according to the style, tone and word count in the content format constraints to obtain rewritten content, and identify the keywords in the rewritten content that are adapted to the target question according to the keyword highlighting conditions in the content format constraints, and configure highlighting attribute information for the keywords to obtain reply content for 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 calling 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 relevance, target historical questions with relevance higher than a preset relevance value are selected from the historical questions input by the target user;
[0164] The target historical questions and the historical response content corresponding to the target historical questions are added to the model call request, so that the target large model can use the target historical questions and historical response content to assist in understanding the target inquiry intention.
[0165] In an optional embodiment, there are multiple target big models, each target big model is associated with a different weight value in different dialogue scenarios, and in the process of calling the target big model according to the model calling request, and executing the question and answer generation logic in the target dialogue scenario according to the role setting and the target inquiry intention associated with the target dialogue example to generate the reply content of the target question, the processor 51 is further used to:
[0166] According to the weight value associated with each target big model in the target dialogue scenario, the target big model with the largest current weight value is selected from multiple target big models as the main target big model;
[0167] The main target big model is called according to the model call request to execute the question and answer 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 response content of the target question.
[0168] In an optional embodiment, the processor 51 is further configured to:
[0169] In the process of question-answering using the main target large model, a detection signal is periodically sent to the main target large model;
[0170] Receiving a response signal returned by the main target large model in response to the detection information;
[0171] Calculate the waiting time from sending a detection signal to receiving a response signal;
[0172] If the waiting time is longer than the preset time, the target model with the highest weight value in the target dialogue scenario is selected from other target models that have not handled the target problem as the backup target model;
[0173] The historical question and answer records generated by the primary target big model for the target user are synchronized to the backup target big model, so that the backup target big model can be used to reply to the target user instead of the primary target big model.
[0174] In an optional embodiment, the processor 51 is further configured to:
[0175] When the backup target big model is used to respond to the target user instead of the main target big model, a weight value corresponding to the main target big model in the target dialogue scenario and a weight value corresponding to the backup target big model in the target dialogue scenario are obtained;
[0176] The weight value corresponding to the main target big model in the target dialogue scenario and / or the weight value corresponding to the backup target big model in the target dialogue scenario are adjusted so that the weight value corresponding to the backup target big model in the target dialogue scenario is higher than the weight value corresponding to the main target big model in the target dialogue scenario, so that the backup target big model is used preferentially in the target dialogue scenario.
[0177] In an optional embodiment, in the process of adding the target inquiry intention and the target dialogue example to the model call request, the processor 51 is further configured to:
[0178] Matching is performed in the local knowledge base according to the target query intent, and the local knowledge base stores existing questions, query intents corresponding to existing questions, and corresponding existing responses;
[0179] If no response content matching the target query intent is found in the local knowledge base, the target query intent and target dialogue example are added to the model call request;
[0180] The processor 51 is further configured to:
[0181] When the target large model outputs the response content, the target question, target inquiry intent and response content are jointly added to the local knowledge base to enrich the local knowledge base.
[0182] Further, if Figure 5 As shown, the computing device also includes: a display 53, a power component 54, an audio component 55 and other components. Figure 5 Only some components are shown schematically, and it does not mean that the computing device only includes Figure 5 Components shown.
[0183] It is worth noting that the technical details in the above-mentioned embodiments of the computing device can refer to the relevant descriptions of the actions of the computing device in the aforementioned embodiments of the question-and-answer method. In order to save space, they will not be repeated here, but this should not cause a loss in the scope of protection of the present application.
[0184] The embodiment of the present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps in the above-mentioned question-and-answer method can be implemented. It should be noted that the technical solution of the computer program and the technical solution of the above-mentioned question-and-answer method belong to the same concept, and the details of the technical solution of the computer program that are not described in detail can be found in the description of the technical solution of the above-mentioned question-and-answer method.
[0185] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which, when executed, can implement the steps that can be executed by a computing device in the above method embodiment.
[0186] Above Figure 5 The memory in the computer 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 disk or optical disk.
[0187] Above Figure 5 The communication component in is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, 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 also 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] Above Figure 5 The display in the embodiment includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
[0189] Above Figure 5 The power supply component in the device provides power to various components of the device where the power supply component is located. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device where the power supply component is located.
[0190] Above Figure 5The audio component in can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting an audio signal.
[0191] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0192] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0193] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0194] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[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-answering method, characterized in that: Applicable to the server, including: Obtaining a target question input by a target user and structured prompt information pre-configured for a target macromodel, wherein the structured prompt information includes a plurality of 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 characterize the role played by the target macromodel in the dialogue scenario, and the question-and-answer generation logic is used to describe the execution logic of the target macromodel generating a reply content for the target question in the dialogue scenario; Extracting target keywords related to the dialogue scenario from the target question, and determining a target dialogue scenario that matches the target question based on the target keywords and multiple dialogue scenarios included in the structured prompt information and scenario description words associated with each dialogue scenario; Based on the target dialogue scenario, multiple dialogue examples in the structured prompt information are screened to obtain a target dialogue example adapted to the target dialogue scenario; Using the intention recognition model to perform intention recognition on the target question to obtain the target inquiry intention corresponding to the target question; In the case where the target query intention is adapted to the target large model, adding the target query intention and the target dialogue example to the model call request; Calling the target big model according to the model calling 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; The reply content output by the target large model is sent to the target user to answer the target question.
2. The method according to claim 1, characterized in that The intent recognition model is used to recognize the intent of the target question to obtain the target inquiry intent corresponding to the target question, including: Using the intention recognition model to recognize the intention of the target question, and obtain the initial inquiry intention; Based on a preset mapping relationship between intent and slot, obtaining at least one slot corresponding to the initial query intent; For any slot, if the target question does not include slot information corresponding to the slot, obtaining 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 problem based on the acquired slot information; The intent recognition model is used to perform intent recognition on the rewritten target question to obtain the target inquiry intent.
3. The method according to claim 1, characterized in that The question-answer generation logic in the target dialogue scenario includes intention understanding logic, knowledge matching logic, and knowledge rewriting logic in sequence; calling the target big model according to the model call request to execute the question-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, including: Inputting the model call request into the target big model, executing the intent understanding logic to understand the target inquiry intent according to the role setting associated with the target dialogue example; Executing the knowledge matching logic to retrieve target knowledge adapted to the target query intention from an external knowledge base associated with the target macro model, wherein the external knowledge base stores various knowledge information; Execute the knowledge rewriting logic to rewrite the target knowledge to obtain the response content corresponding to the target question.
4. The method according to claim 3, characterized in that The question-answer generation logic in the target dialogue scenario also includes a knowledge base constraint corresponding to the knowledge matching logic, and the knowledge base constraint is used to limit the external knowledge base associated with the target large model; Executing the knowledge matching logic to retrieve target knowledge adapted to the target query intent in the external knowledge base associated with the target big model includes: According to the knowledge base constraint condition, 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, and the dedicated knowledge base is a knowledge base in the vertical field corresponding to the target dialogue scenario; The knowledge matching logic is executed to preferentially retrieve target knowledge that matches the target query intent from the dedicated knowledge base; if the target knowledge is not retrieved from the dedicated knowledge base, the target knowledge that matches the target query intent is retrieved from the general knowledge base.
5. The method according to claim 4, characterized in that The general knowledge base includes a plurality of sub-knowledge bases, and different sub-knowledge bases correspond to different application fields. Then, the target knowledge adapted to the target query intention is retrieved from the general knowledge base, including: According to the application field to which the target dialogue scenario belongs and the application fields corresponding to the multiple sub-knowledge bases, identifying available sub-knowledge bases and disabled sub-knowledge bases from the multiple sub-knowledge bases; According to the target query intention, a search is performed in the available sub-knowledge base to obtain target knowledge that is adapted to the target query intention.
6. The method according to claim 3, characterized in that The question-answer generation logic in the target dialogue scenario also includes content format constraints corresponding to the knowledge rewriting logic, and the content format constraints include style, tone and word count required for the reply content, and keyword highlighting conditions; Executing the knowledge rewriting logic to rewrite the target knowledge to obtain the response content corresponding to the target question, including: Executing the knowledge rewriting logic to rewrite the target knowledge in terms of content and format according to the style, tone and word count in the content format constraint conditions to obtain rewritten content, and identifying 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 configuring highlighting attribute information for the keywords to obtain reply content to the target question; The highlight attribute information is used to highlight keywords in the reply content when displaying the reply content.
7. The method according to claim 1, characterized in that Before calling the target large model according to the model calling request, the method further includes: Calculating the correlation between the target question and the historical questions input by the target user; Based on the relevance, selecting a target historical question with a relevance higher than a preset relevance value from the historical questions input by the target user; The target historical questions and the historical reply contents corresponding to the target historical questions are added to the model call request, so that the target big model can use the target historical questions and the historical reply contents to assist in understanding the target inquiry intention.
8. The method according to claim 1, characterized in that: There are multiple target big models, each of which is associated with different weight values in different dialogue scenarios. The target big model is called 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, including: According to the weight value associated with each target macro model in the target dialogue scenario, a target macro model with the largest current weight value is selected from multiple target macro models as a main target macro model; The main target big model is called according to the model calling 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.
9. The method according to claim 8, characterized in that The method further comprises: In the process of using the main target large model to conduct question and answer, regularly sending a detection signal to the main target large model; receiving a response signal returned by the main target large model in response to the detection information; Calculate the waiting time from sending the detection signal to receiving the response signal; If the waiting time is longer than the preset time, the target big model with the highest weight value in the target dialogue scenario is selected from other target big models that have not processed the target problem as a backup target big model; The historical question and answer records generated by the primary target big model for the target user are synchronized to the backup target big model, so that the backup target big model is used to reply to the target user instead of the primary target big model.
10. The method according to claim 9, characterized in that Also includes: In the case where the backup target big model is used to reply to the target user instead of the main target big model, a weight value corresponding to the main target big model in the target dialogue scenario and a weight value corresponding to the backup target big model in the target dialogue scenario are obtained; The weight value corresponding to the main target big model in the target dialogue scenario and / or the weight value corresponding to the backup target big model in the target dialogue scenario are adjusted so that the weight value corresponding to the backup target big model in the target dialogue scenario is higher than the weight value corresponding to the main target big model in the target dialogue scenario, so that the backup target big model is used preferentially in the target dialogue scenario.
11. The method according to any one of claims 1 to 10, characterized in that: Add the target query intent and the target dialogue example to the model call request, including: Matching is performed in a local knowledge base according to the target inquiry intent, wherein the local knowledge base stores existing questions, inquiry intents corresponding to the existing questions, and corresponding existing reply contents; If no response content matching the target query intent is matched in the local knowledge base, the target query intent and the target dialogue example are added to the model call request; The method further comprises: In the case where the target big 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.
12. A question-answering system, characterized in that: Includes client, server and target large model; The client is used to obtain a target question input by a 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; Extracting target keywords related to the dialogue scenario from the target question, and determining a target dialogue scenario that matches the target question based on the target keywords and multiple dialogue scenarios included in the structured prompt information and scenario description words associated with each dialogue scenario; Based on the target dialogue scenario, multiple dialogue examples in the structured prompt information are screened to obtain a target dialogue example adapted to the target dialogue scenario; Using the intention recognition model to perform intention recognition on the target question to obtain the target inquiry intention corresponding to the target question; In the case where the target query intention is adapted to the target large model, adding the target query intention and the target dialogue example to the model call request; Calling the target large model according to the model calling request; The structured prompt information includes a plurality of dialogue examples, each of which is associated with a dialogue scenario and a role setting, each of which 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 characterize the role played by the target macromodel in the dialogue scenario, and the question-and-answer generation logic is used to describe the execution logic of the target macromodel generating a reply content for the target question in the dialogue scenario; The target big model is used to execute the question-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; and provide the reply content to the server; The server is further configured 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.
13. A question-answering device, characterized in that: It includes data interaction module, sample screening module, intent recognition module and model calling 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 dialogue scenario from the target question, and determine the target dialogue scenario that is compatible with the target question based on multiple dialogue scenarios contained in the structured prompt information pre-configured for the target macro model, the scenario description words associated with each dialogue scenario, and the target keywords; Based on the target dialogue scenario, multiple dialogue examples in the structured prompt information are screened to obtain a target dialogue example adapted to the target dialogue scenario; The structured prompt information includes a plurality of dialogue examples, each of which is associated with a dialogue scenario and a role setting, each of which 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 characterize the role played by the target macromodel in the dialogue scenario, and the question-and-answer generation logic is used to describe the execution logic of the target macromodel generating a reply content for the target question in the dialogue scenario; The intention recognition module is used to use the intention recognition model to perform intention recognition on the target question to obtain the target inquiry intention corresponding to the target question; The model calling module is used to add the target inquiry intention and the target dialogue example to the model calling request when the target inquiry intention is adapted to the target big model; call the target big model according to the model calling 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; The data interaction module is also used to send the reply content output by the target large model to the target user to answer the target question.
14. A computing device, characterized in that Includes memory, processor, and communication components; 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-answering method according to any one of claims 1-11.
15. 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-answering method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Question and answer information processing method and device, commodity information display method and device and storage medium
CN113869969A
Information processing method and device based on large language model, equipment and storage medium
CN117521675A
Content recall intelligent rearrangement method for large model questions and answers
CN117851583A
Method for retrieving multi-turn dialogue, storage medium, and electronic device
US20210311979A1
Intent recognition method and apparatus, and device and readable storage medium
WO2024093403A1