Question and answer method, device, equipment and storage medium
Through the combination of model-based automatic generation and ranking model, the problem of missing answer information in the intelligent question and answer system when the answer information cannot be retrieved is solved, ensuring the accuracy and matching degree of the answer information, and solving the problem of missing answer information in the existing technology. question.
Patent Information
- Application Number
- CN202010613891.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-30
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-06-30
AI Technical Summary
Existing intelligent question answering systems cannot answer when matching answer information cannot be retrieved in the database, and there is a problem of missing answer information.
Use a model-based automatic generation method to obtain answer information, and call the sorting model to sort multiple answer information according to the matching degree between the answer information and the question information, and obtain the first-ranked answer information to ensure that even if the answer information cannot be retrieved The answer information can also be generated under the circumstances, and the contextual influence and the matching degree of the answer information and the question information are comprehensively considered to improve the accuracy of the answer information.
It realizes that answer information can be generated even when the answer information cannot be retrieved from the database, avoiding the lack of answer information and improving the accuracy and matching of answer information.
Smart Images

Figure CN111782767B
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing, and in particular to a question-answering method, apparatus, device and storage medium. Background Art
[0002] With the popularization of the Internet and the widespread application of natural language processing technology, intelligent question and answer functions have gradually emerged. After the user enters the question information, the intelligent question and answer function can automatically answer the user's question, thereby interacting with the user.
[0003] In the related art, after a user inputs question information, keywords in the question information are obtained, and based on the obtained keywords, answer information matching the keywords is retrieved from a database to complete the answer to the question information.
[0004] However, when matching answer information cannot be retrieved from the database, the question information cannot be answered, so the above method has limitations. Summary of the invention
[0005] This application example provides a question-answering method, device, equipment and storage medium, which improves the accuracy of the answer information obtained. The technical solution is as follows:
[0006] In one aspect, a question-answering method is provided, the method comprising:
[0007] Acquire a first question vector of first question information and a second question vector of at least one piece of second question information, wherein the at least one piece of second question information is question information acquired before the first question information;
[0008] Calling an answer generation model to obtain at least one piece of answer information according to the first question vector and at least one second question vector, wherein the answer generation model is used to generate answer information matching any question vector according to any question vector;
[0009] Searching a question-answer database according to the first question information or the first question vector;
[0010] The sorting model is called to sort the obtained multiple answer information in descending order of the matching degree with the first question information, and the answer information ranked first is determined as the target answer information.
[0011] In one possible implementation, the method further includes:
[0012] Obtaining sample question information and corresponding sample answer information, as well as sample matching degrees between the sample question information and the sample answer information;
[0013] The sorting model is trained according to the sample question information, the sample answer information and the sample matching degree to obtain a trained sorting model.
[0014] In another possible implementation, the training of the ranking model according to the sample question information, the sample answer information and the sample matching degree to obtain the trained ranking model includes:
[0015] Inputting the sample question information and the sample answer information into the ranking model to obtain the predicted matching degree between the sample question information and the sample answer information;
[0016] The sorting model is trained according to the sample matching degree and the predicted matching degree to obtain a trained sorting model.
[0017] In another possible implementation, the ranking model includes multiple matching layers, a fusion layer, and a ranking layer, and calling the ranking model to sort the multiple pieces of answer information obtained in descending order of matching degree with the first question information, and determining the answer information ranked first as the target answer information, includes:
[0018] Calling the multiple matching layers to respectively obtain a matching degree between each piece of answer information and the first question information;
[0019] Calling the fusion layer to obtain a fusion matching degree of multiple matching degrees of each answer information;
[0020] The sorting layer is called to sort the multiple pieces of answer information in descending order of fusion matching degree, and the answer information ranked first is determined as the target answer information.
[0021] In another possible implementation, the step of obtaining the first question vector of the first question information includes:
[0022] Performing word segmentation processing on the first question information to obtain a plurality of first words after word segmentation;
[0023] Obtaining similar words to the plurality of first words;
[0024] Each time, at least one first word is replaced with a corresponding similar word to generate a similar question information;
[0025] The first question vector is acquired according to the first question information and the at least one piece of similar question information.
[0026] In another possible implementation, obtaining similar words to the plurality of first words includes:
[0027] Acquire similar words associated with each of the plurality of first words from a knowledge database, wherein the knowledge database is used to store each word and similar words associated with each word; or,
[0028] The similarity between each first word in the plurality of first words and at least one preset word is obtained, and a preset word having a similarity with any first word greater than a first preset similarity is used as a similar word to the any first word.
[0029] In another possible implementation manner, acquiring the first question vector according to the first question information and the at least one piece of similar question information includes:
[0030] An average vector of the feature vector of the at least one similar question information and the feature vector of the first question information is obtained as the first question vector.
[0031] In another possible implementation, the calling the answer generation model to obtain at least one piece of answer information according to the first question vector and at least one second question vector includes:
[0032] Concatenate the first problem vector and the at least one second problem vector to obtain a third problem vector;
[0033] The answer generation model is called to obtain the at least one piece of answer information according to the third question vector.
[0034] In another possible implementation, searching a question-answer database according to the first question information or the first question vector includes:
[0035] Concatenate the first problem vector and the at least one second problem vector to obtain a third problem vector;
[0036] Based on the similarity between the third question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of the at least one answer information and the third question vector is greater than the similarity between the feature vectors of other preset answer information and the third question vector.
[0037] In another possible implementation, the at least one second question vector includes a plurality of second question vectors, and the calling of the answer generation model to obtain at least one piece of answer information according to the first question vector and the at least one second question vector includes:
[0038] Performing weighted averaging on the plurality of second question vectors to obtain a fourth question vector;
[0039] Concatenate the first question vector and the fourth question vector to obtain a fused question vector;
[0040] According to the fused question vector, the answer generation model is called to obtain the at least one piece of answer information.
[0041] In another possible implementation, searching a question-answer database according to the first question information or the first question vector includes:
[0042] Performing weighted averaging on the plurality of second question vectors to obtain a fourth question vector;
[0043] Concatenate the first question vector and the fourth question vector to obtain a fused question vector;
[0044] Based on the similarity between the fused question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of the at least one answer information and the fused question vector is greater than the similarity between the feature vectors of other preset answer information and the fused question vector.
[0045] In another possible implementation, searching a question-answer database according to the first question information or the first question vector includes:
[0046] According to the first question vector, searching the question-answer database to determine at least one fifth question vector, wherein the at least one fifth question vector includes a question vector similar to the first question vector; or
[0047] Searching the question-answer database according to the first question vector and the at least one second question vector to determine at least one fifth question vector, wherein the at least one fifth question vector includes at least one of a question vector similar to the first question vector or a question vector similar to the at least one second question vector;
[0048] Obtain answer information of the at least one fifth question vector from the question and answer database as the at least one piece of answer information.
[0049] In another possible implementation, searching a question-answer database according to the first question information or the first question vector includes:
[0050] Based on the similarity between the first question vector and the feature vector of each preset answer information in the question and answer database, the at least one answer information is obtained, and the similarity between the feature vector of the at least one answer information and the first question vector is greater than the similarity between the feature vectors of other preset answer information and the first question vector.
[0051] In another possible implementation, searching a question-answer database according to the first question information or the first question vector includes:
[0052] Performing word segmentation processing on the first question information to obtain keywords or entities of the first question information;
[0053] Performing word segmentation processing on the preset answer information in the question and answer database to obtain keywords or entities of the preset answer information;
[0054] At least one piece of answer information is obtained according to the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question and answer database.
[0055] In another aspect, a question-answering device is provided, the device comprising:
[0056] An acquisition module, configured to acquire a first question vector of first question information and a second question vector of at least one piece of second question information, wherein the at least one piece of second question information is question information acquired before the first question information;
[0057] A generation module, configured to call an answer generation model, and obtain at least one answer information according to the first question vector and at least one second question vector, wherein the answer generation model is configured to generate answer information matching any question vector according to any question vector;
[0058] A retrieval module, configured to search a question-answering database according to the first question information or the first question vector;
[0059] The sorting module is used to call the sorting model to sort the multiple answer information obtained in order of matching degree with the first question information from high to low, and determine the answer information ranked first as the target answer information.
[0060] In a possible implementation, the device further includes:
[0061] The acquisition module is used to acquire sample question information and corresponding sample answer information, as well as sample matching degrees between the sample question information and the sample answer information;
[0062] The training module is used to train the sorting model according to the sample question information, the sample answer information and the sample matching degree to obtain a trained sorting model.
[0063] In another possible implementation, the training module includes:
[0064] An input unit, used to input the sample question information and the sample answer information into the ranking model to obtain a predicted matching degree between the sample question information and the sample answer information;
[0065] A training unit is used to train the sorting model according to the sample matching degree and the predicted matching degree to obtain a trained sorting model.
[0066] In another possible implementation, the sorting model includes multiple matching layers, a fusion layer and a sorting layer, and the generation module includes:
[0067] a matching degree obtaining unit, configured to call the plurality of matching layers to respectively obtain a matching degree between each piece of answer information and the first question information;
[0068] A fusion unit, used for calling the fusion layer to obtain a fusion matching degree of multiple matching degrees of each answer information;
[0069] The sorting unit is used to call the sorting layer to sort the multiple answer information in descending order of fusion matching degree, and determine the answer information ranked first as the target answer information.
[0070] In another possible implementation, the acquisition module is used to perform any of the following:
[0071] Performing word segmentation processing on the first question information to obtain a plurality of first words after word segmentation;
[0072] Obtaining similar words to the plurality of first words;
[0073] Each time, at least one first word is replaced with a corresponding similar word to generate a similar question information;
[0074] The first question vector is acquired according to the first question information and the at least one piece of similar question information.
[0075] In another possible implementation, the acquisition module is used to perform any of the following:
[0076] Acquire similar words associated with each of the plurality of first words from a knowledge database, wherein the knowledge database is used to store each word and similar words associated with each word; or,
[0077] The similarity between each first word in the plurality of first words and at least one preset word is obtained, and a preset word having a similarity with any first word greater than a first preset similarity is used as a similar word to the any first word.
[0078] In another possible implementation, the acquisition module is used to acquire an average vector of a feature vector of the at least one similar question information and a feature vector of the first question information as the first question vector.
[0079] In another possible implementation, the generating module is configured to perform any of the following:
[0080] Concatenate the first problem vector and the at least one second problem vector to obtain a third problem vector;
[0081] The answer generation model is called to obtain the at least one piece of answer information according to the third question vector.
[0082] In another possible implementation, the retrieval module is used to perform any of the following:
[0083] Concatenate the first problem vector and the at least one second problem vector to obtain a third problem vector;
[0084] Based on the similarity between the third question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of the at least one answer information and the third question vector is greater than the similarity between the feature vectors of other preset answer information and the third question vector.
[0085] In another possible implementation, the at least one second question vector includes a plurality of second question vectors, and the generating module is configured to perform any one of the following:
[0086] Performing weighted averaging on the plurality of second question vectors to obtain a fourth question vector;
[0087] Concatenate the first problem vector and the fourth problem vector to obtain a fused problem vector;
[0088] According to the fused question vector, the answer generation model is called to obtain the at least one piece of answer information.
[0089] In another possible implementation, the retrieval module is used to perform any of the following:
[0090] Performing weighted averaging on the plurality of second question vectors to obtain a fourth question vector;
[0091] Concatenate the first problem vector and the fourth problem vector to obtain a fused problem vector;
[0092] Based on the similarity between the fused question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of the at least one answer information and the fused question vector is greater than the similarity between the feature vectors of other preset answer information and the fused question vector.
[0093] In another possible implementation, the retrieval module is used to perform any of the following:
[0094] According to the first question vector, searching the question-answer database to determine at least one fifth question vector, wherein the at least one fifth question vector includes a question vector similar to the first question vector; or
[0095] Searching the question-answer database according to the first question vector and the at least one second question vector to determine at least one fourth question vector, wherein the at least one fourth question vector includes at least one of a question vector similar to the first question vector and a question vector similar to the at least one second question vector;
[0096] Obtain answer information of the at least one fourth question vector from the question and answer database as the at least one answer information.
[0097] In another possible implementation, the retrieval module is used to perform any of the following:
[0098] Performing word segmentation processing on the first question information to obtain keywords or entities of the first question information;
[0099] Performing word segmentation processing on the preset answer information in the question and answer database to obtain keywords or entities of the preset answer information;
[0100] At least one piece of answer information is obtained according to the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question and answer database.
[0101] On the other hand, an electronic device is provided, comprising one or more processors and one or more memories, wherein at least one instruction is stored in the one or more memories, and the at least one instruction is loaded and executed by the one or more processors to implement operations performed by the question-and-answer method.
[0102] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction is stored in the storage medium, and the at least one instruction is loaded and executed by a processor to implement the operations performed by the question-and-answer method.
[0103] The question-and-answer method, apparatus, device, and storage medium provided in the embodiments of the present application adopt a model-based automatic generation method and a retrieval method to obtain answer information, and then call the sorting model to sort the multiple answer information obtained according to the matching degree between the answer information and the question information, and obtain the answer information ranked first, which is the answer information that best matches the first question information. This ensures that answer information can be generated even if the answer information cannot be retrieved using the retrieval method, and there will be no missing answer information. It also comprehensively considers the influence of the context and the matching degree between the answer information and the question information, thereby improving the accuracy of the answer information. BRIEF DESCRIPTION OF THE DRAWINGS
[0104] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0105] Figure 1 It is a structural diagram of an implementation environment provided by an embodiment of the present application;
[0106] Figure 2 is a flow chart of a question-and-answer method provided in an embodiment of the present application;
[0107] Figure 3 is a flow chart of a question-and-answer method provided in an embodiment of the present application;
[0108] Figure 4 is a block diagram of an answer generation model provided in an embodiment of the present application;
[0109] Figure 5 is a block diagram of retrieving answer information provided by an embodiment of the present application;
[0110] Figure 6 It is a block diagram of a sorting model provided in an embodiment of the present application for sorting;
[0111] Figure 7 is a block diagram for determining an answer provided by an embodiment of the present application;
[0112] Figure 8 is a block diagram of operations performed by an input module provided in an embodiment of the present application;
[0113] Fig. 9 is a structural schematic diagram of a question-and-answer device provided in an embodiment of the present application;
[0114] Fig.10 is a structural schematic diagram of a question-and-answer device provided in an embodiment of the present application;
[0115] Fig.11 is a schematic diagram of the structure of a terminal provided in an embodiment of the present application;
[0116] Fig.12 It is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0117] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0118] The question-answering method provided in this application can automatically provide answers to questions asked by users online, improve the accuracy of answering questions, and can be applied in a variety of scenarios:
[0119] For example, the question-and-answer method provided by the present application is applied to an intelligent customer service scenario. When a user uses any application, the application can provide the user with a customer service question-and-answer service. The user can enter question information in the application. When the application detects the question information entered by the user, the question-and-answer method provided by the embodiment of the present application is used to determine a matching answer based on the question information for the user to view the determined answer.
[0120] Alternatively, the question-and-answer method provided by the present application is applied to an entertainment interaction scenario. When a user needs to be entertained, he or she can interact with an intelligent robot. The user can input question information to the intelligent robot, and then use the question-and-answer method provided by the embodiment of the present application to determine a matching answer based on the question information input by the user, and then reply to the user with the answer, thereby interacting with the user.
[0121] In addition, the method provided in the embodiment of the present application is applied to an electronic device, which may include a terminal and may also include a server.
[0122] When the electronic device includes a terminal, the method provided in the embodiment of the present application is executed by the terminal.
[0123] or, Figure 1 A schematic diagram of the implementation environment structure of the present application embodiment is shown, see Figure 1 When the electronic device includes a terminal 101 and a server 102, the terminal 101 and the server 102 are connected via a communication network. After the terminal 101 obtains the first question information, the first question information is sent to the server 102 via the communication network. The server 102 determines the target answer information according to the method provided in the embodiment of the present application, and then feeds back the target answer information to the terminal 101. The user can view the target question information through the terminal 101.
[0124] The terminal may be a mobile phone, a tablet computer, a computer or other types of terminals, and the server may be a single server, a server cluster consisting of several servers, or a cloud computing service center.
[0125] Figure 2 is a flowchart of a question-and-answer method provided in an embodiment of the present application, see Figure 2 , the method comprising:
[0126] 201. Obtain a first question vector of first question information and a second question vector of at least one piece of second question information.
[0127] Among them, at least one second question information is question information obtained before the first question information.
[0128] 202. Call an answer generation model to obtain at least one piece of answer information according to the first question vector and at least one second question vector.
[0129] The answer generation model is used to generate answer information matching any question vector based on any question vector.
[0130] 203. Search in a question-answer database according to the first question information or the first question vector.
[0131] 204. Call the sorting model to sort the obtained multiple answer information in descending order of the matching degree with the first question information, and determine the answer information ranked first as the target answer information.
[0132] The method provided in the embodiment of the present application adopts a model-based automatic generation method and a retrieval method to obtain answer information, and then calls the sorting model to sort the multiple answer information obtained according to the matching degree between the answer information and the question information, and obtains the answer information ranked first, which is the answer information that best matches the first question information. This ensures that answer information can be generated even if the retrieval method cannot be used to retrieve the answer information, and there will be no situation where the answer information is missing. It also comprehensively considers the influence of the context and the matching degree between the answer information and the question information, thereby improving the accuracy of the answer information.
[0133] In one possible implementation, the method further includes:
[0134] Obtaining sample question information and corresponding sample answer information, as well as sample matching degree between the sample question information and the sample answer information;
[0135] The sorting model is trained according to the sample question information, the sample answer information and the sample matching degree to obtain a trained sorting model.
[0136] In another possible implementation, the ranking model is trained according to the sample question information, the sample answer information and the sample matching degree to obtain the trained ranking model, including:
[0137] Inputting the sample question information and the sample answer information into the ranking model to obtain the predicted matching degree between the sample question information and the sample answer information;
[0138] The sorting model is trained according to the sample matching degree and the predicted matching degree to obtain a trained sorting model.
[0139] In another possible implementation, the sorting model includes multiple matching layers, a fusion layer, and a sorting layer. The sorting model is called to sort the obtained multiple answer information in descending order of matching degree with the first question information, and the answer information ranked first is determined as the target answer information, including:
[0140] Call multiple matching layers to obtain the matching degree between each answer information and the first question information respectively;
[0141] Call the fusion layer to obtain the fusion matching degree of multiple matching degrees for each answer information;
[0142] The sorting layer is called to sort the multiple answer information in descending order of fusion matching degree, and the answer information ranked first is determined as the target answer information.
[0143] In another possible implementation, obtaining a first question vector of first question information includes:
[0144] Performing word segmentation processing on the first question information to obtain a plurality of first words after word segmentation;
[0145] Obtaining a plurality of similar words to the first word;
[0146] Each time, at least one first word is replaced with a corresponding similar word to generate a similar question information;
[0147] A first question vector is obtained according to the first question information and at least one piece of similar question information.
[0148] In another possible implementation, obtaining a plurality of similar words to the first word includes:
[0149] Acquire similar words associated with each of the first words from a knowledge database, where the knowledge database is used to store each word and similar words associated with each word; or,
[0150] The similarity between each first word in the plurality of first words and at least one preset word is obtained, and a preset word having a similarity with any first word greater than a first preset similarity is used as a similar word to any first word.
[0151] In another possible implementation, obtaining a first question vector according to the first question information and at least one piece of similar question information includes:
[0152] An average vector of a feature vector of at least one similar question information and a feature vector of the first question information is obtained as a first question vector.
[0153] In another possible implementation, calling the answer generation model to obtain at least one piece of answer information according to the first question vector and at least one second question vector includes:
[0154] Concatenate the first problem vector and at least one second problem vector to obtain a third problem vector;
[0155] The answer generation model is called to obtain at least one piece of answer information according to the third question vector.
[0156] In another possible implementation, searching in a question-answer database according to the first question information or the first question vector includes:
[0157] Concatenate the first problem vector and at least one second problem vector to obtain a third problem vector;
[0158] At least one piece of answer information is obtained based on the similarity between the third question vector and the feature vector of each preset answer information in the question and answer database, and the similarity between the feature vector of at least one piece of answer information and the third question vector is greater than the similarity between the feature vectors of other preset answer information and the third question vector.
[0159] In another possible implementation, the at least one second question vector includes a plurality of second question vectors, and the answer generation model is called to obtain at least one piece of answer information according to the first question vector and the at least one second question vector, including:
[0160] Performing weighted averaging on the plurality of second question vectors to obtain a fourth question vector;
[0161] The first question vector and the fourth question vector are concatenated to obtain a fused question vector;
[0162] According to the fused question vector, the answer generation model is called to obtain at least one answer information.
[0163] In another possible implementation, searching in a question-answer database according to the first question information or the first question vector includes:
[0164] Performing weighted averaging on the plurality of second question vectors to obtain a fourth question vector;
[0165] The first question vector and the fourth question vector are concatenated to obtain a fused question vector;
[0166] According to the similarity between the fused question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of at least one answer information and the fused question vector is greater than the similarity between the feature vectors of other preset answer information and the fused question vector.
[0167] In another possible implementation, searching in a question-answer database according to the first question information or the first question vector includes:
[0168] According to the first question vector, searching in the question-answer database to determine at least one fifth question vector, wherein the at least one fifth question vector includes a question vector similar to the first question vector; or,
[0169] Searching a question-answering database according to the first question vector and the at least one second question vector to determine at least one fifth question vector, wherein the at least one fifth question vector includes at least one of a question vector similar to the first question vector and a question vector similar to the at least one second question vector;
[0170] At least one piece of answer information of the fifth question vector is obtained from the question and answer database as at least one piece of answer information.
[0171] In another possible implementation, searching in a question-answer database according to the first question information or the first question vector includes:
[0172] According to the similarity between the first question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of at least one answer information and the first question vector is greater than the similarity between the feature vectors of other preset answer information and the fused question vector.
[0173] In another possible implementation, searching in a question-answer database according to the first question information or the first question vector includes:
[0174] Perform word segmentation processing on the first question information to obtain keywords or entities of the first question information;
[0175] Perform word segmentation on the preset answer information in the question-answer database to obtain keywords or entities of the preset answer information;
[0176] At least one piece of answer information is obtained according to the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question and answer database.
[0177] Figure 3 is a flowchart of a question-and-answer method provided in an embodiment of the present application, see Figure 3 , the method is applied in an electronic device, the method comprising:
[0178] 301. Obtain a first question vector of first question information and a second question vector of at least one piece of second question information.
[0179] The first question information is the question information currently input by the user. For example, the first question information may be the question information for the user to inquire about an operation, or the question information for the user to inquire about a name, or the question information for the user to inquire about the price of an item, and so on.
[0180] In an embodiment of the present application, when answering the first question information, not only is the answer provided based on the first question vector of the first question information, but it is also necessary to obtain at least one second question information before the first question information, and then answer based on the first question information and at least one second question information.
[0181] The first question information is the question currently asked by the user. Before the first question information, the user has asked other questions. Therefore, obtaining at least one second question information before the first question information and then answering the user's first question information based on the question information previously asked by the user can improve the accuracy of the generated answer information.
[0182] In a possible implementation, the at least one piece of second question information obtained is input into a vector coding model to obtain a second question vector of the at least one piece of second question information. The vector coding model is used to obtain a question vector of any piece of question information.
[0183] Optionally, the first question information is segmented to obtain multiple first words after segmentation, similar words of the multiple first words are obtained, at least one first word is replaced with a corresponding similar word each time to generate a similar question information, and a first question vector is obtained based on the first question information and at least one similar question information.
[0184] Among them, similar words to the first word are obtained. After replacing the first word with the similar words, similar question information similar to the first question information can be obtained. By expanding the obtained first word, the first question information is expanded, and more other question information similar to the first question information can be obtained, and different expressions of the same information can be fully considered.
[0185] After obtaining similar words of multiple first words of the word segmentation, at least one first word can be replaced with a corresponding similar word. For example, one of the first words can be replaced with a corresponding similar word, two of the first words can be replaced with corresponding similar words, and so on. Then, a piece of similar question information after replacement can be generated, and then a first question vector can be obtained based on the first question information and at least one piece of similar question information.
[0186] In a possible implementation manner, a similar word associated with each of the multiple first words is obtained from a knowledge database.
[0187] The knowledge database is used to store each word and similar words associated with each word. The knowledge database can describe the relationship between each word, establish associations between each word, and form a network structure between words.
[0188] When the first question information is segmented, and then the knowledge database is searched based on the first word obtained by the segmentation, similar words associated with the first word in the knowledge database can be determined.
[0189] In another possible implementation, the similarity between each first word in the plurality of first words and at least one preset word is obtained, and a preset word having a similarity with any first word greater than a first preset similarity is used as a similar word to any first word.
[0190] In an embodiment of the present application, after the first question information is segmented, multiple first words are obtained, and then the similarity between each first word and at least one preset word is calculated, and then it is determined whether the similarity between each first word and at least one preset word is greater than the first preset similarity. When it is determined that the similarity between any first word and the preset word is greater than the first preset similarity, the preset word is used as a similar word of any first word.
[0191] The first preset similarity is set by the server, or by a technician, or by other methods. The first preset similarity can be 0.7, 0.8 or other values.
[0192] For example, when the first question information input by the user is "I want to check this order", the multiple first words obtained by word segmentation are "I", "want", "query", "a while", "this", and "order". It can be determined that the similar word of "query" is "find", and the similar word of "order" is "bill". Replace "query" with "find", and the similar question information generated is "I want to find this order". Replace "order" with "bill", and the similar question information generated is "I want to check this bill". At the same time, replace "query" with "find", and replace "order" with "bill", and the similar question information generated is "I want to find this bill". Then, based on the first question information and at least one similar question information, obtain the first question vector.
[0193] Optionally, an average vector of a feature vector of at least one similar question information and a feature vector of the first question information is obtained as the first question vector.
[0194] When generating a first question vector based on the first question information and at least one similar question information, first obtain the feature vector of the at least one similar question information and the feature vector of the first question information, and then calculate the average vector of the feature vector of the at least one similar question information and the feature vector of the first question information as the first question vector.
[0195] In one possible implementation, after obtaining the first question information and at least one similar question information, the first question information and at least one similar question information are input into a sentence vector encoding model, and then a feature vector of the first question information and a feature vector of the similar question information are obtained.
[0196] 302. Call an answer generation model to obtain at least one piece of answer information according to the first question vector and at least one second question vector.
[0197] The answer generation model is used to generate answer information matching any question vector based on any question vector.
[0198] Among them, the answer generation model can be a seq2seq-attention (a model structure) model, an encoder-decoder (a model structure) model, a transformer (a model structure) model, etc.
[0199] Optionally, the answer generation model includes a vector decoding module, an attention mechanism weighting module, an answer error correction module and a generative answer module, for example, Figure 4As shown in the figure, after the question vector is input into the answer generation model, the question vector is weighted by the attention mechanism weighting module to obtain the most influential part of the question vector, and then the predicted answer is obtained by the vector decoding module. The predicted answer is grammatically corrected by the answer correction module, and finally the answer information is obtained, which is the generative answer information.
[0200] After obtaining the first question vector and at least one second question vector, the answer generation model is called to obtain at least one piece of answer information according to the first question vector and the at least one second question vector.
[0201] In one possible implementation, the first question vector and at least one second question vector are concatenated to obtain a third question vector, and the answer generation model is called to obtain at least one piece of answer information according to the third question vector.
[0202] The first question vector and at least one second question vector are sequentially concatenated to obtain a concatenated third question vector, and then the third question vector is input into the answer generation model to generate at least one answer information.
[0203] Optionally, when sequentially splicing the first problem vector and the at least one second problem vector, the splicing is performed sequentially in the order in which the first problem vector and the at least one second problem vector are obtained to obtain a spliced third problem vector.
[0204] Alternatively, the first question vector and at least one second question vector are sequentially concatenated in a random order to obtain a concatenated third question vector.
[0205] In another possible implementation manner, the at least one second question vector obtained includes multiple second question vectors.
[0206] In order to reduce the data volume of the second question vector, a weighted average is first performed on multiple second question vectors to obtain a fourth question vector, and then the first question vector and the fourth question vector are concatenated to obtain a fused question vector. According to the fused question vector, the answer generation model is called to obtain at least one answer information.
[0207] Optionally, the called answer generation model can directly process the fused question vector to generate an answer message.
[0208] Alternatively, the called answer generation model can use multiple processing layers to process the fused question vector separately to obtain multiple processed question vectors, and then each processing layer will generate an answer information based on a question vector, so that multiple answer information can be obtained in the end.
[0209] Optionally, in the process of weighted averaging the multiple second question vectors, the weight of each second question vector is determined according to the sequence of the multiple second question vectors, and then the multiple second question vectors are weighted averaged according to the weight of each second question vector to obtain a fourth question vector.
[0210] For example, the reciprocal of the number of rounds between each second problem vector and the first problem vector is used as the weight of each second problem vector. When the number of rounds between the second problem vector and the first problem vector is 1, the weight is 1. When the number of rounds between the second problem vector and the first problem vector is 2, the weight is 1 / 2, and so on. The larger the number of rounds between the second problem vector and the first problem vector, the smaller the weight.
[0211] Among them, the process from obtaining question information, obtaining answer information based on the question information, to outputting the answer information is a round of question and answer process. Therefore, the number of rounds between the second question vector and the first question vector is the number of rounds of the question and answer process between the first question vector and the second question vector.
[0212] In addition, before calling the answer generation model, the answer generation model needs to be trained first, and then the trained answer generation model is called. The step of training the answer generation model includes: first obtaining an initial answer generation model or an answer generation model that has been trained once or multiple times, then obtaining a sample question vector and corresponding sample answer information, and training the initial answer generation model according to the sample question vector and the corresponding sample answer information to obtain a trained answer generation model.
[0213] During the training process, at least one sample question vector is input into the answer generation model, predicted answer information is obtained based on the answer generation model, and then the error between the sample answer information and the predicted answer information is obtained. The answer generation model is adjusted so that the error obtained by the adjusted answer generation model converges, thereby completing the training of the answer generation model.
[0214] 303. Search in a question-and-answer database according to the first question information or the first question vector.
[0215] Among them, the question and answer database stores multiple answer information, and each of the multiple answer information corresponds to question information. Therefore, according to the obtained first question vector and at least one second question vector, a search is performed in the question and answer database, and after the search, it can be determined whether there is answer information that matches the first question information.
[0216] In the process of searching in the question-answer database, the search may be performed based on the first question information, or based on the first question vector, and the answer information may be subsequently obtained through the search.
[0217] In one possible implementation, the first question vector and at least one second question vector are concatenated to obtain a third question vector, and at least one answer information is obtained based on the similarity between the third question vector and a feature vector of each preset answer information in the question and answer database, and the similarity between the feature vector of at least one answer information and the third question vector is greater than the similarity between the feature vectors of other preset answer information and the third question vector.
[0218] Among them, the characteristic vector of each preset answer information in the question and answer database can be obtained, and then the similarity between the third question vector and the characteristic vector of each preset answer information can be calculated, and then the preset answer information can be sorted in order from large to small according to the similarity, and at least one answer information can be obtained according to the arrangement order.
[0219] Optionally, according to the arrangement order, a preset number of preset answer information is selected as the retrieved answer information.
[0220] The preset number may be set by the server, or by a technician, or in other ways. The preset number may be 2, 3, 4, or other values.
[0221] Optionally, according to the similarity between the acquired third question vector and the feature vector of each preset answer information, the preset answer information with a similarity greater than a preset similarity is selected as the retrieved answer information.
[0222] In another possible implementation, a weighted average is performed on multiple second question vectors to obtain a fourth question vector, the first question vector and the fourth question vector are concatenated to obtain a fused question vector, and at least one piece of answer information is obtained based on the similarity between the fused question vector and a feature vector of each preset answer information in the question and answer database, and the similarity between the feature vector of at least one piece of answer information and the fused question vector is greater than the similarity between the feature vectors of other preset answer information and the fused question vector.
[0223] The process of weighted averaging the multiple second question vectors is similar to the weighted averaging process in the above steps, which will not be repeated here. In addition, the process of calculating the similarity between the fused feature vector and the feature vector of the preset answer information is similar to the process of calculating the similarity between the third feature vector and the feature vector of the preset answer information in the above process, which will not be repeated here.
[0224] In another possible implementation, at least one piece of answer information is obtained based on the similarity between the first question vector and a feature vector of each preset answer information in the question and answer database.
[0225] The similarity between the feature vector of the at least one piece of answer information and the first question vector is greater than the similarity between the feature vector of other preset answer information and the first question vector.
[0226] The process of obtaining at least one piece of answer information according to the similarity is similar to the above-mentioned process of obtaining at least one piece of answer information, which will not be repeated here.
[0227] Optionally, in the process of obtaining at least one piece of answer information based on the first question vector, the amount of answer information obtained can be determined by setting a preset number. For example, when the preset number is 1, one piece of answer information is obtained, and when the preset number is 2, multiple pieces of answer information are obtained.
[0228] Alternatively, when obtaining answer information based on the preset similarity, since the similarity between the obtained third question vector or the fused feature vector and the feature vector of the preset answer information is not fixed, if both are less than the preset similarity, no answer information will be obtained; if only one is greater than the preset similarity, only one piece of answer information will be obtained; if multiple similarities are greater than the preset similarity, multiple pieces of answer information will be obtained.
[0229] In another possible implementation, based on the first question vector, a search is performed in the question-answer database to determine at least one fifth question vector, wherein the at least one fifth question vector includes a question vector similar to the first question vector.
[0230] Optionally, the similarity between at least one fifth question vector and the first question vector is greater than the similarity between other preset question vectors and the first question vector.
[0231] In another possible implementation, a search is performed in a question and answer database based on the first question vector and at least one second question vector to determine at least one fifth question vector, the at least one fifth question vector including at least one of a question vector similar to the first question vector or a question vector similar to at least one second question vector, and answer information of the at least one fifth question vector is obtained from the question and answer database as the at least one answer information retrieved.
[0232] In the process of obtaining at least one fifth question vector by searching, since a question vector similar to the question vector is determined, in order to reduce the situation where the fifth question vector cannot be obtained, the obtained fifth question vector can be a vector similar to the first question vector, or a vector similar to the second question vector.
[0233] Optionally, since the fifth question vector is obtained based on the first question vector and at least one second question vector, three situations may occur, namely, no fifth question vector is obtained, one fifth question vector is obtained, and multiple fifth question vectors are obtained.
[0234] Optionally, the first question vector and at least one second question vector are concatenated to obtain a third question vector, and a search is performed in the question-answer database based on the third question vector to determine at least one fifth question vector.
[0235] Among them, at least one fifth question vector is obtained based on the similarity between the third question vector and each preset question vector in the question and answer database, and the similarity between at least one fourth question vector and the third question vector is greater than the similarity between other preset question vectors and the third question vector.
[0236] Optionally, a weighted average is performed on multiple second question vectors to obtain a sixth question vector, the first question vector and the sixth question vector are concatenated to obtain a fused question vector, and a search is performed in the question and answer database based on the fused question vector to determine at least one fifth question vector.
[0237] Among them, at least one fifth question vector is obtained based on the similarity between the fused question vector and each preset question vector in the question and answer database, and the similarity between the at least one fifth question vector and the third question vector is greater than the similarity between other preset question vectors and the fused question vector.
[0238] It should be noted that the embodiment of the present application is only described by searching the question and answer database for answer information according to the first question vector. In another embodiment, the question and answer database may be searched directly according to the first question information to obtain at least one answer information.
[0239] In one possible implementation, word segmentation is performed on the first question information to obtain keywords or entities in the first question information, and word segmentation is performed on the preset answer information in the question and answer database to obtain keywords or entities of the preset answer information. When the keywords or entities in the first question information match the keywords or entities in the preset answer information, the preset answer information is determined as the answer information.
[0240] In another possible implementation, word segmentation is performed on the first question information to obtain keywords or entities of the first question information, and word segmentation is performed on the preset question information in the question and answer database to obtain keywords or entities of preset answer information. Based on the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question and answer database, a search is performed in the question and answer database to determine at least one third question information similar to the first question information, and then the answer information corresponding to the at least one third question information is determined as the answer information.
[0241] For example, Figure 5 As shown, during the retrieval process, multiple preset answer information is obtained from the question-answer database, and the feature vector of each preset answer information is obtained according to the vector coding model, and then the similarity between the preset answer information and the current question vector is calculated, and the answer information is obtained according to the obtained similarity. Alternatively, the keywords or entities of the preset answer information and the keywords or entities of the current question information can also be obtained, and the similarity between the preset answer information and the keywords and the keywords of the current question information can be calculated, or the similarity between the preset answer information and the entities and the entities of the current question information can be calculated, and the answer information can be obtained according to the obtained similarity. The answer information obtained by the above two methods can be called retrieval answer information.
[0242] 304. Call multiple matching layers in the sorting model to obtain the matching degree between each piece of answer information and the first question information respectively.
[0243] The sorting model includes multiple matching layers, a fusion layer and a sorting layer. Each matching layer in the multiple matching layers is used to obtain the matching degree of the question information and the answer information. The fusion layer is used to fuse the matching degree of each question information and the answer information to obtain the fusion matching degree of the question information and the answer information. The sorting layer is used to sort the answer information according to the fusion matching degree of the question information and each answer information, and take the answer information ranked first as the target answer information of the question information.
[0244] After obtaining multiple answer information, multiple matching layers in the sorting model are called. A matching degree between each answer information and the first question information can be obtained through one matching layer. Then, the same answer information and the first question information can obtain multiple matching degrees through multiple matching layers.
[0245] Optionally, different methods are used in multiple matching layers to obtain the matching degree between the first question information and the answer information.
[0246] Among them, machine learning algorithms such as LSTM (Long short-term memory), CNN (Convolutional Neural Networks), MLP (Multi-Layer Perceptron), GBDT (Gradient Boosting Decision Tree) can be used to obtain the matching degree, or other methods can be used to obtain the matching degree.
[0247] 305. Call the fusion layer in the sorting model to obtain the fusion matching degree of multiple matching degrees of each answer information.
[0248] After obtaining multiple matching degrees for each answer information, the fusion layer is called to obtain the fusion matching degree of the multiple matching degrees for each answer information.
[0249] Optionally, an average value of multiple matching degrees of each answer information is obtained as the fusion matching degree of the answer information.
[0250] Optionally, each matching layer has a corresponding weight, and the sum of the weights corresponding to multiple matching layers is 1. Then, according to the weight corresponding to each matching layer, multiple matching degrees of each answer information are weighted averaged to obtain the fusion matching degree of the answer information.
[0251] 306. Call the sorting layer in the sorting model to sort the multiple answer information in descending order of fusion matching degree, and determine the answer information ranked first as the target answer information.
[0252] For example, Figure 6 As shown, after obtaining multiple pieces of answer information, the sorting model is called to determine the target answer information.
[0253] In addition, in an embodiment of the present application, when calling the sorting model to obtain target answer information from multiple answer information, the priority of at least one answer information obtained through step 303 is greater than the priority of at least one answer information obtained through step 302. Therefore, when the sorting model sorts the multiple answer information, the weight set for the answer information obtained through step 303 is greater than the weight set for the answer information obtained through step 303. When sorting according to the fusion matching degree, the fusion matching degree is first weighted by the set weight to obtain the weighted fusion matching degree, and then sorting is performed according to the weighted fusion matching degree to obtain the target answer information.
[0254] It should be noted that the embodiment of the present application is only described by taking the sorting model including multiple matching layers, a fusion layer and a sorting layer as an example. In another embodiment, steps 304-306 are optional steps. There is no need to set multiple matching layers in the sorting model. The sorting model can be directly called to obtain a matching degree between the answer information and the first question information, and the target answer information is determined according to the obtained matching degree.
[0255] In one possible implementation, a sorting model is called to sort at most pieces of answer information in descending order of matching degree with the first question information, and the answer information ranked first is determined as the target answer information.
[0256] In an embodiment of the present application, a sorting model is called to obtain the matching degree between each answer information in the multiple answer information and the first question information. Since each answer information corresponds to a matching degree, the multiple answer information are directly sorted in order from high to low according to the matching degree with the first question information, and the answer information ranked first is determined as the target answer information.
[0257] In addition, before calling the sorting model, you need to train the sorting model first to obtain the trained sorting model, and then call the trained sorting model to obtain the target answer. The process of training the sorting model is as follows:
[0258] Obtain sample question information and corresponding sample answer information, as well as sample matching degrees between the sample question information and the sample answer information, and train a sorting model based on the sample question information, the sample answer information, and the sample matching degrees to obtain a trained sorting model.
[0259] The sample question information and the sample answer information are in a corresponding relationship, that is, the answer to the sample question information is the sample answer information. In addition, the sample matching degree of the sample question information and the sample answer information is used to indicate that the sample question information and the sample answer information match.
[0260] After obtaining the sample question information and the corresponding sample answer information, as well as the sample matching degree of the sample question information and the corresponding sample answer information, the sorting model can be trained according to the sample question information, the sample answer information and the sample matching degree to obtain the trained sorting model.
[0261] Optionally, the sample question information and the sample answer information are input into the sorting model to obtain the predicted matching degree of the sample question information and the sample answer information, and the sorting model is trained according to the sample matching degree and the predicted matching degree to obtain a trained sorting model.
[0262] During the training process, at least one sample question information and the corresponding sample answer information are input into the sorting model, and the predicted matching degree is obtained based on the sorting model. Then, the error between the sample matching degree and the predicted matching degree is obtained, and the sorting model is adjusted so that the error obtained by the adjusted sorting model converges, thereby completing the training of the sorting model.
[0263] The process of the method provided in the embodiment of the present application is as follows Figure 7 As shown, step 301 is executed by the input module, step 302 is executed by the answer generation module to obtain at least one generative answer, step 303 is executed by the answer retrieval module to obtain at least one retrieval answer, and steps 304-306 are executed by the answer sorting module to sort at least one generative answer and at least one retrieval answer to obtain the answer for the current round.
[0264] In addition, the procedures in the input module such as Figure 8 As shown, first obtain the first question information input by the user in the current round, perform word segmentation on the first question information, and then expand the words after word segmentation to obtain similar question information. According to the first question information, similar question information and second question information, the second question information is the scene context information. The scene context encoding model is called to obtain the scene context information vector. The sentence vector encoding model is called to obtain the first question information and the first question vector of the similar question information. Then, a fused feature vector is generated according to the scene context information vector and the first question vector. The fused feature vector is the input of the subsequent generation module and the retrieval module, and becomes the scene context information of the next question information.
[0265] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present disclosure, and will not be described in detail here.
[0266] The method provided in the embodiment of the present application adopts a model-based automatic generation method and a retrieval method to obtain answer information, and then calls the sorting model to sort the multiple answer information obtained according to the matching degree between the answer information and the question information, and obtains the answer information ranked first, which is the answer information that best matches the first question information. This ensures that answer information can be generated even if the retrieval method cannot be used to retrieve the answer information, and there will be no situation where the answer information is missing. It also comprehensively considers the influence of the context and the matching degree between the answer information and the question information, thereby improving the accuracy of the answer information.
[0267] In addition, multiple matching methods are used to obtain multiple matching degrees between question information and answer information, and multiple matching degrees are fused to obtain a fused matching degree. The fused matching degree combines multiple matching degrees and is more accurate. Therefore, the answer information with the highest fused matching degree is determined as the target answer information, which can improve the accuracy of the target answer information.
[0268] Moreover, by adopting the method of first segmenting words and then expanding them, the first question information is expanded, and more question information similar to the first question information can be obtained, and different expressions of the same information are fully considered to improve the accuracy of the answer information obtained subsequently.
[0269] Fig. 9 is a structural diagram of a question-answering device provided in an embodiment of the present application. Fig. 9 , the device comprises:
[0270] An acquisition module 901 is used to acquire a first question vector of a first question information and a second question vector of at least one piece of second question information, wherein the at least one piece of second question information is question information acquired before the first question information;
[0271] A generating module 902 is used to call an answer generating model to obtain at least one piece of answer information according to the first question vector and at least one second question vector, wherein the answer generating model is used to generate answer information matching any question vector according to any question vector;
[0272] A retrieval module 903, configured to search a question-answer database according to the first question information or the first question vector;
[0273] The sorting module 904 is used to call the sorting model to sort the multiple answer information obtained in order of matching degree with the first question information from high to low, and determine the answer information ranked first as the target answer information.
[0274] The device provided in the embodiment of the present application adopts a model-based automatic generation method and a retrieval method to obtain answer information, and then calls the sorting model to sort the multiple answer information obtained according to the matching degree between the answer information and the question information, and obtains the answer information ranked first, which is the answer information that best matches the first question information. This ensures that answer information can be generated even if the answer information cannot be retrieved using the retrieval method, and there will be no situation where answer information is missing. It also comprehensively considers the influence of the context and the matching degree between the answer information and the question information, thereby improving the accuracy of the answer information.
[0275] In a possible implementation, the device further includes:
[0276] The acquisition module 901 is used to acquire sample question information and corresponding sample answer information, as well as sample matching degree between the sample question information and the sample answer information;
[0277] The training module 905 is used to train the sorting model according to the sample question information, the sample answer information and the sample matching degree to obtain a trained sorting model.
[0278] In another possible implementation, the training module 905 includes:
[0279] An input unit 9051 is used to input the sample question information and the sample answer information into the ranking model to obtain a predicted matching degree between the sample question information and the sample answer information;
[0280] The training unit 9052 is used to train the sorting model according to the sample matching degree and the predicted matching degree to obtain a trained sorting model.
[0281] In another possible implementation, the sorting model includes multiple matching layers, a fusion layer and a sorting layer, and the generating module 902 includes:
[0282] A matching degree obtaining unit 9021 is used to call the multiple matching layers to obtain the matching degree between each answer information and the first question information respectively;
[0283] A fusion unit 9022, configured to call the fusion layer to obtain a fusion matching degree of multiple matching degrees of each answer information;
[0284] The sorting unit 9023 is used to call the sorting layer to sort the multiple answer information in descending order of fusion matching degree, and determine the answer information ranked first as the target answer information.
[0285] In another possible implementation, the acquisition module 901 is configured to perform any of the following:
[0286] Performing word segmentation processing on the first question information to obtain a plurality of first words after word segmentation;
[0287] Obtaining similar words to the plurality of first words;
[0288] Each time, at least one first word is replaced with a corresponding similar word to generate a similar question information;
[0289] The first question vector is acquired according to the first question information and the at least one piece of similar question information.
[0290] In another possible implementation, the acquisition module 901 is configured to perform any of the following:
[0291] Acquire similar words associated with each of the plurality of first words from a knowledge database, wherein the knowledge database is used to store each word and similar words associated with each word; or,
[0292] The similarity between each first word in the plurality of first words and at least one preset word is obtained, and a preset word having a similarity with any first word greater than a first preset similarity is used as a similar word to the any first word.
[0293] In another possible implementation, the acquisition module 901 is used to acquire an average vector of the feature vector of the at least one similar question information and the feature vector of the first question information as the first question vector.
[0294] In another possible implementation, the generating module 902 is configured to perform any of the following:
[0295] Concatenate the first problem vector and the at least one second problem vector to obtain a third problem vector;
[0296] The answer generation model is called to obtain the at least one piece of answer information according to the third question vector.
[0297] In another possible implementation, the retrieval module 903 is configured to perform any of the following:
[0298] Concatenate the first problem vector and the at least one second problem vector to obtain a third problem vector;
[0299] Based on the similarity between the third question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of the at least one answer information and the third question vector is greater than the similarity between the feature vectors of other preset answer information and the third question vector.
[0300] In another possible implementation, the at least one second question vector includes multiple second question vectors, and the generating module 902 is configured to perform any one of the following:
[0301] Performing weighted averaging on the plurality of second question vectors to obtain a fourth question vector;
[0302] Concatenate the first problem vector and the fourth problem vector to obtain a fused problem vector;
[0303] According to the fused question vector, the answer generation model is called to obtain the at least one piece of answer information.
[0304] In another possible implementation, the retrieval module 903 is configured to perform any of the following:
[0305] Performing weighted averaging on the plurality of second question vectors to obtain a fourth question vector;
[0306] Concatenate the first question vector and the fourth question vector to obtain a fused question vector;
[0307] Based on the similarity between the fused question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of the at least one answer information and the fused question vector is greater than the similarity between the feature vectors of other preset answer information and the fused question vector.
[0308] In another possible implementation, the retrieval module 903 is configured to perform any of the following:
[0309] According to the first question vector, searching the question-answer database to determine at least one fifth question vector, wherein the at least one fifth question vector includes a question vector similar to the first question vector; or
[0310] Searching the question-answer database according to the first question vector and the at least one second question vector to determine at least one fourth question vector, wherein the at least one fourth question vector includes at least one of a question vector similar to the first question vector and a question vector similar to the at least one second question vector;
[0311] Obtain answer information of the at least one fourth question vector from the question and answer database as the at least one answer information.
[0312] In another possible implementation, the retrieval module 903 is configured to perform any of the following:
[0313] Performing word segmentation processing on the first question information to obtain keywords or entities of the first question information;
[0314] Performing word segmentation processing on the preset answer information in the question and answer database to obtain keywords or entities of the preset answer information;
[0315] At least one piece of answer information is obtained according to the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question and answer database.
[0316] It should be noted that: when the question-answering device provided in the above embodiment is conducting question-answering, only the division of the above functional modules is used as an example. In actual applications, the above functional distribution can be completed by different functional modules as needed, that is, the internal structure of the electronic device is divided into different functional modules to complete all or part of the functions described above. In addition, the embodiment of the question-answering device provided in the above embodiment belongs to the same concept as the embodiment of the question-answering method. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0317] Fig.11 11 is a schematic diagram of the structure of a terminal provided in an embodiment of the present application. The terminal 1100 may be a portable mobile terminal, such as a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, a head-mounted device, or any other intelligent terminal. The terminal 1100 may also be referred to as a user device, a portable terminal, a laptop terminal, a desktop terminal, or other names.
[0318] Typically, the terminal 1100 includes a processor 1101 and a memory 1102 .
[0319] The processor 1101 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1101 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1101 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1101 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1101 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0320] The memory 1102 may include one or more computer-readable storage media, which may be non-transitory. The memory 1102 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1102 is used to store at least one instruction, which is used by the processor 1101 to implement the question-and-answer method provided in the method embodiment of the present application.
[0321] In some embodiments, the terminal 1100 may also optionally include: a peripheral device interface 1103 and at least one peripheral device. The processor 1101, the memory 1102 and the peripheral device interface 1103 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1103 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1104, a display screen 1105, a camera assembly 1106, an audio circuit 1107, a positioning assembly 1108 and a power supply 11011.
[0322] The peripheral device interface 1103 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1101 and the memory 1102. In some embodiments, the processor 1101, the memory 1102, and the peripheral device interface 1103 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1101, the memory 1102, and the peripheral device interface 1103 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0323] The radio frequency circuit 1104 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1104 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1104 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 1104 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The radio frequency circuit 1104 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: a metropolitan area network, various generations of mobile communication networks (2G, 3G, 4G and 8G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1104 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.
[0324] The display screen 1105 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1105 is a touch display screen, the display screen 1105 also has the ability to collect touch signals on the surface or above the surface of the display screen 1105. The touch signal can be input to the processor 1101 as a control signal for processing. At this time, the display screen 1105 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 1105 can be one, set on the front panel of the terminal 1100; in other embodiments, the display screen 1105 can be at least two, respectively set on different surfaces of the terminal 1100 or in a folding design; in other embodiments, the display screen 1105 can be a flexible display screen, set on a curved surface or a folding surface of the terminal 1100. Even, the display screen 1105 can also be set to a non-rectangular irregular figure, that is, a special-shaped screen. The display screen 1105 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0325] The camera assembly 1106 is used to capture images or videos. Optionally, the camera assembly 1106 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1106 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0326] The audio circuit 1107 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 1101 for processing, or input them into the radio frequency circuit 1104 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 1100. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 1101 or the radio frequency circuit 1104 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1107 may also include a headphone jack.
[0327] The positioning component 1108 is used to locate the current geographical location of the terminal 1100 to implement navigation or LBS (Location Based Service). The positioning component 1108 can be a positioning component based on the US GPS (Global Positioning System), China's Beidou system, Russia's Grenas system or the European Union's Galileo system.
[0328] The power supply 1109 is used to power various components in the terminal 1100. The power supply 1109 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1109 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0329] In some embodiments, the terminal 1100 further includes one or more sensors 1110 , including but not limited to: an acceleration sensor 1111 , a gyroscope sensor 1112 , a pressure sensor 1113 , a fingerprint sensor 1114 , an optical sensor 1115 , and a proximity sensor 1116 .
[0330] The acceleration sensor 1111 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 1100. For example, the acceleration sensor 1111 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1101 can control the display screen 1105 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 1111. The acceleration sensor 1111 can also be used to collect motion data of games or users.
[0331] The gyro sensor 1112 can detect the body direction and rotation angle of the terminal 1100, and the gyro sensor 1112 can cooperate with the acceleration sensor 1111 to collect the user's 3D actions on the terminal 1100. The processor 1101 can implement the following functions based on the data collected by the gyro sensor 1112: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0332] The pressure sensor 1113 may be provided at the side frame of the terminal 1100 and / or the lower layer of the display screen 1105. When the pressure sensor 1113 is provided at the side frame of the terminal 1100, the user's holding signal of the terminal 1100 may be detected, and the processor 1101 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor 1113. When the pressure sensor 1113 is provided at the lower layer of the display screen 1105, the processor 1101 controls the operability controls on the UI interface according to the user's pressure operation on the display screen 1105. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0333] The fingerprint sensor 1114 is used to collect the user's fingerprint, and the processor 1101 identifies the user's identity based on the fingerprint collected by the fingerprint sensor 1114, or the fingerprint sensor 1114 identifies the user's identity based on the collected fingerprint. When the user's identity is identified as a trusted identity, the processor 1101 authorizes the user to have relevant sensitive operations, which include unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings. The fingerprint sensor 1114 can be set on the front, back, or side of the terminal 1100. When a physical button or a manufacturer logo is set on the terminal 1100, the fingerprint sensor 1114 can be integrated with the physical button or the manufacturer logo.
[0334] The optical sensor 1115 is used to collect the ambient light intensity. In one embodiment, the processor 1101 can control the display brightness of the display screen 1105 according to the ambient light intensity collected by the optical sensor 1115. Specifically, when the ambient light intensity is high, the display brightness of the display screen 1105 is increased; when the ambient light intensity is low, the display brightness of the display screen 1105 is reduced. In another embodiment, the processor 1101 can also dynamically adjust the shooting parameters of the camera assembly 1106 according to the ambient light intensity collected by the optical sensor 1115.
[0335] The proximity sensor 1116, also called a distance sensor, is usually arranged on the front panel of the terminal 1100. The proximity sensor 1116 is used to collect the distance between the user and the front of the terminal 1100. In one embodiment, when the proximity sensor 1116 detects that the distance between the user and the front of the terminal 1100 is gradually decreasing, the processor 1101 controls the display screen 1105 to switch from the screen-on state to the screen-off state; when the proximity sensor 1116 detects that the distance between the user and the front of the terminal 1100 is gradually increasing, the processor 1101 controls the display screen 1105 to switch from the screen-off state to the screen-on state.
[0336] Those skilled in the art will understand that Fig.11 The structure shown in the figure does not constitute a limitation on the terminal 1100, and the terminal 1100 may include more or fewer components than those shown in the figure, or combine certain components, or adopt a different component arrangement.
[0337] Fig.12 This is a schematic diagram of the structure of a server provided in an embodiment of the present application. The server 1200 may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 1201 and one or more memories 1202, wherein the memory 1202 stores at least one instruction, and the at least one instruction is loaded and executed by the processor 1201 to implement the methods provided in the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output, and the server may also include other components for implementing device functions, which will not be described in detail here.
[0338] The server 1200 can be used to execute the steps performed by the server in the above question-and-answer method.
[0339] An embodiment of the present application also provides an electronic device, which includes one or more processors and one or more memories, wherein at least one instruction is stored in the one or more memories, and the at least one instruction is loaded and executed by the one or more processors to implement operations performed by the question-and-answer method.
[0340] An embodiment of the present application also provides a computer-readable storage medium, in which at least one instruction is stored, and the at least one instruction is loaded and executed by a processor to implement the operations performed by the question-and-answer method.
[0341] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0342] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A question-answering method, characterized in that: The method comprises: Acquire a first question vector of first question information and a second question vector of at least one piece of second question information, wherein the at least one piece of second question information is question information acquired before the first question information; Calling an answer generation model to obtain at least one piece of answer information according to the first question vector and at least one second question vector, wherein the answer generation model is used to generate answer information matching any question vector according to any question vector; Searching a question-answer database according to the first question information or the first question vector; Calling the sorting model to sort the obtained multiple answer information in descending order of matching degree with the first question information, and determining the answer information ranked first as the target answer information; The sorting model includes multiple matching layers, a fusion layer and a sorting layer. The calling sorting model sorts the obtained multiple answer information in descending order of matching degree with the first question information, and determines the answer information ranked first as the target answer information, including: Calling the multiple matching layers to respectively obtain a matching degree between each piece of answer information and the first question information; Calling the fusion layer to obtain a fusion matching degree of the multiple matching degrees of each answer information, specifically including: each matching layer has a corresponding weight, and the sum of the weights corresponding to the multiple matching layers is 1, then according to the weight corresponding to each matching layer, performing weighted averaging on the multiple matching degrees of each answer information to obtain the fusion matching degree of the answer information; The sorting layer is called to sort the multiple pieces of answer information in descending order of fusion matching degree, and the answer information ranked first is determined as the target answer information.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining sample question information and corresponding sample answer information, as well as sample matching degrees between the sample question information and the sample answer information; The sorting model is trained according to the sample question information, the sample answer information and the sample matching degree to obtain a trained sorting model.
3. The method according to claim 2, characterized in that The step of training the sorting model according to the sample question information, the sample answer information and the sample matching degree to obtain a trained sorting model comprises: Inputting the sample question information and the sample answer information into the ranking model to obtain the predicted matching degree between the sample question information and the sample answer information; The sorting model is trained according to the sample matching degree and the predicted matching degree to obtain a trained sorting model.
4. The method according to claim 1, characterized in that: The step of obtaining the first question vector of the first question information includes: Performing word segmentation processing on the first question information to obtain a plurality of first words after word segmentation; Obtaining similar words to the plurality of first words; Each time, at least one first word is replaced with a corresponding similar word to generate a similar question information; The first question vector is acquired according to the first question information and the at least one piece of similar question information.
5. The method according to claim 4, characterized in that The obtaining similar words to the plurality of first words comprises: Acquire similar words associated with each of the plurality of first words from a knowledge database, wherein the knowledge database is used to store each word and similar words associated with each word; or, The similarity between each first word in the plurality of first words and at least one preset word is obtained, and a preset word having a similarity with any first word greater than a first preset similarity is used as a similar word to any first word.
6. The method according to claim 4, characterized in that The acquiring the first question vector according to the first question information and the at least one piece of similar question information includes: An average vector of the feature vector of the at least one similar question information and the feature vector of the first question information is obtained as the first question vector.
7. The method according to claim 1, characterized in that The calling the answer generation model to obtain at least one piece of answer information according to the first question vector and at least one second question vector includes: Concatenate the first problem vector and the at least one second problem vector to obtain a third problem vector; The answer generation model is called to obtain the at least one piece of answer information according to the third question vector.
8. The method according to claim 1, characterized in that The searching in a question-answer database according to the first question information or the first question vector includes: Concatenate the first problem vector and the at least one second problem vector to obtain a third problem vector; Based on the similarity between the third question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of the at least one answer information and the third question vector is greater than the similarity between the feature vectors of other preset answer information and the third question vector.
9. The method according to claim 1, characterized in that: The at least one second question vector includes a plurality of second question vectors, and the calling of the answer generation model to obtain at least one piece of answer information according to the first question vector and the at least one second question vector includes: Performing weighted averaging on the plurality of second question vectors to obtain a fourth question vector; Concatenate the first problem vector and the fourth problem vector to obtain a fused problem vector; According to the fused question vector, the answer generation model is called to obtain the at least one piece of answer information.
10. The method according to claim 1, characterized in that The searching in a question-answer database according to the first question information or the first question vector includes: Performing weighted averaging on a plurality of said second question vectors to obtain a fourth question vector; Concatenate the first problem vector and the fourth problem vector to obtain a fused problem vector; Based on the similarity between the fused question vector and the feature vector of each preset answer information in the question and answer database, at least one answer information is obtained, and the similarity between the feature vector of the at least one answer information and the fused question vector is greater than the similarity between the feature vectors of other preset answer information and the fused question vector.
11. The method according to claim 1, characterized in that: The searching in a question-answer database according to the first question information or the first question vector includes: According to the first question vector, searching the question-answer database to determine at least one fifth question vector, wherein the at least one fifth question vector includes a question vector similar to the first question vector; or Searching the question-answer database according to the first question vector and the at least one second question vector to determine at least one fifth question vector, wherein the at least one fifth question vector includes at least one of a question vector similar to the first question vector or a question vector similar to the at least one second question vector; Obtain answer information of the at least one fifth question vector from the question and answer database as the at least one piece of answer information.
12. A question-answering device, characterized in that: The device comprises: An acquisition module, configured to acquire a first question vector of first question information and a second question vector of at least one piece of second question information, wherein the at least one piece of second question information is question information acquired before the first question information; A generation module, configured to call an answer generation model, and obtain at least one answer information according to the first question vector and at least one second question vector, wherein the answer generation model is configured to generate answer information matching any question vector according to any question vector; A retrieval module, configured to search a question-answering database according to the first question information or the first question vector; A sorting module, used to call the sorting model, sort the obtained multiple answer information in descending order of the matching degree with the first question information, and determine the answer information ranked first as the target answer information; The sorting model includes multiple matching layers, a fusion layer and a sorting layer. The calling sorting model sorts the obtained multiple answer information in descending order of the matching degree with the first question information, and determines the answer information ranked first as the target answer information, including: The sorting module is used to call the multiple matching layers to obtain the matching degree of each answer information with the first question information respectively; call the fusion layer to obtain the fusion matching degree of the multiple matching degrees of each answer information, specifically including: each matching layer has a corresponding weight, and the sum of the weights corresponding to the multiple matching layers is 1, then according to the weight corresponding to each matching layer, the multiple matching degrees of each answer information are weighted averaged to obtain the fusion matching degree of the answer information; call the sorting layer to sort the multiple answer information in descending order of the fusion matching degree, and determine the answer information ranked first as the target answer information.
13. An electronic device, characterized in that: The electronic device includes one or more processors and one or more memories, wherein the one or more memories store at least one instruction, and the at least one instruction is loaded and executed by the one or more processors to implement the operations performed by the question-and-answer method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the operation performed by the question-and-answer method according to any one of claims 1 to 11.
