Artificial intelligence-based question and answer method and device, computer device and medium
By calculating the similarity between user questions and preset questions, non-preset questions are identified and filtered in the indexing platform. A trained question-and-answer scoring model is used for scoring and ranking, which solves the problem of insufficient flexibility in question-and-answer for task-oriented robots and improves the user experience.
Patent Information
- Application Number
- CN202210950989.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-09
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2042-08-09
AI Technical Summary
Existing task-oriented chatbots have low question-answering flexibility and cannot effectively handle non-preset questions raised by users, resulting in a reduced user experience.
By calculating the similarity between the user's question and the preset questions, if the similarity does not meet the conditions, the question is determined to be a non-preset question. Multiple initial question-and-answer sets are then selected from the preset indexing platform. The trained question-and-answer scoring model is used to score and rank the questions to determine the target question to answer the user's question.
This improves the flexibility and user experience of task-oriented chatbots during the question-and-answer process, ensuring accurate responses to non-preset questions.
Smart Images

Figure CN115292465B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application is suitable for the field of artificial intelligence, and particularly relates to a question and answer method and device based on artificial intelligence, a computer device and a medium. BACKGROUND
[0002] Task-based robots refer to robots that provide information or services under specific conditions, and need to help users clarify the purpose through inquiry and dialogue. The task-based robots in the industry are based on the mechanism of finite state machines, modeling the dialogue as a path of tree or graph structure. The modeling is simple and can clearly and clearly match the interaction to the model. However, this method defines the dialogue process by human, and the expression ability is limited. When the user's question does not match the preset question, the task-based robot directly ignores the question raised by the user, greatly reducing the flexibility in the question and answer process and reducing the user experience.
[0003] Therefore, in the field of artificial intelligence, how to improve the question and answer flexibility of task-based robots has become a problem to be solved. SUMMARY
[0004] Therefore, the embodiments of the present application provide a question and answer method and device based on artificial intelligence, a computer device and a medium to solve the problem of low flexibility of the existing task-based robots.
[0005] In a first aspect, the embodiments of the present application provide a question and answer method based on artificial intelligence, which comprises:
[0006] Obtaining a user question, calculating the similarity of the user question and each preset question, judging whether the similarity meets a preset condition, and if the similarity meets the preset condition, determining the user question as a non-pre-set question;
[0007] Inputting the non-pre-set question into a preset index platform, and selecting N groups of initial questions and answers from the index platform, wherein each group of initial questions and answers includes an initial question and an initial answer corresponding thereto, and N is an integer greater than 1;
[0008] Inputting each initial question and the non-pre-set question into a trained question and answer scoring model to determine the question and answer score of each initial question;
[0009] According to the question and answer score of the N initial questions, the N initial questions are sorted, the target question consistent with the non-pre-set question is determined according to the sorting result, and the user question is replied according to the initial answer corresponding to the target question.
[0010] In a second aspect, the embodiments of the present application provide a question and answer device based on artificial intelligence, which comprises:
[0011] The category determining module is configured to obtain a user question, calculate a similarity between the user question and each preset question, determine whether the similarity satisfies a preset condition, and determine the user question as a non-pre-set question if the similarity satisfies the preset condition.
[0012] The question and answer screening module is configured to input the non-pre-set question into a preset index platform and select N groups of initial questions and answers from the index platform, wherein each group of the initial questions and answers comprises an initial question and a corresponding initial answer, and N is an integer greater than 1.
[0013] The question and answer scoring module is configured to input each initial question and the non-pre-set question into a trained question and answer scoring model and determine a question and answer score of each initial question.
[0014] The question reply module is configured to sort N initial questions according to the question and answer scores of the N initial questions, determine a target question consistent with the non-pre-set question according to a sorting result, and reply to the user question according to the target question and the corresponding initial answer.
[0015] In a third aspect, an embodiment of the present application provides a computer device, which comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor implements the question and answer method according to the first aspect when executing the computer program.
[0016] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executable on a processor to implement the question and answer method according to the first aspect.
[0017] Compared with the prior art, the embodiment of the present application has the beneficial effects that: by calculating the similarity between the user question and each preset question, determining the user question as a non-pre-set question if the similarity satisfies a preset condition, inputting the non-pre-set question into a preset index platform, selecting N groups of initial questions and answers from the index platform, inputting each initial question and the non-pre-set question into a trained question and answer scoring model, determining the question and answer score of each initial question, sorting N initial questions according to the question and answer scores of the N initial questions, and finally determining a target question consistent with the non-pre-set question according to a sorting result, the user question is replied to according to the target question and the corresponding initial answer. By comparing and matching the non-pre-set question with index questions in the preset index platform when the user question is a non-pre-set question, the non-pre-set question is replied to, the question and answer interaction between the user and the task-oriented robot is completed, the flexibility of the task-oriented robot in the question and answer process is greatly improved, and the user experience is improved. BRIEF DESCRIPTION OF DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description only some of the embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.
[0019] Figure 1 is an application environment schematic diagram of a question and answer method provided by the embodiment one of the present application;
[0020] Figure 2 is a flow schematic diagram of a question and answer method provided by the embodiment one of the present application;
[0021] Figure 3 is a structure schematic diagram of a question and answer device provided by the embodiment two of the present application;
[0022] Figure 4 is a structure schematic diagram of a computer device provided by the embodiment three of the present application. DETAILED DESCRIPTION
[0023] In the following description, for the purpose of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
[0024] It should be understood that the term "comprising" as used in the specification and the appended claims indicates the presence of the recited features, integers, steps, operations, elements, and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0025] It should also be understood that the term "and / or" as used herein refers to any one of the associated listed items, combinations of one or more of the associated listed items, and all possible combinations thereof.
[0026] As used in the specification and the appended claims, the term "if' can be interpreted as meaning "when" or "once" or "in response to a determination" or "in response to a detection" depending on the context. Similarly, the phrase "if determined" or "if detected [the described condition or event]" can be interpreted to mean "once determined" or "in response to a determination" or "once detected [the described condition or event]" or "in response to a detection [the described condition or event]" depending on the context.
[0027] In addition, in the description of the present application and the appended claims, the terms "first", "second", "third", etc. are used only to distinguish descriptions and cannot be understood as indicating or implying relative importance.
[0028] In the present application, the reference to "one embodiment" or "some embodiments" and the like means that the particular feature, structure or characteristic described in connection with this embodiment is included in at least one embodiment of the present application. Thus, the appearance of the phrases "in one embodiment", "in some embodiments", "in other embodiments", "in additional embodiments" and the like in various places in the specification is not necessarily all referring to the same embodiment, but means "one or more but not all embodiments", unless otherwise specifically stated. The terms "comprise", "include", "have" and their conjugates mean "including but not limited to", unless otherwise specifically stated.
[0029] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) is the use of digital computers or computer-controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0030] The basic technology of artificial intelligence generally includes technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. The software technology of artificial intelligence mainly includes computer vision technology, robot technology, biometric technology, speech processing technology, natural language processing technology, and machine learning / deep learning, etc.
[0031] It should be understood that the size of the serial number of each step in the following embodiments does not mean the order of execution, and the execution order of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0032] In order to illustrate the technical solutions of the present application, the following will be described by specific embodiments.
[0033] The question and answer method provided by the embodiment of the present application can be applied to, for example Figure 1The application environment is a client-server application environment, wherein the client communicates with the server. The client includes, but is not limited to, a palmtop computer, a desktop computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cloud computer device, a personal digital assistant (PDA), and the like. The server can be implemented by a single server or a server cluster composed of multiple servers.
[0034] Referring to Figure 2 is a flowchart of a question and answer method provided by an embodiment of the present application. The question and answer method can be applied to a client in Figure 1 The question and answer method can include the following steps.
[0035] In step S201, a user question is obtained, the similarity between the user question and each preset question is calculated, and it is determined whether the similarity satisfies a preset condition. If the similarity satisfies the preset condition, the user question is determined to be a non-pre-set question.
[0036] The user question is a question asked by a user to a task-oriented robot in a question and answer interaction process between the user and the task-oriented robot. The user question is obtained in different ways when the question and answer interaction form between the user and the task-oriented robot is different. For example, when the question and answer interaction between the user and the task-oriented robot is a text question and answer interaction, a question input by the user is obtained as the user question. When the question and answer interaction between the user and the task-oriented robot is a voice question and answer interaction, a voice of a question asked by the user is obtained, and the voice is converted into text according to voice recognition technology to obtain the user question in the form of text.
[0037] The preset question is a question pre-set for the task-oriented robot. For example, a question of “consulting detailed information of an insurance policy” is used to reply to a corresponding user question according to a preset answer corresponding to the preset question when it is determined that the user question is similar to the preset question, so as to complete the question and answer interaction between the user and the task-oriented robot.
[0038] Therefore, in the question and answer interaction process between the user and the task-oriented robot, the similarity between the user question and each preset question is first calculated, and it is determined whether the similarity satisfies a preset condition, that is, it is determined whether the user question is similar to each preset question according to the similarity. When the user question is not similar to each preset question, it is indicated that the user question is not related to the question pre-set for the task-oriented robot, and the user question cannot be replied according to the preset answer corresponding to the preset question. Therefore, when the similarity satisfies the preset condition, the corresponding user question is determined to be a non-pre-set question.
[0039] Optionally, the similarity between the user question and each preset question is calculated, including:
[0040] convert the user question into a user question vector according to the word vector technology, and convert each preset question into a preset question vector according to the word vector technology;
[0041] calculate a vector similarity between the user question vector and each preset question vector as a similarity between the user question and each preset question.
[0042] The user question and each preset question are in a text form, and therefore, before calculating the similarity between the user question and each preset question, the user question is first converted into a user question vector and each preset question is converted into a preset question vector according to the word vector technology, and then a vector similarity between the user question vector and each preset question vector is calculated as the similarity between the user question and each preset question.
[0043] Optionally, it is determined whether the similarity satisfies a preset condition, and if the similarity satisfies the preset condition, the user question is determined as a non-pre-set question, including:
[0044] determining a maximum similarity from the similarity between the user question and each preset question;
[0045] comparing the maximum similarity with a similarity threshold, and if the maximum similarity is not greater than the similarity threshold, the user question is determined as a non-pre-set question.
[0046] The smaller the similarity between the user question and the preset question is, the lower the accuracy of replying to the user question according to the preset answer corresponding to the preset question is.
[0047] Therefore, a maximum similarity is first determined from the similarity between the user question and each preset question, and the maximum similarity is compared with a similarity threshold, and if the maximum similarity is not greater than the similarity threshold, it indicates that the accuracy of replying to the user question according to the preset answer of any preset question is low, and therefore, the user question is determined as a non-pre-set question, i.e., a question that cannot be replied to according to the preset answer in the task-based robot. The similarity threshold can be set according to actual conditions, and in this embodiment, the similarity threshold is set to 0.8 according to actual conditions to improve the accuracy of replying to the user question.
[0048] Optionally, the question and answer method further includes:
[0049] if the maximum similarity is greater than the similarity threshold, determining the preset question corresponding to the maximum similarity as a target preset question;
[0050] obtaining a target preset answer of the target preset question, and replying to the user question according to the target preset answer.
[0051] The greater the similarity between the user question and the preset question, the higher the accuracy of the user question being replied to according to the preset answer corresponding to the preset question.
[0052] Therefore, if the maximum similarity is greater than the similarity threshold, it indicates that the accuracy of the user question being replied to according to the preset answer corresponding to the maximum similarity is relatively high. In view of the efficiency of the task-based robot and the user in the question and answer interaction, the maximum similarity corresponding to the preset question can be selected as the target preset question, the target preset answer of the target preset question is obtained, and the user question is replied to according to the target preset answer, so as to ensure that the accuracy of the task-based robot in replying to the user question is relatively high, and improve the efficiency of the task-based robot and the user in the question and answer interaction.
[0053] For example, the user question vector is denoted as H, the number of preset questions is denoted as L, and the preset question vector of the i th (i = 1, 2,..., L) preset question is denoted as Y i The cosine similarity between the user question vector H and the i th preset question vector Y i is calculated as the vector similarity between the user question vector H and the i th preset question vector Y i , and the vector similarity S i between the user question vector H and the i th preset question vector Y i is:
[0054]
[0055] In the formula, H is the user question vector, Y i is the preset question vector of the i th preset question.
[0056] The vector similarity S i between the user question vector H and the i th preset question vector Y i is taken as the similarity S i ' between the user question and the i th preset question, and the similarities S1', S2',..., SL' between the user question and the first, second,..., L th preset questions are determined according to the similarities S1', S2',..., SL' between the user question and the first, second,..., L th preset questions. L The maximum similarity in the similarities S1', S2',..., SL' is determined by size comparison, and the maximum similarity is denoted as S0'. L
[0057] Secondly, the preset similarity threshold is denoted as S0, and the similarity threshold S0 = 0.8 is set according to the actual situation.
[0058] Then, the maximum similarity S0' is compared with a preset similarity threshold S0, if S0'≤S0, the user question is determined as a non-pre-set question, if S0'>S0, the preset question corresponding to the maximum similarity is determined as a target preset question, and the target preset answer of the target preset question is obtained to reply the user question according to the target preset answer, so as to complete the question and answer interaction between the user and the task robot.
[0059] In step S202, the non-pre-set question is input into a preset index platform, and N groups of initial questions and answers are selected from the index platform, wherein each group of initial questions and answers includes an initial question and an initial answer corresponding thereto, and N is an integer greater than 1.
[0060] The preset index platform contains a large amount of commonly used question and answer information, which can be obtained by collecting a large amount of commonly used question and answer information and storing the collected question and answer information in the index platform, wherein the index platform includes a plurality of groups of index questions and answers, and each group of index questions and answers includes an index question and an index answer corresponding thereto.
[0061] Therefore, after the non-pre-set question is input into the preset index platform, the non-pre-set question and each index question are matched to screen N groups of index questions and answers in the index platform that meet the matching rule as initial questions and answers, and correspondingly, each group of initial questions and answers includes an initial question and an initial answer corresponding thereto. N is an integer greater than 1.
[0062] Optionally, the non-pre-set question is input into the preset index platform, and N groups of initial questions and answers are selected from the index platform, including:
[0063] The index platform includes a plurality of groups of index questions and answers, and each group of index questions and answers includes an index question and an index answer corresponding thereto.
[0064] The problem keywords of the non-pre-set question are extracted according to a keyword extraction algorithm, and the index keywords of each index question are extracted according to the keyword extraction algorithm.
[0065] The problem keywords and the index keywords are compared, and N index questions and N index questions and answers corresponding thereto that meet a preset comparison condition are selected as N groups of initial questions and answers.
[0066] The non-pre-set question and the index question can be a question phrase, a question sentence or a question segment, and the non-pre-set question and the index question include auxiliary words and keywords that constitute a question text, wherein the keywords are the key content for question matching, and the auxiliary words interfere with the accuracy of question matching.
[0067] Therefore, firstly, the problem keyword of the non-pre-set question and the index keyword of each index question are extracted according to the keyword extraction algorithm, and the matching degree of the problem keyword and each index keyword is determined by comparing the problem keyword and each index keyword. When the matching degree of the problem keyword and a certain index keyword meets the preset comparison condition, the corresponding non-pre-set question and index question are matched, and the corresponding index question and the corresponding index question and answer are taken as the initial question and answer, so as to select N groups of initial question and answer from the index platform as the reply basis of the user question.
[0068] Optionally, the problem keyword and the index keyword are compared, and N index questions and corresponding N index question and answers meeting the preset comparison condition are taken as N groups of initial question and answer, which comprises:
[0069] The problem keyword is converted into a problem keyword vector according to the word vector technology, and each index keyword is converted into an index keyword vector according to the word vector technology;
[0070] The keyword similarity between the problem keyword vector and each index keyword vector is calculated as the matching degree of the problem keyword and each index keyword;
[0071] The matching degree is compared with the preset matching degree threshold value, and when the matching degree is greater than the preset matching degree threshold value, the non-pre-set question and the index question corresponding to the matching degree are matched;
[0072] The index question and the corresponding index question and answer matched with the non-pre-set question are determined as the initial question and answer.
[0073] The problem keyword and each index keyword are in text form, so when the matching degree of the problem keyword and each index keyword is calculated, the problem keyword is first converted into a problem keyword vector according to the word vector technology, and each index keyword is converted into an index keyword vector, then the keyword similarity between the problem keyword vector and each index keyword vector is calculated, the greater the keyword similarity, the higher the matching degree between the keyword vector and the corresponding index keyword vector, so the keyword similarity between the problem keyword vector and each index keyword vector is taken as the matching degree of the problem keyword and the corresponding index keyword.
[0074] Then, the matching degree is compared with the preset matching degree threshold value, and when the matching degree is greater than the preset matching degree threshold value, the non-pre-set question and the index question corresponding to the matching degree are matched, so that N groups of index questions and corresponding N index question and answers matched with the non-pre-set question are determined from the index platform as N groups of initial question and answer.
[0075] For example, let the keyword vector be P, the number of index problems be M, and the jth (j = 1, 2,..., M) index keyword vector be Q j The cosine similarity between the keyword vector P and the jth index keyword vector Q is calculated j The keyword similarity X between the keyword vector P and the jth index keyword vector Q is calculated j The keyword similarity X between the keyword vector P and the jth index keyword vector Q is calculated j The keyword similarity X between the keyword vector P and the jth index keyword vector Q is calculated j is:
[0076]
[0077] In the formula, P is the keyword vector, and Q j is the index keyword vector of the jth index problem.
[0078] The keyword similarity X between the keyword vector P and the jth index keyword vector Q is calculated j The keyword similarity X between the keyword vector P and the jth index keyword vector Q is calculated j The keyword similarity X between the keyword vector P and the jth index keyword vector Q is calculated j The keyword similarity X between the keyword vector P and the jth index keyword vector Q is calculated M .
[0079] Secondly, a preset matching degree threshold is denoted as X0, and the similarity threshold X0 = 0.7 is set according to the actual situation.
[0080] Then, the M matching degrees X1', X2',..., X M ' are compared with the preset matching degree threshold X0 respectively, and when X j >X0, it is determined that the matching degree X j corresponding to the jth index problem matches the non-pre-set problem, and N groups of index problems matching the non-pre-set problem are determined from the index platform, and N groups of initial questions and answers are determined in combination with the corresponding N groups of index questions and answers.
[0081] In step S203, each initial question and the non-pre-set question are input into the trained question and answer scoring model to determine the question and answer score of each initial question.
[0082] Each group of initial questions and answers includes an initial question and a corresponding initial answer. In order to ensure the efficiency of the question and answer interaction between the task-oriented robot and the user while improving the reply accuracy of the task-oriented robot to the user's question, the question and answer score of each initial question obtained by keyword matching from the index platform is further determined.
[0083] Specifically, the initial question and the non-pre-set question are input into the trained question and answer scoring model, and feature extraction is performed on the initial question and the non-pre-set question to obtain a question and answer score of each initial question, which is used to represent a matching score of each initial question and the non-pre-set question.
[0084] Optionally, the question and answer scoring model includes an encoder and a fully connected layer, and the initial question and the non-pre-set question are used as training samples, and the actual question and answer score of the training sample is used as a training label to train the question and answer scoring model and determine the parameters of the question and answer scoring model.
[0085] The training sample is a large number of initial questions and non-pre-set questions, and the training label is the actual question and answer score of the training sample. The actual question and answer score is obtained by manually matching and measuring the initial question and the non-pre-set question, and is used to evaluate the question and answer score obtained by the question and answer scoring model, so that the question and answer scoring model can be trained according to the evaluation result to obtain the trained question and answer scoring model.
[0086] Optionally, the training process of the question and answer scoring model includes:
[0087] The initial question and the non-pre-set question of the training sample are input into the encoder for feature extraction to obtain question matching features,
[0088] The question matching features are input into the fully connected layer to obtain a sample question and answer score.
[0089] The loss function is calculated according to the sample question and answer score and the corresponding actual question and answer score, and the parameters of the encoder and the fully connected layer are corrected in reverse according to the gradient descent method until the loss function converges, thereby obtaining the trained question and answer scoring model.
[0090] During the training process of the question and answer scoring model, the initial question and the non-pre-set question of the training sample are first input into the encoder for feature extraction to obtain question matching features, which are feature vectors used to measure the matching degree between the input initial question and the non-pre-set question. Then, the question matching features are input into the fully connected layer to obtain a sample question and answer score. Then, the loss function is calculated according to the sample question and answer score and the corresponding actual question and answer score. When the loss function is small, it indicates that the difference between the sample question and answer score obtained according to the question and answer scoring model and the actual question and answer score is small, indicating that the accuracy of the question and answer scoring model is high. On the contrary, when the loss function is large, it indicates that the difference between the sample question and answer score obtained according to the question and answer scoring model and the actual question and answer score is large, indicating that the accuracy of the question and answer scoring model is low. Therefore, the parameters of the encoder and the fully connected layer are corrected in reverse according to the gradient descent method until the loss function converges, thereby obtaining the trained question and answer scoring model to improve the accuracy of the question and answer scoring model.
[0091] Step S204, according to the size of the question and answer score of the N initial questions, the N initial questions are sorted, and the target question consistent with the non-pre-set question is determined according to the sorting result, and the initial answer corresponding to the target question is used to reply to the user question.
[0092] Wherein, the question and answer score of each initial question is obtained by the trained question and answer scoring model, and the greater the question and answer score is, the greater the degree of matching between the corresponding initial question and the non-pre-set question is.
[0093] Therefore, according to the size of the question and answer score of the N initial questions, the N initial questions are sorted, and then according to the sorting result, one target question consistent with the non-pre-set question is determined, and then the initial answer corresponding to the target question is used to reply to the user question, so as to complete the question and answer interaction between the user and the task robot in the case of the user question being a non-pre-set question, improve the flexibility of the task robot in the question and answer process, and improve the user experience.
[0094] For example, after obtaining the question and answer scores of the N initial questions, the N initial questions are sorted in descending order of the question and answer scores, and the initial question with a higher ranking indicates a greater degree of matching with the non-pre-set question.
[0095] Therefore, the initial question ranked first is determined as the target question, and then the initial answer corresponding to the target question is determined, so that the corresponding initial answer can be used to reply to the user question and complete the question and answer interaction between the user and the task robot.
[0096] For example, after obtaining the question and answer scores of the N initial questions, the N initial questions are sorted in ascending order of the question and answer scores, and the initial question with a lower ranking indicates a greater degree of matching with the non-pre-set question.
[0097] Therefore, the initial question ranked last is determined as the target question, and then the initial answer corresponding to the target question is determined, so that the corresponding initial answer can be used to reply to the user question and complete the question and answer interaction between the user and the task robot.
[0098] The embodiment of the application determines the user question as a non-pre-set question if the similarity meets the pre-set condition, inputs the non-pre-set question into the pre-set index platform, selects N groups of initial questions and answers from the index platform, inputs each initial question and the non-pre-set question into the trained question and answer scoring model, determines the question and answer scoring of each initial question, sorts the N initial questions according to the question and answer scoring, finally determines the target question consistent with the non-pre-set question according to the sorting result, and replies to the user question according to the initial answer corresponding to the target question. When the user question is a non-pre-set question, the non-pre-set question is compared and matched with the index questions in the pre-set index platform in a series of operations to reply to the non-pre-set question, so as to complete the question and answer interaction between the user and the task-oriented robot, greatly improves the flexibility of the task-oriented robot in the question and answer process, and improves the experience of the user.
[0099] The question and answer method corresponding to the above embodiment, Figure 3 The structure block diagram of the question and answer device provided by the second embodiment of the application is given, only the parts related to the embodiments of the application are shown for the convenience of description.
[0100] Referring to Figure 3 The question and answer device comprises:
[0101] The category determination module 31 is configured to acquire the user question, calculate the similarity between the user question and each pre-set question, determine whether the similarity meets the pre-set condition, and determine the user question as a non-pre-set question if the similarity meets the pre-set condition.
[0102] The question and answer screening module 32 is configured to input the non-pre-set question into the pre-set index platform, and select N groups of initial questions and answers from the index platform, wherein each group of initial questions and answers comprises one initial question and one corresponding initial answer, and N is an integer greater than 1.
[0103] The question and answer scoring module 33 is configured to input each initial question and the non-pre-set question into the trained question and answer scoring model, and determine the question and answer scoring of each initial question.
[0104] The question reply module 34 is configured to sort the N initial questions according to the question and answer scoring, determine the target question consistent with the non-pre-set question according to the sorting result, and reply to the user question according to the initial answer corresponding to the target question.
[0105] Optionally, the category determination module 31 comprises:
[0106] The vector conversion submodule is configured to convert the user question into a user question vector according to the word vector technology, and convert each pre-set question into a pre-set question vector according to the word vector technology.
[0107] The similarity calculation submodule is configured to calculate vector similarities between the user question vector and each preset question vector as similarities between the user question and each preset question.
[0108] Optionally, the category determination module 31 includes:
[0109] The maximum similarity determination submodule is configured to determine a maximum similarity from the similarities between the user question and each preset question.
[0110] The first category determination submodule is configured to compare the maximum similarity with a similarity threshold, and if the maximum similarity is not greater than the similarity threshold, determine the user question as a non-pre-set question.
[0111] Optionally, the category determination module 31 includes:
[0112] The second category determination submodule is configured to, if the maximum similarity is greater than the similarity threshold, determine the preset question corresponding to the maximum similarity as a target preset question.
[0113] The first question reply submodule is configured to obtain a target preset answer of the target preset question, and reply to the user question according to the target preset answer.
[0114] Optionally, the question and answer screening module 32 includes:
[0115] The index platform determination submodule is configured to determine that the index platform includes a plurality of groups of index questions and answers, and each group of index questions and answers includes an index question and an index answer corresponding thereto.
[0116] The keyword extraction submodule is configured to extract a question keyword of the non-pre-set question according to a keyword extraction algorithm, and extract an index keyword of each index question according to the keyword extraction algorithm.
[0117] The initial question and answer determination submodule is configured to compare the question keyword and the index keyword, and determine N groups of initial questions and answers as N groups of index questions and answers corresponding thereto, if a comparison result satisfies a preset comparison condition.
[0118] Optionally, the initial question and answer determination submodule includes:
[0119] The vector conversion unit is configured to convert the question keyword into a question keyword vector according to a word vector technology, and convert each index keyword into an index keyword vector according to the word vector technology.
[0120] The similarity calculation unit is configured to calculate a keyword similarity between the question keyword vector and each index keyword vector as a matching degree between the question keyword and each index keyword.
[0121] The problem matching unit is used to compare the matching degree with a preset matching degree threshold. When the matching degree is greater than the preset matching degree threshold, the non-preset problem and the index problem corresponding to the matching degree are matched.
[0122] The initial question and answer determination unit is used to determine the index questions and corresponding index questions and answers that match the non-preset questions as the initial questions and answers.
[0123] Optionally, the above-mentioned question-and-answer scoring module 33 includes:
[0124] The model training submodule is used to determine the parameters of the question-answering scoring model, which includes an encoder and a fully connected layer. It uses initial questions and non-preset questions as training samples and the actual question-answering scores of the training samples as training labels.
[0125] Optionally, the above model training submodule includes:
[0126] The feature extraction unit is used to input the initial question and non-preset question from the training samples into the encoder for feature extraction, thereby obtaining question-matching features.
[0127] The question-answering scoring unit is used to input question matching features into the fully connected layer to obtain sample question-answering scores;
[0128] The parameter correction unit is used to calculate the loss function based on the sample question-answering scores and the corresponding actual question-answering scores, and to correct the parameters of the encoder and fully connected layer in reverse using the gradient descent method until the loss function converges, thus obtaining the trained question-answering scoring model.
[0129] It should be noted that the information interaction and execution process between the above modules are based on the same concept as the method embodiments of the present invention. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.
[0130] Figure 4 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Figure 4 As shown, the computer device of this embodiment includes: at least one processor ( Figure 4 Only one is shown in the diagram), a memory, and a computer program stored in the memory and executable on at least one processor, which, when executed by the processor, implements the steps in any of the above-described optimization method embodiments.
[0131] This computer device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that... Figure 4The computer device is only an example and does not limit the computer device. The computer device can include more or less components than shown, or combine some components, or have different components, such as a network interface, a display screen, an input device, and the like.
[0132] The processor can be a CPU, and can also be other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, and the like. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0133] The memory includes a readable storage medium, an internal memory, and the like. The internal memory can be a memory of the computer device, and provides an environment for running an operating system and computer-readable instructions in the readable storage medium. The readable storage medium can be a hard disk of the computer device, and in other embodiments, can also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, and the like. Further, the memory can include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a BootLoader, data, and other programs, such as program codes of computer programs. The memory can also be used to temporarily store data that has been output or will be output.
[0134] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of software functional unit. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the present application. The specific working process of the unit and module in the above device can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here. If the integrated unit is realized in the form of software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the present application realizes all or part of the processes in the above-mentioned embodiment methods, which can be completed by a computer program to instruct related hardware. The computer program can be stored in a computer readable storage medium, and when the processor executes the computer program, the steps of the above-mentioned method embodiment can be realized. The computer program includes computer program code, which can be in the form of source code, object code, executable file or some intermediate form, etc. The computer readable medium can at least include any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), electrical carrier signal, telecommunication signal and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, according to legislation and patent practice, the computer readable medium cannot be an electrical carrier signal and a telecommunication signal.
[0135] The present application realizes all or part of the processes in the above-mentioned embodiment methods, which can also be completed by a computer program product. When the computer program product runs on the computer device, it makes the computer device execute the steps in the above-mentioned method embodiment.
[0136] In the above-mentioned embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0137] Those skilled in the art can understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0138] In the embodiments provided by the present application, it should be understood that the disclosed apparatus / computer device and method can be implemented in other manners. For example, the described apparatus / computer device embodiments are merely schematic. For example, the division of the modules or units can be different, and each can include a plurality of sub-units. Some or all of the modules or units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.
[0139] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e. may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.
[0140] The above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. An artificial intelligence-based question and answer method, characterized by, The question and answer method comprises: Obtaining a user question, calculating the similarity of the user question and each preset question, judging whether the similarity meets a preset condition, and determining the user question as a non-pre-set question if the similarity meets the preset condition; Inputting the non-pre-set question into a preset index platform, and selecting N groups of initial questions and answers from the index platform, wherein each group of initial questions and answers comprises an initial question and a corresponding initial answer, and N is an integer greater than 1; Inputting each initial question and the non-pre-set question into a trained question and answer scoring model to determine the question and answer scoring of each initial question; According to the question and answer scoring of the N initial questions, the N initial questions are sorted, the target question consistent with the non-pre-set question is determined according to the sorting result, and the user question is replied according to the initial answer corresponding to the target question; The calculation of the similarity of the user question and each preset question comprises: Converting the user question into a user question vector according to a word vector technology, and converting each preset question into a preset question vector according to a word vector technology; Calculating the vector similarity between the user question vector and each preset question vector as the similarity of the user question and each preset question; The inputting of the non-pre-set question into the preset index platform to select N groups of initial questions and answers comprises: The index platform comprises a plurality of groups of index questions and answers, and each group of index questions and answers comprises an index question and a corresponding index answer; Extracting the question keywords of the non-pre-set question according to a keyword extraction algorithm, and extracting the index keywords of each index question according to a keyword extraction algorithm; Comparing the question keywords and the index keywords, and selecting N index questions and corresponding N index questions and answers that meet a preset comparison condition as N groups of initial questions and answers.
2. The question and answer method of claim 1, wherein, The judgment of whether the similarity meets a preset condition, and the determination of the user question as a non-pre-set question if the similarity meets the preset condition, comprises: Determining the maximum similarity from the similarity of the user question and each preset question; Comparing the maximum similarity with a similarity threshold, and determining the user question as a non-pre-set question if the maximum similarity is not greater than the similarity threshold.
3. The question answering method of claim 2, wherein, The question and answer method further comprises: If the maximum similarity is greater than the similarity threshold, determining the preset question corresponding to the maximum similarity as a target preset question; Obtaining a target preset answer of the target preset question, and replying the user question according to the target preset answer.
4. The question answering method of claim 1, wherein, The question and answer scoring model comprises an encoder and a fully connected layer, the initial question and the non-pre-set question are used as training samples, the actual question and answer scoring of the training samples is used as a training label, the question and answer scoring model is trained, and the parameters of the question and answer scoring model are determined.
5. The question answering method of claim 4, wherein, The training process of the question and answer scoring model comprises: Inputting the initial question and the non-pre-set question of the training sample into the encoder for feature extraction to obtain question matching features; inputting the question matching feature into the full connection layer to obtain a sample question and answer score; calculating a loss function according to the sample question and answer score and the actual question and answer score, and reversely correcting parameters of the encoder and the full connection layer according to a gradient descent method until the loss function converges, to obtain a trained question and answer scoring model.
6. An artificial intelligence-based question answering apparatus, characterized by comprising: The question and answer device comprises: a category determining module configured to obtain a user question, calculate a similarity between the user question and each preset question, determine whether the similarity satisfies a preset condition, and determine the user question as a non-pre-set question if the similarity satisfies the preset condition; a question and answer screening module configured to input the non-pre-set question into a preset index platform, and select N groups of initial question and answers from the index platform, wherein each group of the initial question and answer comprises an initial question and an initial answer corresponding thereto, and N is an integer greater than 1; a question and answer scoring module configured to input each initial question and the non-pre-set question into the trained question and answer scoring model, and determine a question and answer score of each initial question; a question reply module configured to sort N initial questions according to the question and answer scores of the N initial questions, determine a target question consistent with the non-pre-set question according to a sorting result, and reply to the user question according to the initial answer corresponding to the target question; The category determining module comprises: a vector conversion submodule configured to convert the user question into a user question vector according to a word vector technology, and convert each preset question into a preset question vector according to the word vector technology; a similarity calculation submodule configured to calculate a vector similarity between the user question vector and each preset question vector as the similarity between the user question and each preset question; The question and answer screening module comprises: an index platform determining submodule configured to include a plurality of groups of index question and answers in the index platform, wherein each group of the index question and answer comprises an index question and an index answer corresponding thereto; a keyword extraction submodule configured to extract a question keyword of the non-pre-set question according to a keyword extraction algorithm, and extract an index keyword of each index question according to the keyword extraction algorithm; an initial question and answer determining submodule configured to compare the question keyword and the index keyword, and select N index questions and corresponding N index question and answers satisfying a preset comparison condition as N groups of initial question and answers.
7. A computer device, comprising: The computer device comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and the processor implements the question and answer method of any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 7. The computer program is executed by the processor to implement the question and answer method of any one of claims 1 to 5.
Citation Information
Patent Citations
Question and answer matching processing method and device, question and answer matching model training method and device, equipment and storage medium
CN110442675A
Intelligent legal question-answering method and device, electronic equipment and storage medium
CN112948553A