Intelligent Conversation Method, Device, Computer Equipment and Storage Medium
By using a bidirectional recurrent neural network and a two-way attention mechanism in intelligent customer service, answers are generated directly in the target document, and the problem of low accuracy in traditional intelligent customer service is solved, achieving higher answer accuracy and more natural human-computer interaction.
Patent Information
- Application Number
- CN202111638516.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2041-12-29
AI Technical Summary
The question-and-answer corpus of traditional smart customer service is difficult to involve all types of questions, resulting in the answers provided by smart customer service are relatively low when customers ask questions that are not mentioned in the corpus.
By obtaining the question text and performing word segmentation processing, a preset bidirectional recurrent neural network generates problem encoding, obtaining the document encoding of the target document from the database, and calculating the similarity matrix using the bidirectional attention mechanism, and finally generating the answer text of the question.
This method improves the accuracy of intelligent customer service answers, does not require preset question-and-answer pairs, and can directly find corresponding answers in the target document, taking into account the context semantic information between the question and the document.
Smart Images

Figure CN114328873B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular, to an intelligent dialogue method, apparatus, computer device, and storage medium. Background Art
[0002] With the popular application of the Internet and e-commerce, intelligent customer service has become increasingly common. The dialogue technology of traditional intelligent customer service is usually based on a retrieval method. According to the questions most frequently asked by customers or the questions that customers are most concerned about, a corpus containing question-and-answer pairs is prepared in advance. When a customer asks a question, by calculating the similarity between the target question and the questions in the corpus, the question with the highest matching degree is found, and the corresponding answer to the question is given.
[0003] However, due to its own limitations, it is difficult for the question-and-answer pair corpus to cover all question types. When a customer asks a question not mentioned in the corpus, the answer provided by the intelligent customer service at this time is not the answer the user wants, and the accuracy of the traditional customer service answer is relatively low. Summary of the Invention
[0004] Embodiments of this application provide an intelligent dialogue method, apparatus, computer device, and storage medium, which can improve the accuracy of the answers of intelligent customer service.
[0005] In a first aspect, an embodiment of this application provides an intelligent dialogue method, which includes:
[0006] Obtain a question text, and perform word segmentation processing on the question text to obtain a plurality of question word segments;
[0007] Input the plurality of question word segments into a preset bidirectional recurrent neural network in sequence to obtain question encodings corresponding to the question word segments;
[0008] Obtain document encodings of each text word segment corresponding to a target document from a preset database;
[0009] Determine a first similarity matrix between the document encoding and the question encoding according to a preset bidirectional attention mechanism;
[0010] Determine a vector representation of the target document with respect to the question text according to the question encoding and the first similarity matrix to obtain a second similarity matrix;
[0011] Determine a vector representation of the question text with respect to the target document according to the document encoding and the first similarity matrix to obtain a third similarity matrix;
[0012] Determine an answer text to the question text according to the second similarity matrix, the third similarity matrix, and the document encoding.
[0013] In a second aspect, an embodiment of the present application further provides an intelligent dialogue device, which includes:
[0014] A first acquisition unit, configured to acquire a question text, and perform word segmentation processing on the question text to obtain a plurality of question word segments;
[0015] A first input unit, configured to sequentially input the plurality of question word segments into a preset bidirectional recurrent neural network to obtain question encodings corresponding to the question word segments;
[0016] A second acquisition unit, configured to acquire document encodings of respective text word segments corresponding to a target document from a preset database;
[0017] A first determination unit, configured to determine a first similarity matrix between the document encoding and the question encoding according to a preset bidirectional attention mechanism;
[0018] A second determination unit, configured to determine a vector representation of the target document with respect to the question text according to the question encoding and the first similarity matrix to obtain a second similarity matrix;
[0019] A third determination unit, configured to determine a vector representation of the question text with respect to the target document according to the document encoding and the first similarity matrix to obtain a third similarity matrix;
[0020] A fourth determination unit, configured to determine an answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document encoding.
[0021] In a third aspect, an embodiment of the present application further provides a computer device, which includes a memory and a processor. A computer program is stored on the memory, and when the processor executes the computer program, the above method is implemented.
[0022] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium. The storage medium stores a computer program, and the computer program includes program instructions, and when the program instructions are executed by a processor, the above method can be implemented.
[0023] An embodiment of the present application provides an intelligent dialogue method, apparatus, computer device, and storage medium. Among them, the method includes: obtaining a question text, performing word segmentation processing on the question text to obtain a plurality of question word segments; sequentially inputting the plurality of question word segments into a preset bidirectional recurrent neural network to obtain question encodings corresponding to the question word segments; obtaining document encodings of each text word segment corresponding to a target document from a preset database; determining a first similarity matrix between the document encodings and the question encodings according to a preset bidirectional attention mechanism; determining a vector representation of the target document with respect to the question text according to the question encodings and the first similarity matrix to obtain a second similarity matrix; determining a vector representation of the question text with respect to the target document according to the document encodings and the first similarity matrix to obtain a third similarity matrix; determining an answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document encodings. This solution does not require setting up question-and-answer pairs. After obtaining the user's question text, it directly searches for corresponding answers in the target document through the connection between the question text and the target document, improving the accuracy of the intelligent customer service answers. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0025] Figure 1 Schematic diagram of the application scenario of the intelligent dialogue method provided by the embodiment of the present application;
[0026] Figure 2 Schematic flowchart of the intelligent dialogue method provided by the embodiment of the present application;
[0027] Figure 3 Schematic diagram of the structure of an intelligent customer service provided by the embodiment of the present application;
[0028] Figure 4 Schematic diagram of the principle of the intelligent dialogue method provided by the embodiment of the present application;
[0029] Figure 5 Schematic block diagram of the intelligent dialogue apparatus provided by the embodiment of the present application;
[0030] Figure 6 Schematic block diagram of the intelligent dialogue apparatus provided by another embodiment of the present application;
[0031] Figure 7 Schematic block diagram of the computer device provided by the embodiment of the present application. Detailed implementation manners
[0032] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part rather than all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the protection scope of the present application.
[0033] It should be understood that when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0034] It should also be understood that the terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification of the present application and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" are intended to include the plural forms.
[0035] It should be further understood that the term " / and" as used in the specification of the present application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0036] The embodiments of the present application provide an intelligent dialogue method, device, computer device, and storage medium.
[0037] The execution subject of the intelligent dialogue method may be the intelligent dialogue device provided in the embodiments of the present application, or a computer device integrated with the intelligent dialogue device. Among them, the intelligent dialogue device may be implemented in a hardware or software manner, the computer device may be a terminal or a server, and the terminal may be a smart phone, a tablet computer, a handheld computer, a notebook computer, or the like.
[0038] Please refer to Figure 1 , Figure 1 which is a schematic diagram of an application scenario of the intelligent dialogue method provided in the embodiments of the present application. The intelligent dialogue method is applied to Figure 1In the intelligent customer service, the intelligent customer service obtains the question text communicated by the user in natural language form, performs word segmentation processing on the question text to obtain a plurality of question word segments; sequentially inputs the plurality of question word segments into a preset bidirectional recurrent neural network to obtain question encodings corresponding to the question word segments; obtains document encodings of each text word segment corresponding to a target document (such as the illustrated product document) from a preset database; and then obtains product information through machine reading comprehension. Specifically, a first similarity matrix between the document encoding and the question encoding is determined according to a preset bidirectional attention mechanism; a vector representation of the target document with respect to the question text is determined according to the question encoding and the first similarity matrix to obtain a second similarity matrix; a vector representation of the question text with respect to the target document is determined according to the document encoding and the first similarity matrix to obtain a third similarity matrix; and an answer text of the question text is determined according to the second similarity matrix, the third similarity matrix, and the document encoding.
[0039] Figure 2 is a schematic flowchart of the intelligent dialogue method provided by an embodiment of the present application. As Figure 2 shown, the method includes the following steps S110-170.
[0040] S110. Obtain a question text, and perform word segmentation processing on the question text to obtain a plurality of question word segments.
[0041] In this embodiment, when a customer needs to understand a certain product, the customer can input a corresponding question text in the intelligent customer service dialog box, for example: "How long is the shelf life of the product?"
[0042] Specifically, the structure of the intelligent customer service in this embodiment is as Figure 3 shown, including an input layer, an encoding layer, an interaction layer, and an output layer.
[0043] This embodiment first defines a proprietary dictionary related to the Internet of Things field and the component enabling platform (SCEP) to improve the accuracy of word segmentation. The question text is obtained through the input layer, and then the jieba word segmentation technology is used to perform word segmentation processing on the question text.
[0044] In some embodiments, after obtaining the question text and performing word segmentation processing on the question text to obtain a plurality of question word segments, the method further includes: performing part-of-speech analysis processing and keyword extraction processing on the question word segments to obtain target question word segments; at this time, the target question word segments carry part-of-speech analysis results, and the target question word segments are the word segments after keyword extraction. That is, after word segmentation of the question, part-of-speech (POS) analysis and keyword extraction are also introduced because keywords and nouns and verbs in the sentence are relatively important for question positioning. Among them, keywords refer to verbs, nouns, etc. other than adverbs in the sentence.
[0045] S120. Input the word segments of the multiple problems into a preset bidirectional recurrent neural network in sequence to obtain the problem encodings corresponding to the word segments of the problems.
[0046] The word segments of the problems will not change with the context, but the same word usually has different meanings in different sentences. Therefore, based on the word segments of the problems, the results of part-of-speech analysis, and the results of keyword extraction, this system introduces the technology of bidirectional recurrent neural network (RNN) to obtain the encoding representation with context semantic information, and obtains the problem encodings corresponding to each word segment of the problems respectively.
[0047] Among them, this step is implemented in the encoding layer of the intelligent customer service.
[0048] S130. Obtain the document encodings of the text word segments corresponding to the target document from a preset database.
[0049] In this embodiment, the database is preset with the document encodings of the text word segments corresponding to the target document. Among them, the target document can be an original knowledge document such as a product document or a technical document, and the text word segment is the word segment corresponding to the target text.
[0050] At this time, before step S130, the method further includes: obtaining the target document, performing word segmentation processing on the target document to obtain multiple document word segments; inputting the multiple document word segments into the bidirectional recurrent neural network in sequence to obtain the document encodings; storing the target document, the document word segments, and the document encodings into the database.
[0051] In some embodiments, after obtaining the target document and performing word segmentation processing on the target document to obtain multiple document word segments, the method further includes: performing part-of-speech analysis processing and keyword extraction processing on the document word segments to obtain target document word segments, where the target document word segments carry the results of part-of-speech analysis, and the target document word segments are the word segments after keyword extraction; at this time, the step of inputting the multiple document word segments into the bidirectional recurrent neural network in sequence to obtain the document encodings includes: inputting the multiple target document word segments into the bidirectional recurrent neural network in sequence to obtain the document encodings.
[0052] S140. Determine the first similarity matrix between the document encoding and the problem encoding according to a preset bidirectional attention mechanism.
[0053] In the interaction layer of the intelligent customer service, a first similarity matrix between the document encoding and the question encoding is determined according to the Bi-Directional Attention Flow for Machine Comprehension (BiDAF).
[0054] Specifically, the first similarity matrix is determined according to formula (1):
[0055] S tj = α(P t , Q ij ); (1)
[0056] S tj represents the similarity value between the t-th column vector in the document encoding matrix P and the j-th column vector in the question encoding matrix Q, and it is a real value. α represents a trainable mapping function. After calculating the similarities between all document tokens in the document encoding matrix P and all question tokens in the question encoding matrix Q, the first similarity matrix S is obtained. Among them, the rows in S represent the similarities between a certain document token in the target document and each question token, and the columns in S represent the similarities between a certain question token in the question text and each document token.
[0057] S150. Determine a vector representation of the target document with respect to the question text according to the question encoding and the first similarity matrix, and obtain a second similarity matrix.
[0058] In some embodiments, specifically, determine the first maximum similarity value of each question token with respect to the text token according to the first similarity matrix; then determine the second similarity matrix according to the first maximum similarity value and the question encoding.
[0059] Context-to-query Attention (C2Q) calculates which query words (question tokens) are most relevant to each context word (document token). Specifically, the second similarity matrix is determined through formula (2) and formula (3).
[0060] a t = softmax(S t: ); (2)
[0061]
[0062] Specifically, it is to directly use the softmax layer of each row of the S similarity matrix as the attention value a. Since each row in S represents the similarity between the i-th word in the target text and each word in the question text, and C2Q represents the influence of the text on the question, so a is obtained.t It is directly weighted and summed with each column in Q to obtain a new Finally, it is assembled into a new question encoding That is, the second similarity matrix.
[0063] S160. Determine the vector representation of the question text with respect to the target document according to the document encoding and the first similarity matrix, and obtain the third similarity matrix.
[0064] In some embodiments, specifically: determine the second largest similarity value of each text tokenization with respect to the question tokenization according to the first similarity matrix; then determine the third similarity matrix according to the second largest similarity value and the text encoding.
[0065] In this embodiment, the third similarity matrix reflects query-to-context Attention (Q2C). Query-to-context Attention (Q2C) calculates which context words are most relevant to each query word. Since these context words are important for answering questions, directly take the largest column in the correlation matrix, perform softmax normalization calculation on the weighted sum of the context vectors, and then repeat T (the total number of document tokenizations is T) times to obtain the third similarity matrix Specifically, it is obtained through formula (4) and formula (5)
[0066] b = softmax(max(S)); (4)
[0067]
[0068] Specifically, steps S140 - S160 in this embodiment are implemented through the interaction layer in the intelligent customer service.
[0069] Through steps S140 - S160, not only the semantic information between text contexts is saved, but also an interactive connection is generated between the question text and the target document.
[0070] S170. Determine the answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document encoding.
[0071] In some embodiments, specifically, the second similarity matrix, the third similarity matrix, and the document encoding are concatenated through a preset function beta β to obtain a fusion matrix; the fusion matrix is encoded through a preset encoding module to obtain an answer matrix with a fixed dimension; and the answer matrix is decoded through a preset decoder to obtain the answer text.
[0072] In this embodiment, the answer to the question is generated by the ncoder-decoder technology in the intelligent customer service output layer and fed back to the customer.
[0073] Specifically, this embodiment can generate the answer to the question through Neuro-Linguistic Programming (NLP) technology and feed it back to the customer. The answer is not just a continuous piece of text in the target document, but also a summary statement that synthesizes the knowledge base information for specific questions by the intelligent customer service. Compared with traditional technologies, this method is closer to real human-computer interaction.
[0074] To further understand the intelligent dialogue method in this embodiment, please refer to Figure 4 , Figure 4 , which is the schematic diagram of the implementation of this method.
[0075] Compared with the prior art, the main advantages are as follows:
[0076] 1. It reduces the labor cost of constructing question-answer pairs;
[0077] 2. It is difficult for the question-answer pair corpus to cover all questions. When the customer asks a question not in the corpus, it is difficult to give a satisfactory answer. However, the free-form question-and-answer machine reading comprehension method enables the machine to learn knowledge like a human and answer questions based on what it has learned.
[0078] 3. This method not only considers single words, their parts of speech, the importance of words, and context semantic information, but also fully takes into account the mutual connection between the original knowledge base (target document) and the question.
[0079] 4. Traditional retrieval methods usually give fixed answers and cannot provide comprehensive answers to customer questions. This system comprehensively analyzes the connection between the question and the original knowledge base according to the customer's question and automatically generates natural language for answering. The answer is not limited to a continuous segment in the original knowledge base.
[0080] In addition, most of the systems or methods proposed in current patents are retrieval-based. By calculating the matching degree between the question and the questions in the Q&A corpus, the answer to the question is retrieved. This method overly relies on the Q&A corpus, but questions are usually extensive and divergent. Moreover, this method selects the answer to the most similar question from the Q&A corpus, ignoring other questions with the second-highest similarity but equal importance. The method proposed in this solution can directly generate a natural language answer to the question based on the original knowledge base, and fully considers the context information, part-of-speech information, and the interaction between the knowledge base P and the question Q, and can directly generate an answer to the question.
[0081] In summary, in this embodiment, the question text is obtained, and the question text is tokenized to obtain a plurality of question tokens. The plurality of question tokens are sequentially input into a preset bidirectional recurrent neural network to obtain the question encoding corresponding to the question tokens. The document encoding of each text token corresponding to the target document is obtained from a preset database. The first similarity matrix between the document encoding and the question encoding is determined according to a preset bidirectional attention mechanism. The vector representation of the target document with respect to the question text is determined according to the question encoding and the first similarity matrix to obtain a second similarity matrix. The vector representation of the question text with respect to the target document is determined according to the document encoding and the first similarity matrix to obtain a third similarity matrix. The answer text to the question text is determined according to the second similarity matrix, the third similarity matrix, and the document encoding. This solution does not require setting up Q&A pairs. After obtaining the user's question text, the corresponding answer is directly searched for in the target document through the connection between the question text and the target document, improving the accuracy of the intelligent customer service answer.
[0082] Figure 5 It is a schematic block diagram of an intelligent dialogue device provided by an embodiment of the present application. As Figure 5 shown, corresponding to the above intelligent dialogue method, the present application also provides an intelligent dialogue device. The intelligent dialogue device includes units for executing the above intelligent dialogue method, and the device can be configured in terminals such as desktop computers, tablet computers, laptops, etc. Specifically, please refer to Figure 5 , the intelligent dialogue device includes a first acquisition unit 501, a first input unit 502, a second acquisition unit 503, a first determination unit 504, a second determination unit 505, a third determination unit 506, and a fourth determination unit 507.
[0083] The first acquisition unit 501 is used to acquire the question text and tokenize the question text to obtain a plurality of question tokens;
[0084] The first input unit 502 is used to sequentially input the plurality of question tokens into a preset bidirectional recurrent neural network to obtain the question encoding corresponding to the question tokens;
[0085] A second acquisition unit 503, configured to acquire the document codes of the text segmentations corresponding to the target document from a preset database;
[0086] A first determination unit 504, configured to determine a first similarity matrix between the document code and the question code according to a preset bidirectional attention mechanism;
[0087] A second determination unit 505, configured to determine a vector representation of the target document with respect to the question text according to the question code and the first similarity matrix, to obtain a second similarity matrix;
[0088] A third determination unit 506, configured to determine a vector representation of the question text with respect to the target document according to the document code and the first similarity matrix, to obtain a third similarity matrix;
[0089] A fourth determination unit 507, configured to determine an answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document code.
[0090] In some embodiments, the second determination unit 505 is specifically configured to:
[0091] Determine a first maximum similarity value of each question segmentation with respect to the text segmentation according to the first similarity matrix;
[0092] Determine the second similarity matrix according to the first maximum similarity value and the question code.
[0093] In some embodiments, the third determination unit 506 is specifically configured to:
[0094] Determine a second maximum similarity value of each text segmentation with respect to the question segmentation according to the first similarity matrix;
[0095] Determine the third similarity matrix according to the second maximum similarity value and the text code.
[0096] In some embodiments, the fourth determination unit 507 is specifically configured to:
[0097] Perform splicing processing on the second similarity matrix, the third similarity matrix, and the document code through a preset function beta to obtain a fusion matrix;
[0098] Perform encoding processing on the fusion matrix through a preset encoding module to obtain an answer matrix with a fixed dimension;
[0099] Perform decoding processing on the answer matrix through a preset decoder to obtain the answer text.
[0100] Figure 6 It is a schematic block diagram of an intelligent dialogue device provided by another embodiment of the present application. As Figure 6 shown, the intelligent dialogue device of this embodiment adds a first processing unit 508, a third acquisition unit 509, a second input unit 510, a storage unit 511, and a second processing unit 512 on the basis of the above embodiment.
[0101] The first processing unit 508 is used to perform part-of-speech analysis processing and keyword extraction processing on the problem segmentation to obtain target problem segmentation;
[0102] At this time, the first input unit 502 is specifically used for:
[0103] Sequentially inputting multiple target problem segmentations into the bidirectional recurrent neural network to obtain a problem encoding corresponding to the target problem segmentation.
[0104] The third acquisition unit 509 is used to acquire the target document and perform segmentation processing on the target document to obtain multiple document segmentations;
[0105] The second input unit 510 is used to sequentially input multiple document segmentations into the bidirectional recurrent neural network to obtain the document encoding;
[0106] The storage unit 511 is used to store the target document, the document segmentation, and the document encoding into the database.
[0107] The second processing unit 512 is used to perform part-of-speech analysis processing and keyword extraction processing on the document segmentation to obtain target document segmentation;
[0108] At this time, the second input unit 510 is specifically used for:
[0109] Sequentially inputting multiple target document segmentations into the bidirectional recurrent neural network to obtain the document encoding.
[0110] It should be noted that those skilled in the art can clearly understand that the specific implementation processes of the above intelligent dialogue device and each unit can refer to the corresponding descriptions in the foregoing method embodiments. For the sake of convenience and brevity of description, they will not be elaborated here.
[0111] The above intelligent dialogue device can be implemented in the form of a computer program, and the computer program can run on a computer device as Figure 7 shown.
[0112] Please refer to Figure 7 , Figure 7It is a schematic block diagram of a computer device provided by an embodiment of the present application. The computer device 700 can be a terminal or a server. Among them, the terminal can be an electronic device with communication functions such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device. The server can be an independent server or a server cluster composed of multiple servers.
[0113] Referring to Figure 7 , the computer device 700 includes a processor 702, a memory, and a network interface 705 connected through a system bus 701. Among them, the memory can include a non-volatile storage medium 703 and an internal memory 704.
[0114] The non-volatile storage medium 703 can store an operating system 7031 and a computer program 7032. The computer program 7032 includes program instructions. When the program instructions are executed, the processor 702 can be made to execute an intelligent dialogue method.
[0115] The processor 702 is used to provide computing and control capabilities to support the operation of the entire computer device 700.
[0116] The internal memory 704 provides an environment for the operation of the computer program 7032 in the non-volatile storage medium 703. When the computer program 7032 is executed by the processor 702, the processor 702 can be made to execute an intelligent dialogue method.
[0117] The network interface 705 is used for network communication with other devices. Those skilled in the art can understand that Figure 7 the structure shown in
[0118] is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 700 to which the solution of the present application is applied. The specific computer device 700 may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.
[0118] Among them, the processor 702 is used to run the computer program 7032 stored in the memory to implement the following steps:
[0119] Obtain the problem text and perform word segmentation processing on the problem text to obtain a plurality of problem word segments;
[0120] Input the plurality of problem word segments into a preset bidirectional recurrent neural network in sequence to obtain a problem encoding corresponding to the problem word segments;
[0121] Obtain the document encoding of each text word segment corresponding to the target document from a preset database;
[0122] Determine a first similarity matrix between the document encoding and the question encoding according to a preset bidirectional attention mechanism;
[0123] Determine a vector representation of the target document with respect to the question text according to the question encoding and the first similarity matrix, and obtain a second similarity matrix;
[0124] Determine a vector representation of the question text with respect to the target document according to the document encoding and the first similarity matrix, and obtain a third similarity matrix;
[0125] Determine an answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document encoding.
[0126] In some embodiments, when the processor 702 implements the step of determining a vector representation of the target document with respect to the question text according to the question encoding and the first similarity matrix and obtaining a second similarity matrix, the specific implementation is as follows:
[0127] Determine a first maximum similarity value of each question token with respect to the text token according to the first similarity matrix;
[0128] Determine the second similarity matrix according to the first maximum similarity value and the question encoding.
[0129] In some embodiments, when the processor 702 implements the step of determining a vector representation of the question text with respect to the target document according to the document encoding and the first similarity matrix and obtaining a third similarity matrix, the specific implementation is as follows:
[0130] Determine a second maximum similarity value of each text token with respect to the question token according to the first similarity matrix;
[0131] Determine the third similarity matrix according to the second maximum similarity value and the text encoding.
[0132] In some embodiments, when the processor 702 implements the step of determining an answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document encoding, the specific implementation is as follows:
[0133] Perform splicing processing on the second similarity matrix, the third similarity matrix, and the document encoding through a preset function beta to obtain a fusion matrix;
[0134] Perform encoding processing on the fusion matrix through a preset encoding module to obtain an answer matrix with a fixed dimension;
[0135] Decode the answer matrix through a preset decoder to obtain the answer text.
[0136] In some embodiments, after the processor 702 implements the steps of obtaining the question text and performing word segmentation processing on the question text to obtain multiple question word segments, the following steps are further implemented:
[0137] Perform part-of-speech analysis processing and keyword extraction processing on the question word segments to obtain target question word segments;
[0138] At this time, when the processor 702 implements the step of sequentially inputting multiple question word segments into a preset bidirectional recurrent neural network to obtain the question encoding corresponding to the question word segments, the following steps are specifically implemented:
[0139] Sequentially input multiple target question word segments into the bidirectional recurrent neural network to obtain the question encoding corresponding to the target question word segments.
[0140] In some embodiments, before the processor 702 implements the step of obtaining the document encoding of each text word segment corresponding to the target document from a preset database, the following steps are further implemented:
[0141] Obtain the target document and perform word segmentation processing on the target document to obtain multiple document word segments;
[0142] Sequentially input multiple document word segments into the bidirectional recurrent neural network to obtain the document encoding;
[0143] Store the target document, the document word segments, and the document encoding in the database.
[0144] In some embodiments, after the processor 702 implements the steps of obtaining the target document and performing word segmentation processing on the target document to obtain multiple document word segments, the following steps are further implemented:
[0145] Perform part-of-speech analysis processing and keyword extraction processing on the document word segments to obtain target document word segments;
[0146] At this time, when the processor 702 implements the step of sequentially inputting multiple document word segments into the bidirectional recurrent neural network to obtain the document encoding, the following steps are specifically implemented:
[0147] Sequentially input multiple target document word segments into the bidirectional recurrent neural network to obtain the document encoding.
[0148] It should be understood that in the embodiments of the present application, the processor 702 may be a central processing unit (CPU), and the processor 702 may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0149] Those of ordinary skill in the art can understand that all or part of the processes in the methods of implementing the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, and the storage medium is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0150] Therefore, the present application also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, where the computer program includes program instructions. When the program instructions are executed by a processor, the processor performs the following steps:
[0151] Obtain the problem text, and perform word segmentation processing on the problem text to obtain a plurality of problem word segments;
[0152] Input the plurality of problem word segments into a preset bidirectional recurrent neural network in sequence to obtain problem encodings corresponding to the problem word segments;
[0153] Obtain document encodings of each text word segment corresponding to the target document from a preset database;
[0154] Determine a first similarity matrix between the document encoding and the problem encoding according to a preset bidirectional attention mechanism;
[0155] Determine a vector representation of the target document with respect to the problem text according to the problem encoding and the first similarity matrix to obtain a second similarity matrix;
[0156] Determine a vector representation of the problem text with respect to the target document according to the document encoding and the first similarity matrix to obtain a third similarity matrix;
[0157] Determine the answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document encoding.
[0158] In some embodiments, when the processor executes the program instructions to implement the step of determining the vector representation of the target document with respect to the question text according to the question encoding and the first similarity matrix, and obtaining the second similarity matrix, the specific implementation is as follows:
[0159] Determine the first maximum similarity value of each question word segment with respect to the text word segment according to the first similarity matrix;
[0160] Determine the second similarity matrix according to the first maximum similarity value and the question encoding.
[0161] In some embodiments, when the processor executes the program instructions to implement the step of determining the vector representation of the question text with respect to the target document according to the document encoding and the first similarity matrix, and obtaining the third similarity matrix, the specific implementation is as follows:
[0162] Determine the second maximum similarity value of each text word segment with respect to the question word segment according to the first similarity matrix;
[0163] Determine the third similarity matrix according to the second maximum similarity value and the text encoding.
[0164] In some embodiments, when the processor executes the program instructions to implement the step of determining the answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document encoding, the specific implementation is as follows:
[0165] Perform splicing processing on the second similarity matrix, the third similarity matrix, and the document encoding through a preset function beta to obtain a fusion matrix;
[0166] Perform encoding processing on the fusion matrix through a preset encoding module to obtain an answer matrix with a fixed dimension;
[0167] Perform decoding processing on the answer matrix through a preset decoder to obtain the answer text.
[0168] In some embodiments, after the processor executes the program instructions to implement the step of obtaining the question text and performing word segmentation processing on the question text to obtain multiple question word segments, the following steps are further implemented:
[0169] Perform part-of-speech analysis processing and keyword extraction processing on the question word segments to obtain target question word segments;
[0170] At this time, when the processor executes the program instructions to implement the step of sequentially inputting the multiple problem word segments into a preset bidirectional recurrent neural network to obtain the problem encoding corresponding to the problem word segments, the specific implementation is as follows:
[0171] Sequentially input the multiple target problem word segments into the bidirectional recurrent neural network to obtain the problem encoding corresponding to the target problem word segments.
[0172] In some embodiments, before the processor executes the program instructions to implement the step of obtaining the document encoding of each text word segment corresponding to the target document from a preset database, the following steps are also implemented:
[0173] Obtain the target document, and perform word segmentation processing on the target document to obtain multiple document word segments;
[0174] Sequentially input the multiple document word segments into the bidirectional recurrent neural network to obtain the document encoding;
[0175] Store the target document, the document word segments, and the document encoding in the database.
[0176] In some embodiments, after the processor executes the program instructions to implement the step of obtaining the target document and performing word segmentation processing on the target document to obtain multiple document word segments, the following steps are also implemented:
[0177] Perform part-of-speech analysis processing and keyword extraction processing on the document word segments to obtain target document word segments;
[0178] At this time, when the processor executes the program instructions to implement the step of sequentially inputting the multiple document word segments into the bidirectional recurrent neural network to obtain the document encoding, the specific implementation is as follows:
[0179] Sequentially input the multiple target document word segments into the bidirectional recurrent neural network to obtain the document encoding.
[0180] The storage medium may be various computer-readable storage media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disc that can store program codes.
[0181] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0182] In several embodiments provided by this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of each unit is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0183] The steps in the method embodiments of this application can be adjusted, combined, and deleted according to actual needs. The units in the device embodiments of this application can be combined, divided, and deleted according to actual needs. In addition, the functional units in each embodiment of this application can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit.
[0184] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of this application.
[0185] As described above, the above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed in this application can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should all be covered within the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims
1. An intelligent dialogue method, characterized in that, comprising: Obtain the question text, and perform word segmentation processing on the question text to obtain a plurality of question word segments; Input the plurality of question word segments into a preset bidirectional recurrent neural network in sequence to obtain question encodings corresponding to the question word segments; Obtain document encodings of each text word segment corresponding to the target document from a preset database; Determine a first similarity matrix between the document encoding and the question encoding according to a preset bidirectional attention mechanism; Determine a vector representation of the target document with respect to the question text according to the question encoding and the first similarity matrix to obtain a second similarity matrix; Determine a vector representation of the question text with respect to the target document according to the document encoding and the first similarity matrix to obtain a third similarity matrix; Determine an answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document encoding; The determining a vector representation of the target document with respect to the question text according to the question encoding and the first similarity matrix to obtain a second similarity matrix includes: Determine a first maximum similarity value of each question word segment with respect to the text word segment respectively according to the first similarity matrix; Determine the second similarity matrix according to the first maximum similarity value and the question encoding; The determining a vector representation of the question text with respect to the target document according to the document encoding and the first similarity matrix to obtain a third similarity matrix includes: Determine a second maximum similarity value of each text word segment with respect to the question word segment respectively according to the first similarity matrix; Determine the third similarity matrix according to the second maximum similarity value and the text encoding.
2. The method according to claim 1, characterized in that, after obtaining the question text and performing word segmentation processing on the question text to obtain a plurality of question word segments, the method further includes: Perform part-of-speech analysis processing and keyword extraction processing on the question word segments to obtain target question word segments; The inputting the plurality of question word segments into a preset bidirectional recurrent neural network in sequence to obtain question encodings corresponding to the question word segments includes: Input the plurality of target question word segments into the bidirectional recurrent neural network in sequence to obtain question encodings corresponding to the target question word segments.
3. The method according to any one of claims 1 to 2, characterized in that, before obtaining document encodings of each text word segment corresponding to the target document from a preset database, the method further includes: Obtain the target document, and perform word segmentation processing on the target document to obtain a plurality of document word segments; Input the plurality of document word segments into the bidirectional recurrent neural network in sequence to obtain the document encoding; Store the target document, the document word segments, and the document encoding in the database.
4. The method according to claim 3, characterized in that, after obtaining the target document and performing word segmentation processing on the target document to obtain a plurality of document word segments, the method further includes: Perform part-of-speech analysis and keyword extraction on the segmented text of the document to obtain the target segmented text of the document; The step of sequentially inputting multiple segmented texts of the document into the bidirectional recurrent neural network to obtain the document encoding includes: Sequentially inputting multiple target segmented texts of the document into the bidirectional recurrent neural network to obtain the document encoding.
5. An intelligent dialogue device, Characterized in that, It includes: A first acquisition unit, configured to acquire a question text, and perform word segmentation processing on the question text to obtain a plurality of question segmented words; A first input unit, configured to sequentially input the plurality of question segmented words into a preset bidirectional recurrent neural network to obtain a question encoding corresponding to the question segmented words; A second acquisition unit, configured to acquire the document encoding of each text segmented word corresponding to the target document from a preset database; A first determination unit, configured to determine a first similarity matrix between the document encoding and the question encoding according to a preset bidirectional attention mechanism; A second determination unit, configured to determine a vector representation of the target document with respect to the question text according to the question encoding and the first similarity matrix to obtain a second similarity matrix; A third determination unit, configured to determine a vector representation of the question text with respect to the target document according to the document encoding and the first similarity matrix to obtain a third similarity matrix; A fourth determination unit, configured to determine an answer text of the question text according to the second similarity matrix, the third similarity matrix, and the document encoding; The second determination unit is specifically configured to: Determine a first maximum similarity value of each question segmented word with respect to the text segmented word according to the first similarity matrix; Determine the second similarity matrix according to the first maximum similarity value and the question encoding; The third determination unit is specifically configured to: Determine a second maximum similarity value of each text segmented word with respect to the question segmented word according to the first similarity matrix; Determine the third similarity matrix according to the second maximum similarity value and the text encoding.
6. A computer device, Characterized in that, The computer device includes a memory and a processor, a computer program is stored on the memory, and when the processor executes the computer program, the method described in any one of claims 1-4 is implemented.
7. A computer-readable storage medium, Characterized in that, The storage medium stores a computer program, the computer program includes program instructions, and when the program instructions are executed by a processor, the method described in any one of claims 1-4 can be implemented.
Citation Information
Patent Citations
Method and device for determining answers to questions, computer device and storage medium
CN109670029A
Answer extraction method and device based on deep learning and storage medium
CN109977404A