Intent recognition method, device, equipment and storage medium

Through vectorization processing and weight matrix merging processing of each sentence in the dialogue, the problem of inaccurate intent recognition in the existing technology is solved, and higher recognition accuracy and stability are achieved.

CN111738017BActive Publication Date: 2024-09-10WEBANK (CHINA)
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202010591744.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-24
Publication Date
2024-09-10
Estimated Expiration
2040-06-24

AI Technical Summary

Technical Problem

Existing intent recognition methods that combine context with fixed weights to identify sentences lead to inaccurate intent recognition. They are greatly affected by the number and weight of manually defined contexts, resulting in large deviations between the recognition results and the true intent.

Method used

By obtaining each sentence in the dialogue, performing vectorization processing and merging based on the preset weight matrix, the intention influence weight of each sentence is adaptively determined, and the intention is recognized directly without selecting a fixed number of context sentences, improving the accuracy of intention recognition. sex.

Benefits of technology

It improves the accuracy of sentence intention recognition, reduces the error caused by manual configuration of fixed weights, enhances the accuracy of the influence weight of each sentence in the dialogue on the intention of the sentence to be recognized, and reduces the deviation between the recognition result and the true intention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111738017B
    Figure CN111738017B
Patent Text Reader

Abstract

The present invention provides an intention recognition method, device, equipment and storage medium. The method includes obtaining each sentence in a conversation, vectorizing each sentence to obtain a sentence vector of each sentence, merging the sentence vectors of each sentence based on a first preset weight matrix to obtain a merged sentence vector, wherein the first preset weight matrix is ​​used to represent the weight of each sentence in the conversation on the intention of the sentence to be recognized, and the intention influence weight is obtained by training and learning the influence of the intention of the sample sentence based on the sample sentence labeled with the intention and the context sentence of the sample sentence, and determining the intention of the sentence to be recognized based on the merged sentence vector. Since the number of context sentences is not limited and the weight of the influence of each context sentence in the conversation on the intention of the sentence to be recognized is adaptively determined, the problem of inaccurate intention recognition caused by identifying the intention of the sentence in the prior art in combination with the context of fixed weights can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of financial technology (Fintech), and in particular to an intent recognition method, device, equipment and storage medium. Background Art

[0002] With the development of computer technology, more and more technologies are being applied in the financial field. Traditional finance is gradually transforming into financial technology. However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology. In the customer service of the financial field, quickly and accurately identifying the user's intention in human-computer interaction has become a huge challenge for customer service. If the user's intention in the conversation can be identified in time, it will be of great significance to improve the quality of the entire conversation and enhance the user experience.

[0003] The existing intent recognition method is to recognize the intent of a sentence in combination with a fixed-weight context. That is, a fixed number of contexts are selected from the conversation data, and then a fixed weight is configured for the selected context. However, if intent recognition is performed in the above manner, the number of selected contexts and the fixed weights need to be manually defined. Manual selection is greatly affected by subjective experience, which may cause errors due to improper selection of the number and fixed weights, resulting in a large deviation between the recognized intent of the sentence and the true intent, thereby resulting in low accuracy of intent recognition.

[0004] In summary, there is an urgent need for an intent recognition method to solve the problem in the prior art that the intent of a sentence is recognized by combining a context with a fixed weight, resulting in inaccurate intent recognition. Summary of the invention

[0005] The present invention provides an intent recognition method, apparatus, device and storage medium, which are used to solve the problem in the prior art that the intent of a sentence is recognized in combination with a context with a fixed weight, resulting in inaccurate intent recognition.

[0006] In a first aspect, the present invention provides an intention recognition method, comprising:

[0007] Acquire each sentence in the conversation; each sentence in the conversation includes a sentence to be recognized and a context sentence corresponding to the sentence to be recognized;

[0008] Performing vectorization processing on each of the sentences respectively to obtain a sentence vector of each of the sentences;

[0009] Based on a first preset weight matrix, the sentence vectors of the sentences are merged to obtain a merged sentence vector; wherein the first preset weight matrix is ​​used to represent the weight of the intention influence of each sentence in the conversation on the sentence to be identified; the intention influence weight is obtained by training and learning the influence of the intention of the sample sentence based on the sample sentence marked with the intention and the context sentence of the sample sentence;

[0010] Based on the merged sentence vector, the intention of the sentence to be recognized is determined.

[0011] In the above technical solution, the intent recognition is directly performed according to the sentence to be recognized and the context sentences corresponding to the sentence to be recognized, that is, the intent recognition can be performed according to all the context sentences corresponding to the sentence to be recognized, without selecting a fixed number of context sentences, saving the operation steps of sentence selection in the intent recognition process, and not limiting the number of context sentences corresponding to the sentence to be recognized, which can increase the amount of input information for sentence intent recognition and improve the accuracy of sentence intent recognition. In addition, since the intent influence weight in the first preset weight matrix is ​​obtained by training and learning the influence of the intent of the sample sentence based on the sample sentence with the marked intent and the context sentence of the sample sentence, that is, the weight learned by combining the sample of the known intent, the intention influence weight of each sentence in the conversation on the sentence to be recognized can be adaptively determined, which can avoid or reduce the error caused by the manually configured fixed weight, so as to merge the sentence vectors of each sentence based on the intention influence weight of each sentence in the conversation on the sentence to be recognized, and obtain the merged sentence vector, and determine the intent of the sentence to be recognized based on the merged sentence vector, which can reduce the deviation between the sentence intent recognition result and the true intent, thereby improving the accuracy of sentence intent recognition.

[0012] Optionally, performing vectorization processing on each of the sentences to obtain a sentence vector for each of the sentences includes:

[0013] Each of the sentences is input into a vectorization processing model for processing, and based on a second preset weight matrix, the semantic feature vectors output by each layer of the vectorization processing model are adjusted to obtain a sentence vector for each sentence; the second preset weight matrix is ​​used to represent the weights of the semantic feature vectors extracted by each layer in the vectorization processing model.

[0014] Optionally, the step of inputting each sentence into a vectorization processing model for processing, and adjusting the semantic feature vectors output by each layer of the vectorization processing model based on a second preset weight matrix to obtain a sentence vector of each sentence includes:

[0015] For each sentence, the sentence is input into the vectorization processing model for processing to obtain the semantic feature vector outputted by the sentence at each layer, and the semantic feature vector outputted by the sentence at each layer is weighted according to the second preset weight matrix to obtain the sentence vector of the sentence.

[0016] In the above technical solution, each sentence in each sentence is input into the vectorization processing model for processing, and based on the second preset weight matrix, the semantic feature vectors output by each layer of the vectorization processing model are weighted to obtain the sentence vector of each sentence. Since the information level of the context required by the intent recognition model is different when predicting intent, the semantic feature vector output by each sentence at each layer is weighted by the weight of the semantic feature vector extracted from each sentence at each layer, so that the semantic information contained in the sentence vector of each sentence can provide support for accurately identifying the intent of the sentence to be identified. Such processing will be more reasonable and can reduce the deviation between the sentence intent recognition result and the true intent, thereby making intent recognition more accurate.

[0017] Optionally, the merging the sentence vectors of the sentences based on the first preset weight matrix to obtain a merged sentence vector includes:

[0018] Determining the intention impact weight of each sentence based on the first preset weight matrix;

[0019] The sentence vectors of the sentences are weightedly merged according to the intention influence weights of the sentences to obtain the merged sentence vector.

[0020] Optionally, determining the intention impact weight of each sentence based on the first preset weight matrix includes:

[0021] For each sentence, according to the position of the sentence in the conversation, the parameter value at the position in the first preset weight matrix is ​​used as the intention influence weight of the sentence.

[0022] In the above technical solution, the position of each sentence in the conversation is used as the intention influence weight of the sentence by the parameter value at the position in the first preset weight matrix, and the sentence vectors of each sentence are weighted and merged according to the intention influence weight of each sentence to obtain the merged sentence vector. Since the intention influence weight of each sentence is not fixed, but the sentence vectors of each sentence are weighted and merged with different intention influence weights, such processing will be more reasonable, which can reduce the deviation between the sentence intention recognition result and the true intention, thereby making the intention recognition more accurate.

[0023] Optionally, the first preset weight matrix is ​​obtained when training the intent recognition model based on sample sentences with marked intent and context sentences of the sample sentences; the second preset weight matrix is ​​obtained when training the intent recognition model based on sample sentences with marked intent and context sentences of the sample sentences.

[0024] In the above technical solution, a second preset weight matrix is ​​obtained when training the intent recognition model based on sample sentences with labeled intent and context sentences of the sample sentences. That is, since the weights of the semantic feature vectors extracted from each sentence at each layer are different, and the level of context information required by the intent recognition model when predicting intent is different, the semantic feature vectors output from each sentence at each layer are weighted based on the weights of the semantic feature vectors extracted from each sentence at each layer, so that the semantic information contained in the sentence vector of each sentence can provide support for accurately identifying the intent of the sentence to be identified. In addition, a first preset weight matrix is ​​obtained when training the intent recognition model based on sample sentences with labeled intent and context sentences of the sample sentences, that is, the weights learned in combination with samples of known intent are used to adaptively determine the weights of the influence of each sentence in the conversation on the intent of the sentence to be identified, which can avoid or reduce the errors caused by manually configured fixed weights, thereby making intent recognition more accurate.

[0025] Optionally, the first preset weight matrix is ​​obtained when training an intent recognition model based on sample sentences annotated with intent and context sentences of the sample sentences, and includes:

[0026] According to an initial first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process;

[0027] The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial first preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met to obtain the intent recognition model and the first preset weight matrix.

[0028] In the above technical scheme, the merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial first preset weight matrix and the initial intent recognition model are continuously updated by the loss function value obtained by the loss function between the predicted intent and the labeled intent until the training termination condition is met, thereby obtaining the intent recognition model and the first preset weight matrix, which can provide support for accurately identifying the intent of the sentence to be recognized.

[0029] Optionally, the second preset weight matrix is ​​obtained when training the intent recognition model based on the sample sentences annotated with the intent and the context sentences of the sample sentences, and includes:

[0030] For the sample sentence of the marked intention and any sentence in the context sentences of the sample sentence, vectorize the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence;

[0031] According to the first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process;

[0032] The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial second preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met to obtain the intent recognition model and the second preset weight matrix.

[0033] In the above technical scheme, for any sentence, vectorization processing is performed on the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence, and the sentence vectors of each sentence are merged according to the first preset weight matrix to obtain the merged sentence vector, and the merged sentence vector is input into the initial intention recognition model for training to obtain the intention of the sample sentence, and the loss function value obtained by the loss function between the predicted intention and the labeled intention is continuously updated by the initial second preset weight matrix and the initial intention recognition model until the training termination condition is met, and the intention recognition model and the second preset weight matrix are obtained, so that the semantic information contained in the sentence vector of each sentence can provide support for accurately identifying the intention of the sentence to be recognized.

[0034] Optionally, the first preset weight matrix and the second preset weight matrix are obtained when training the intent recognition model based on sample sentences annotated with intent and context sentences of the sample sentences, respectively, and include:

[0035] For the sample sentence of the marked intention and any sentence in the context sentences of the sample sentence, vectorize the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence;

[0036] According to an initial first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process;

[0037] The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial first preset weight matrix, the initial second preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met, thereby obtaining the intent recognition model, the first preset weight matrix and the second preset weight matrix.

[0038] In the above technical scheme, for any sentence, vectorization processing is performed on the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence, and the sentence vectors of each sentence are merged according to the initial first preset weight matrix to obtain the merged sentence vector, and the merged sentence vector is input into the initial intention recognition model for training to obtain the intention of the sample sentence, and the loss function value obtained by the loss function between the predicted intention and the labeled intention is continuously updated with the initial first preset weight matrix, the initial second preset weight matrix and the initial intention recognition model until the training termination condition is met, and the intention recognition model and the first preset weight matrix and the second preset weight matrix are obtained, which can provide support for accurately identifying the intention of the sentence to be recognized.

[0039] Optionally, determining the intention of the sentence to be recognized based on the merged sentence vector includes:

[0040] The merged sentence vector is input into the intention recognition model for recognition to determine the intention of the sentence to be recognized.

[0041] In the above technical solution, by inputting the vector of the sentence to be recognized into the intention recognition model for recognition, the intention of the current sentence can be recognized quickly and accurately.

[0042] In a second aspect, the present invention further provides an intention recognition device, comprising:

[0043] An acquisition unit, configured to acquire each sentence in the conversation; each sentence in the conversation includes a sentence to be recognized and a context sentence corresponding to the sentence to be recognized;

[0044] A processing unit is used to vectorize each of the sentences respectively to obtain a sentence vector of each sentence; based on a first preset weight matrix, the sentence vectors of each sentence are merged to obtain a merged sentence vector; wherein the first preset weight matrix is ​​used to represent the influence weight of each sentence in the conversation on the intention of the sentence to be identified; the intention influence weight is obtained by training and learning the influence of the intention of the sample sentence based on sample sentences with marked intentions and context sentences of the sample sentences; based on the merged sentence vector, the intention of the sentence to be identified is determined.

[0045] Optionally, the processing unit is specifically configured to:

[0046] Each of the sentences is input into a vectorization processing model for processing, and based on a second preset weight matrix, the semantic feature vectors output by each layer of the vectorization processing model are adjusted to obtain a sentence vector for each sentence; the second preset weight matrix is ​​used to represent the weights of the semantic feature vectors extracted by each layer in the vectorization processing model.

[0047] Optionally, the processing unit is specifically configured to:

[0048] For each sentence, the sentence is input into the vectorization processing model for processing to obtain the semantic feature vector outputted by the sentence at each layer, and the semantic feature vector outputted by the sentence at each layer is weighted according to the second preset weight matrix to obtain the sentence vector of the sentence.

[0049] Optionally, the processing unit is specifically configured to:

[0050] Based on the first preset weight matrix, determining the intention impact weight of each sentence;

[0051] The sentence vectors of the sentences are weightedly merged according to the intention influence weights of the sentences to obtain the merged sentence vector.

[0052] Optionally, the processing unit is specifically configured to:

[0053] For each sentence, according to the position of the sentence in the conversation, the parameter value at the position in the first preset weight matrix is ​​used as the intention influence weight of the sentence.

[0054] Optionally, the processing unit is specifically configured to:

[0055] The first preset weight matrix is ​​obtained when training the intent recognition model based on sample sentences with marked intent and the context sentences of the sample sentences; the second preset weight matrix is ​​obtained when training the intent recognition model based on sample sentences with marked intent and the context sentences of the sample sentences.

[0056] Optionally, the processing unit is specifically configured to:

[0057] According to an initial first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process;

[0058] The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial first preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met to obtain the intent recognition model and the first preset weight matrix.

[0059] Optionally, the processing unit is specifically configured to:

[0060] For the sample sentence of the marked intention and any sentence in the context sentences of the sample sentence, vectorize the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence;

[0061] According to the first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process;

[0062] The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial second preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met to obtain the intent recognition model and the second preset weight matrix.

[0063] Optionally, the processing unit is specifically configured to:

[0064] For the sample sentence of the marked intention and any sentence in the context sentences of the sample sentence, vectorize the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence;

[0065] According to an initial first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process;

[0066] The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial first preset weight matrix, the initial second preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met, thereby obtaining the intent recognition model, the first preset weight matrix and the second preset weight matrix.

[0067] Optionally, the processing unit is specifically configured to:

[0068] The merged sentence vector is input into the intention recognition model for recognition to determine the intention of the sentence to be recognized.

[0069] In a third aspect, the present invention provides a computing device, comprising:

[0070] Memory for storing computer programs;

[0071] The processor is used to call the computer program stored in the memory and execute the intention recognition method according to the obtained program.

[0072] In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer-executable program for causing a computer to execute an intent recognition method. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0074] Figure 1 A schematic diagram of a system architecture provided for an embodiment of the present invention;

[0075] Figure 2 A flowchart of an intent recognition method provided by an embodiment of the present invention;

[0076] Figure 3 A schematic diagram of the structure of an intention recognition device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0077] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0078] Figure 1 A system architecture is provided for an embodiment of the present invention. Figure 1 As shown, the system architecture may be a server 100 , including a processor 110 , a communication interface 120 , and a memory 130 .

[0079] The communication interface 120 is used to communicate with the terminal device, send and receive information transmitted by the terminal device, and realize communication.

[0080] The processor 110 is the control center of the server 100, and uses various interfaces and lines to connect various parts of the entire server 100, and executes various functions of the server 100 and processes data by running or executing software programs and / or modules stored in the memory 130, and calling data stored in the memory 130. Optionally, the processor 110 may include one or more processing units.

[0081] The memory 130 can be used to store software programs and modules. The processor 110 executes various functional applications and data processing by running the software programs and modules stored in the memory 130. The memory 130 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc.; the data storage area can store data created according to business processing, etc. In addition, the memory 130 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0082] It should be noted that the above Figure 1 The structure shown is only an example and is not limited to this embodiment of the present invention.

[0083] Based on the above description, Figure 2 The process of an intention recognition method provided by an embodiment of the present invention is exemplarily shown, and the process can be executed by an intention recognition device.

[0084] like Figure 2 As shown in the figure, the process specifically includes:

[0085] Step 201, obtaining each sentence in the conversation.

[0086] In the embodiment of the present invention, each sentence in the conversation can be a sentence to be recognized in a round of conversation and a context sentence corresponding to the sentence to be recognized. That is to say, the embodiment of the present invention performs intent recognition based on all context sentences corresponding to the sentence to be recognized, without selecting a fixed number of context sentences, which can save the operation steps of sentence selection in the intent recognition process, and does not limit the number of context sentences corresponding to the sentence to be recognized, thereby increasing the amount of input information for sentence intent recognition.

[0087] Step 202, vectorize each of the sentences to obtain a sentence vector for each of the sentences.

[0088] In an embodiment of the present invention, for each sentence in each sentence, the sentence is input into a vectorization processing model for processing to obtain a semantic feature vector outputted by the sentence at each layer, and the semantic feature vector outputted by the sentence at each layer is weighted according to a second preset weight matrix to obtain a sentence vector of the sentence, thereby obtaining a sentence vector of each sentence. Among them, the second preset weight matrix is ​​used to represent the weights of the semantic feature vectors extracted at each layer in the vectorization processing model, and the second preset weight matrix is ​​obtained when training the intent recognition model based on sample sentences with annotated intents and context sentences of the sample sentences. Since the level of information of the context required by the intent recognition model is different when predicting intent, the semantic feature vector outputted by each sentence at each layer is weighted by the weight of the semantic feature vector extracted by each sentence at each layer, so that the semantic information contained in the sentence vector of each sentence can provide support for accurately identifying the intent of the sentence to be identified. Such processing will be more reasonable, and the deviation between the sentence intent recognition result and the true intent can be reduced, thereby making the intent recognition more accurate.

[0089] Specifically, when training the intent recognition model to obtain the second preset weight matrix, first obtain a training sample with annotated intent, the training sample consists of a sample sentence with annotated intent and a context sentence of the sample sentence, and for any sentence in the sample sentence with annotated intent and the context sentence of the sample sentence, vectorize the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence, and merge the sentence vector of the sample sentence with annotated intent and the sentence vector of the context sentence of the sample sentence according to the first preset weight matrix to obtain the merged sentence vector, and then input the merged sentence vector into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and update the initial second preset weight matrix and the initial intent recognition model through the loss function between the predicted intent and the annotated intent until the training termination condition is met to obtain the intent recognition model and the second preset weight matrix.

[0090] Further, construct a training data set T = {(x 1 ,y1 ), (x 2 ,y 2 ),…,(x n ,y n )}, where n is the number of data, x represents the user's current input and all the input data of the user before the current input in this round of dialogue, and y represents the intention corresponding to the current input. Each data is composed of the current sentence input by the user and the historical sentences input by the user before the current sentence in this round of dialogue. Randomly initialize the parameter matrix U, vectorize the training data, and the result of vectorizing input x is Where k is the number of sentences in this round of dialogue up to the current input (including the current input), e i is the vector representation of the i-th sentence, W is the parameter matrix, that is, for each e i At the same time, the vector of each sentence can be obtained through a deep pre-training model (such as BERT, etc.), Where m is the number of layers in the model, e l is the output vector of each layer, U is the parameter matrix, that is, for each e l The weights are obtained through training and learning; in addition, the label y can be vectorized using one-hot. The vectorized training data is then input into the preset classification model for training to obtain the intent recognition model, where the preset classification model can be a traditional machine learning model, such as support vector machine, logistic regression, etc., or a deep learning model, such as convolutional neural network, etc., which can be selected according to the complexity of the task.

[0091] During the training and learning process, the initial U and the preset classification model are updated by the loss function value obtained by the loss function between the predicted intent of the vectorized training data and the true intent corresponding to each training data in the vectorized and merged training data until the training termination condition is met, and the intent recognition model and U are obtained. When predicting, for the sentence input by the user, the predetermined W and the U obtained by training and learning are used and the context is integrated for vectorization, and then input into the trained intent recognition model for recognition, and the intent of the sentence input by the user is recognized.

[0092] Step 203: Based on the first preset weight matrix, the sentence vectors of the sentences are merged to obtain a merged sentence vector.

[0093] In an embodiment of the present invention, for each sentence in each sentence, according to the position of the sentence in the conversation, the parameter value at the position in the first preset weight matrix is ​​used as the intention influence weight of the sentence, thereby obtaining the intention influence weight of each sentence, and the sentence vectors of each sentence are weighted and merged according to the intention influence weight of each sentence to obtain the merged sentence vector. Among them, the first preset weight matrix is ​​used to represent the intention influence weight of each sentence in the conversation on the sentence to be recognized, and the intention influence weight is obtained when the intention recognition model is trained based on the sample sentences with labeled intentions and the context sentences of the sample sentences. The first preset weight matrix is ​​obtained when the intention recognition model is trained based on the sample sentences with labeled intentions and the context sentences of the sample sentences, that is, the weights learned by combining the samples of known intentions are used to adaptively determine the intention influence weight of each sentence in the conversation on the sentence to be recognized, which can avoid or reduce the errors caused by the manually configured fixed weights, thereby making the intention recognition more accurate.

[0094] Specifically, when training the intent recognition model to obtain the first preset weight matrix, first obtain training samples with labeled intent, the training samples consist of sample sentences with labeled intent and context sentences of the sample sentences, and according to the first preset weight matrix, merge the sentence vectors of the sample sentences with labeled intent and the sentence vectors of the context sentences of the sample sentences to obtain the merged sentence vectors, and input the merged sentence vectors into the initial intent recognition model for training to obtain the predicted intent of the sample sentences, and update the initial first preset weight matrix and the initial intent recognition model through the loss function between the predicted intent and the labeled intent until the training termination condition is met to obtain the intent recognition model and the first preset weight matrix.

[0095] Furthermore, the training data set T is used as the training initial intention recognition model to obtain the training sample set of the intention recognition model and the first preset weight matrix, and the training data set T = {(x 1 ,y 1 ), (x 2 ,y 2 ),…,(x n ,y n )}, where n is the number of data, x represents the user's current input and all the input data of the user before the current input in this round of dialogue, and y represents the intention corresponding to the current input. Each data is composed of the current sentence input by the user and the historical sentences input by the user before the current sentence in this round of dialogue. Randomly initialize the parameter matrix W, vectorize the training data, and the result of vectorizing input x is Where k is the number of sentences in this round of dialogue up to the current input (including the current input), e i is the vector representation of the i-th sentence, W is the parameter matrix, that is, for each ei The weights are obtained through training and learning; at the same time, the vector of each sentence can be obtained through a deep pre-training model (such as BERT, etc.), Where m is the number of layers in the model, e l is the output vector of each layer, U is the parameter matrix, that is, for each e l The weight of y can be used; in addition, the label y can be vectorized using one-hot. The vectorized training data is then input into a preset classification model for training to obtain an intent recognition model. The preset classification model can be a traditional machine learning model, such as a support vector machine, logistic regression, etc., or a deep learning model, such as a convolutional neural network, etc., which can be selected according to the complexity of the task.

[0096] During the training and learning process, the initial W and the preset classification model are updated by the loss function value obtained by the loss function between the predicted intent of the vectorized training data and the true intent corresponding to each training data in the vectorized and merged training data until the training termination condition is met, and the intent recognition model and W are obtained. When predicting, for the sentence input by the user, the predetermined U and the W obtained by training and learning are used and the context is integrated for vectorization, and then input into the trained intent recognition model for recognition, so as to identify the intent of the sentence input by the user.

[0097] It should be noted that the first preset weight matrix, the second preset weight matrix and the intent recognition model can also be obtained simultaneously when training the intent recognition model based on the sample sentences with labeled intent and the context sentences of the sample sentences. Specifically, first obtain a training sample with labeled intent, the training sample consists of the sample sentences with labeled intent and the context sentences of the sample sentences, for any sentence in the sample sentences with labeled intent and the context sentences of the sample sentences, the sentence is vectorized according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence, and according to the initial first preset weight matrix, the sentence vector of the sample sentences with labeled intent and the sentence vector of the context sentences of the sample sentences are merged to obtain the merged sentence vector, and then the merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentences, and the initial first preset weight matrix, the initial second preset weight matrix and the initial intent recognition model are updated by the loss function between the predicted intent and the labeled intent until the training termination condition is met, and the intent recognition model, the first preset weight matrix and the second preset weight matrix are obtained.

[0098] Specifically, the above training data set T is used as the training initial intention recognition model to obtain the training sample set of the intention recognition model, the first preset weight matrix and the second preset weight matrix, and the training data set T = {(x 1,y 1 ), (x 2 ,y 2 ),…,(x n ,y n )}, where n is the number of data, x represents the user's current input and all the input data of the user before the current input in this round of dialogue, and y represents the intention corresponding to the current input. Each data is composed of the current sentence input by the user and the historical sentences input by the user before the current sentence in this round of dialogue. Randomly initialize the parameter matrices W and U, vectorize the training data, and the result of vectorizing input x is Where k is the number of sentences in this round of dialogue up to the current input (including the current input), e i is the vector representation of the i-th sentence, W is the parameter matrix, that is, for each e i The weights are obtained through training and learning; at the same time, the vector of each sentence can be obtained through a deep pre-training model (such as BERT, etc.), Where m is the number of layers in the model, e l is the output vector of each layer, U is the parameter matrix, that is, for each e l The weight of is also obtained through training and learning; in addition, the label y can be vectorized using one-hot. The vectorized training data is then input into the preset classification model for training to obtain the intent recognition model, where the preset classification model can be a traditional machine learning model, such as support vector machine, logistic regression, etc., or a deep learning model, such as convolutional neural network, etc., which can be selected according to the complexity of the task.

[0099] During the training and learning process, the initial W, initial U and the preset classification model are updated by the loss function value obtained by the loss function between the predicted intent of the vectorized training data and the true intent corresponding to each training data in the vectorized and merged training data until the training termination condition is met, and the intent recognition model, W and U are obtained. When predicting, for the sentence input by the user, the W and U obtained by training and learning are used and the context is integrated for vectorization, and then input into the trained intent recognition model for recognition, so as to identify the intent of the sentence input by the user.

[0100] Step 204: Determine the intention of the sentence to be recognized based on the merged sentence vector.

[0101] In the embodiment of the present invention, the merged sentence vector is input into the intention recognition model for recognition to determine the intention of the sentence to be recognized.

[0102] The above embodiments show that by directly performing intent recognition based on the sentences to be recognized and the context sentences corresponding to the sentences to be recognized, that is, intent recognition can be performed based on all the context sentences corresponding to the sentences to be recognized, without selecting a fixed number of context sentences, saving the operation steps of sentence selection in the intent recognition process, and not limiting the number of context sentences corresponding to the sentences to be recognized, the amount of input information for sentence intent recognition can be increased, and the accuracy of sentence intent recognition can be improved. In addition, since the intent influence weights in the first preset weight matrix are obtained by training and learning the influence of the intent of the sample sentences based on the sample sentences with labeled intent and the context sentences of the sample sentences, that is, the weights learned by combining the samples of known intents can be used to adaptively determine the intent influence weights of each sentence in the conversation on the sentence to be recognized, which can avoid or reduce the errors caused by the manually configured fixed weights, thereby merging the sentence vectors of each sentence based on the intent influence weights of each sentence in the conversation on the sentence to be recognized, and obtaining the merged sentence vector, and determining the intent of the sentence to be recognized based on the merged sentence vector, which can reduce the deviation between the sentence intent recognition result and the true intent, thereby improving the accuracy of sentence intent recognition.

[0103] Based on the same technical concept, Figure 3 An intention recognition device provided by an embodiment of the present invention is exemplarily shown, and the device can execute the process of the intention recognition method.

[0104] like Figure 3 As shown, the device comprises:

[0105] An acquisition unit 301 is used to acquire each sentence in the conversation; each sentence in the conversation includes a sentence to be recognized and a context sentence corresponding to the sentence to be recognized;

[0106] The processing unit 302 is used to vectorize each of the sentences respectively to obtain the sentence vector of each sentence; based on the first preset weight matrix, the sentence vectors of each sentence are merged to obtain the merged sentence vector; wherein the first preset weight matrix is ​​used to represent the influence weight of each sentence in the conversation on the intention of the sentence to be identified; the intention influence weight is obtained by training and learning the influence of the intention of the sample sentence based on the sample sentences marked with the intention and the context sentences of the sample sentences; based on the merged sentence vector, the intention of the sentence to be identified is determined.

[0107] Optionally, the processing unit 302 is specifically configured to:

[0108] Each of the sentences is input into a vectorization processing model for processing, and based on a second preset weight matrix, the semantic feature vectors output by each layer of the vectorization processing model are adjusted to obtain a sentence vector for each sentence; the second preset weight matrix is ​​used to represent the weights of the semantic feature vectors extracted by each layer in the vectorization processing model.

[0109] Optionally, the processing unit 302 is specifically configured to:

[0110] For each sentence, the sentence is input into the vectorization processing model for processing to obtain the semantic feature vector outputted by the sentence at each layer, and the semantic feature vector outputted by the sentence at each layer is weighted according to the second preset weight matrix to obtain the sentence vector of the sentence.

[0111] Optionally, the processing unit 302 is specifically configured to:

[0112] Based on the first preset weight matrix, determining the intention impact weight of each sentence;

[0113] The sentence vectors of the sentences are weightedly merged according to the intention influence weights of the sentences to obtain the merged sentence vector.

[0114] Optionally, the processing unit 302 is specifically configured to:

[0115] For each sentence, according to the position of the sentence in the conversation, the parameter value at the position in the first preset weight matrix is ​​used as the intention influence weight of the sentence.

[0116] Optionally, the processing unit 302 is specifically configured to:

[0117] The first preset weight matrix is ​​obtained when training the intent recognition model based on sample sentences with marked intent and the context sentences of the sample sentences; the second preset weight matrix is ​​obtained when training the intent recognition model based on sample sentences with marked intent and the context sentences of the sample sentences.

[0118] Optionally, the processing unit 302 is specifically configured to:

[0119] According to an initial first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process;

[0120] The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial first preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met to obtain the intent recognition model and the first preset weight matrix.

[0121] Optionally, the processing unit 302 is specifically configured to:

[0122] For the sample sentence of the marked intention and any sentence in the context sentences of the sample sentence, vectorize the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence;

[0123] According to the first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process;

[0124] The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial second preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met to obtain the intent recognition model and the second preset weight matrix.

[0125] Optionally, the processing unit 302 is specifically configured to:

[0126] For the sample sentence of the marked intention and any sentence in the context sentences of the sample sentence, vectorize the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence;

[0127] According to an initial first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process;

[0128] The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial first preset weight matrix, the initial second preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met, thereby obtaining the intent recognition model, the first preset weight matrix and the second preset weight matrix.

[0129] Optionally, the processing unit 302 is specifically configured to:

[0130] The merged sentence vector is input into the intention recognition model for recognition to determine the intention of the sentence to be recognized.

[0131] Based on the same technical concept, an embodiment of the present invention provides a computing device, including:

[0132] Memory for storing computer programs;

[0133] The processor is used to call the computer program stored in the memory and execute the intention recognition method according to the obtained program.

[0134] Based on the same technical concept, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer-executable program, and the computer-executable program is used to enable a computer to execute an intention recognition method.

[0135] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0136] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0137] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0139] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0140] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of this application and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for intention recognition, characterized in that: include: Acquire each sentence in the conversation; each sentence in the conversation includes a sentence to be recognized and a context sentence corresponding to the sentence to be recognized; Performing vectorization processing on each of the sentences respectively to obtain a sentence vector of each of the sentences; Based on a first preset weight matrix, the sentence vectors of the sentences are merged to obtain a merged sentence vector; wherein the first preset weight matrix is ​​used to represent the weight of the intention influence of each sentence in the conversation on the sentence to be identified; the intention influence weight is obtained by training and learning the influence of the intention of the sample sentence based on the sample sentence marked with the intention and the context sentence of the sample sentence; Determining the intention of the sentence to be identified based on the merged sentence vector; The vectorization processing is performed on each of the sentences to obtain a sentence vector of each of the sentences, including: Each of the sentences is input into a vectorization processing model for processing, and based on a second preset weight matrix, the semantic feature vectors output by each layer of the vectorization processing model are adjusted to obtain a sentence vector for each sentence; the second preset weight matrix is ​​used to represent the weights of the semantic feature vectors extracted by each layer in the vectorization processing model.

2. The method according to claim 1, characterized in that The step of inputting each sentence into a vectorization processing model for processing, and adjusting the semantic feature vectors output by each layer of the vectorization processing model based on a second preset weight matrix to obtain a sentence vector of each sentence includes: For each sentence, the sentence is input into the vectorization processing model for processing to obtain the semantic feature vector outputted by the sentence at each layer, and the semantic feature vector outputted by the sentence at each layer is weighted according to the second preset weight matrix to obtain the sentence vector of the sentence.

3. The method according to claim 1, characterized in that The merging the sentence vectors of the sentences based on the first preset weight matrix to obtain the merged sentence vectors includes: Based on the first preset weight matrix, determining the intention impact weight of each sentence; The sentence vectors of the sentences are weightedly merged according to the intention influence weights of the sentences to obtain the merged sentence vector.

4. The method according to claim 3, characterized in that The determining, based on the first preset weight matrix, the intention impact weight of each sentence includes: For each sentence, according to the position of the sentence in the conversation, the parameter value at the position in the first preset weight matrix is ​​used as the intention influence weight of the sentence.

5. The method according to any one of claims 1 to 4, characterized in that: The first preset weight matrix is ​​obtained when training the intent recognition model based on the sample sentences annotated with the intent and the context sentences of the sample sentences, and includes: According to an initial first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process; The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial first preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met to obtain the intent recognition model and the first preset weight matrix.

6. The method according to any one of claims 1 to 4, characterized in that: The second preset weight matrix is ​​obtained when training the intent recognition model based on the sample sentences annotated with the intent and the context sentences of the sample sentences, and includes: For the sample sentence of the marked intention and any sentence in the context sentences of the sample sentence, vectorize the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence; According to the first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process; The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial second preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met to obtain the intent recognition model and the second preset weight matrix.

7. The method according to any one of claims 1 to 4, characterized in that The first preset weight matrix and the second preset weight matrix are obtained when training the intent recognition model based on sample sentences annotated with intent and context sentences of the sample sentences, respectively, and include: For the sample sentence of the marked intention and any sentence in the context sentences of the sample sentence, vectorize the sentence according to the initial second preset weight matrix and the vectorization processing model to obtain the sentence vector of the sentence; According to an initial first preset weight matrix, merging the sentence vector of the sample sentence of the labeled intention and the sentence vector of the context sentence of the sample sentence to obtain the sentence vector after the merging process; The merged sentence vector is input into the initial intent recognition model for training to obtain the predicted intent of the sample sentence, and the initial first preset weight matrix, the initial second preset weight matrix and the initial intent recognition model are updated through the loss function between the predicted intent and the labeled intent until the training termination condition is met, thereby obtaining the intent recognition model, the first preset weight matrix and the second preset weight matrix.

8. An intention recognition device, characterized in that: include: An acquisition unit, configured to acquire each sentence in the conversation; each sentence in the conversation includes a sentence to be recognized and a context sentence corresponding to the sentence to be recognized; A processing unit, configured to perform vectorization processing on each of the sentences to obtain a sentence vector of each of the sentences; and to merge the sentence vectors of each of the sentences based on a first preset weight matrix to obtain a merged sentence vector; wherein the first preset weight matrix is ​​used to represent the weight of the influence of each sentence in the conversation on the intention of the sentence to be identified; The intention influence weight is obtained by training and learning the influence of the intention of the sample sentence based on the sample sentence marked with the intention and the context sentence of the sample sentence; based on the merged sentence vector, determining the intention of the sentence to be identified; When the processing unit performs vectorization processing on each of the sentences respectively to obtain the sentence vector of each sentence, it is specifically used to: input each of the sentences into the vectorization processing model for processing, and adjust the semantic feature vectors output by each layer of the vectorization processing model based on a second preset weight matrix to obtain the sentence vector of each sentence; the second preset weight matrix is ​​used to represent the weights of the semantic feature vectors extracted by each layer in the vectorization processing model.

9. A computing device, characterized in that include: Memory for storing computer programs; A processor, configured to call a computer program stored in the memory, and execute the method according to any one of claims 1 to 7 according to the obtained program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer-executable program, and the computer-executable program is used to enable a computer to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for distinguishing consumption intention

    CN103412882A

  • Semantic analysis method and device

    CN108509411A

  • Question and answer pair extraction method and system based on BiLSTM-CRF model and storage medium

    CN110188175A

  • Conversation generation method and system, readable storage medium and computer equipment

    CN110321417A

  • Emotion dialogue generation method and device based on self-attention mechanism

    CN110427490A