Intention recognition method, device, electronic device and computer readable storage medium

By receiving target statements in intention recognition, building a matrix of predetermined dimensions and combining an intention recognition classifier, the problem of poor recognition effect caused by the difference in user expression length is solved, and the accuracy and interaction effect of intention recognition are improved.

CN114881045BActive Publication Date: 2024-12-20INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210563900.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-23
Publication Date
2024-12-20
Estimated Expiration
2042-05-23

AI Technical Summary

Technical Problem

The existing intention recognition model has poor recognition effect when dealing with large differences in the length of user statements, resulting in the impact of interaction effects, and no effective solution has been available.

Method used

By receiving the target statement, a matrix consisting of a predetermined number of word vectors of predetermined dimensions is determined, and an intention recognition classifier is used to predict the intent category to which the target statement belongs, including splitting the statement as the target word, supplementing the zero vector, performing nonlinear transformation and multi-header Attention mechanism processing, machine training is carried out in combination with training samples, weight values ​​and normalization are obtained to improve recognition accuracy.

Benefits of technology

It effectively avoids the problem of inaccurate identification caused by the difference in length of user expression sentences, improves the accuracy of intention prediction and the accuracy of multi-classification tasks, and reduces the phenomenon of answering non-questions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114881045B_ABST
    Figure CN114881045B_ABST
Patent Text Reader

Abstract

The present invention discloses an intent recognition method, device, electronic device and computer-readable storage medium. The method comprises: receiving a target sentence based on a predetermined task; determining a first matrix corresponding to the target sentence, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as the value of the predetermined dimension; and according to the first matrix, using an intent recognition classifier to predict the target intent category to which the target sentence belongs. The present invention solves the technical problem of poor prediction effect when predicting the intent expressed by the user's sentence in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to an intent recognition method, device, electronic device and computer-readable storage medium. Background Art

[0002] In recent years, with the rapid development and application of speech recognition, speech synthesis and intelligent mobile terminals, communication between people and computers through natural language has gradually become an important way of interaction.

[0003] Classic human-computer interaction systems generally include three main parts: intent recognition, dialogue management, and language generation. Among them, intent recognition is a primary and basic link for whether intelligent interaction systems can conduct accurate and effective dialogues. However, due to the complexity of intelligent interaction environments and the diversity of user expressions, dialogue systems often make mistakes in recognizing user intent, which greatly affects the effect of interaction. In addition, most existing intent recognition models can achieve good results for intent recognition of a specific length, but the recognition effect is poor when the length of user expressions varies greatly. Therefore, there is an urgent need to propose more effective solutions for expressions with large differences in users in intelligent interactions.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] Embodiments of the present invention provide an intent recognition method, device, electronic device, and computer-readable storage medium to at least solve the technical problem of poor prediction effect when predicting the intent expressed by a user's sentence in the related art.

[0006] According to one aspect of an embodiment of the present invention, there is provided an intent recognition method, comprising: receiving a target sentence based on a predetermined task; determining a first matrix corresponding to the target sentence, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as the value of the predetermined dimension; based on the first matrix, using an intent recognition classifier to predict a target intent category to which the target sentence belongs.

[0007] Optionally, determining the first matrix corresponding to the target sentence includes: splitting the target sentence into a second predetermined number of target words; determining the second predetermined number of target word vectors of the predetermined dimension based on the second predetermined number of target words; when the second predetermined number is lower than the first predetermined number, supplementing a third predetermined number of zero vectors of the predetermined dimension to obtain the first matrix, wherein the sum of the second predetermined number and the third predetermined number is the first predetermined number.

[0008] Optionally, based on the first matrix, using an intent recognition classifier to predict the target intent category to which the target sentence belongs includes: based on the first matrix, using an intent recognition classifier to predict the probability that the target sentence belongs to each of multiple intent categories, and determining the maximum probability among the probabilities of belonging to the multiple intent categories; comparing the maximum probability with a predetermined threshold; and when the maximum probability is greater than the predetermined threshold, determining that the intent category corresponding to the maximum probability is the target intent category expressed by the target sentence.

[0009] Optionally, before predicting the target intent category to which the target sentence belongs using the intent recognition classifier based on the first matrix, the method further includes: obtaining training samples, wherein the training samples include a first sample matrix, a second sample matrix, a first sample intent category to which a first sample sentence corresponding to the first sample matrix belongs, and a second sample intent category to which a second sample sentence corresponding to the second sample matrix belongs, the second sample sentence being a sample sentence obtained by back-translating the first sample sentence; and performing machine training based on the training samples to obtain the intent recognition classifier.

[0010] Optionally, based on the first matrix, an intent recognition classifier is used to predict the target intent category to which the target sentence belongs, including: performing a nonlinear transformation on the first matrix and the second matrix to obtain a third matrix, wherein the second matrix is ​​a matrix obtained by transposing the first matrix; applying a multi-head attention mechanism based on a hidden method to the third matrix to obtain a fourth matrix; based on the first matrix and the fourth matrix, a fifth matrix is ​​obtained; and the fifth matrix is ​​input into the intent recognition classifier to predict the target intent category to which the target sentence belongs.

[0011] Optionally, obtaining the fifth matrix based on the first matrix and the fourth matrix includes: determining a first predetermined number of weight values ​​corresponding to the target sentence; obtaining a first predetermined number of seventh matrices based on the first predetermined number of weight values, the fourth matrix and the sixth matrix, wherein the sixth matrix is ​​a matrix obtained by normalizing the first matrix; and concatenating the first predetermined number of seventh matrices to obtain the fifth matrix.

[0012] According to one aspect of an embodiment of the present invention, there is provided an intent recognition device, comprising: a receiving module for receiving a target sentence based on a predetermined task; a determining module for determining a first matrix corresponding to the target sentence, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as the value of the predetermined dimension; and a predicting module for predicting a target intent category to which the target sentence belongs using an intent recognition classifier based on the first matrix.

[0013] According to one aspect of an embodiment of the present invention, there is provided an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement any one of the above-described intent recognition methods.

[0014] According to one aspect of an embodiment of the present invention, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the above-mentioned intent recognition methods.

[0015] According to one aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the above-mentioned intention recognition methods.

[0016] In an embodiment of the present invention, a target sentence based on a predetermined task is received, and a first matrix corresponding to the target sentence is determined, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as the value of the predetermined dimension. This can avoid the problem of inaccurate recognition caused by the difference in length of the sentence expressed by the user, and then based on the first matrix, a matrix of a predetermined number of predetermined dimensions is processed, and an intention recognition classifier is used to predict the target intention category to which the target sentence belongs, thereby solving the technical problem of poor prediction effect when predicting the intention expressed by the user's sentence in the related art. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0018] Figure 1 is a flowchart of an intention recognition method according to an embodiment of the present invention;

[0019] Figure 2 is a flowchart of an intention recognition method provided according to an optional embodiment of the present invention;

[0020] Figure 3 4 is a structural block diagram of an intention recognition device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0021] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0023] Example 1

[0024] According to an embodiment of the present invention, an embodiment of an intent recognition method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0025] Figure 1 is a flow chart of an intention recognition method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0026] Step S102, receiving a target sentence based on a predetermined task;

[0027] Step S104, determining a first matrix corresponding to the target sentence, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as the value of the predetermined dimension;

[0028] Step S106: Based on the first matrix, an intent recognition classifier is used to predict the target intent category to which the target sentence belongs.

[0029] Through the above steps, by receiving the target sentence based on the predetermined task, the first matrix corresponding to the target sentence is determined, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as the value of the predetermined dimension. Thus, the problem of inaccurate recognition caused by the difference in the length of the sentence expressed by the user can be avoided, and then based on the first matrix, the matrix of the predetermined number of dimensions is processed, and the target intent category to which the target sentence belongs is predicted by the intent recognition classifier, thereby solving the technical problem of poor prediction effect when predicting the intent expressed by the user's sentence in the related art.

[0030] As an optional embodiment, a target statement based on a predetermined task is received. The predetermined task may be a task based on a scenario setting. For example, in a banking scenario, the predetermined task is a financial task. The predetermined task is also related to the target intent category. For example, when the predetermined task is a financial task, a finance-related intent category can be derived. The finance-related intent category can be customized, such as product consulting, after-sales service, account processing, and so on. By setting a predetermined task, the scenario, task, and intent category can be linked together to make a more targeted judgment.

[0031] Among them, the target sentence can be obtained through various ways. For example, in the real-time scenario of human-computer dialogue, the words spoken by the user to the machine are the target sentences, which are applied to the practical application level to determine the user's target intention category based on the user's target sentence. For example, it can also be obtained through recording, and the words expressed by the user in the recording are the target sentences, which are applied to the test level to determine the user's target intention category based on the user's target sentence, and detect whether it is the same as the actual intention category. It can also be applied to the training level, through target sentences based on predetermined tasks, and target sentences with different expressions, so that the target intention category obtained can be more accurate.

[0032] As an optional embodiment, a first matrix corresponding to the target sentence is determined, and the first matrix can represent the semantics of the target object, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as the value of the predetermined dimension. Generally speaking, the dimension can be customized according to the actual application and scenario. For example, when using the BERT (Bidirectional Encoder Representation from Transformers, pre-trained language representation) model, the dimension can be set to 512 to be suitable for the model. Among them, the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension. By setting the predetermined number and the predetermined dimension, the situation where the length difference is large can be avoided.

[0033] As an optional embodiment, when determining the first matrix corresponding to the target sentence, in order to avoid the situation where the length difference is large, a zero-filling vector method can be adopted, that is, the first matrix can be determined by the following steps: split the target sentence into a second predetermined number of target words. Among them, the second predetermined number can be the number of words included in the target sentence, or the number of remaining words after preprocessing the target sentence. For example, it can be the number of remaining words obtained by performing data cleaning on the target sentence through the nltk (Natural Language Toolkit, natural language processing) toolkit, removing punctuation, names, numbers and other interference information, and obtaining the target word vector of the remaining words. Then, based on the second predetermined number of target words, determine the target word vector of the second predetermined number of predetermined dimensions. When the second predetermined number is lower than the first predetermined number, supplement the zero vector of the third predetermined number of predetermined dimensions to obtain the first matrix, wherein the sum of the second predetermined number and the third predetermined number is the first predetermined number. It is ensured that the first matrix obtained is of a predetermined number and a predetermined dimension, and can be better processed in the subsequent process.

[0034] As an optional embodiment, according to the first matrix, an intention recognition classifier is used to predict the target intent category to which the target sentence belongs. It is explained above that the first matrix can represent the semantics of the target object, but in the target sentence, it contains expressions that are very relevant to the target intent category and expressions that are not very relevant to the target intent category. In order to distinguish different expressions in the same target sentence, the first matrix can be further processed. The first matrix and the second matrix obtained by transposing the first matrix can be nonlinearly transformed to obtain a third matrix, and then the third matrix is ​​subjected to a multi-head attention mechanism based on a hidden method to obtain a fourth matrix. Among them, the matrix is ​​processed by a multi-head attention mechanism based on a hidden method, which can weaken the 0 vector without any meaning, and the real user description part is quantitatively converted to a high order of magnitude, so that the 0 vector is small enough to capture the effective features of the target sentence. So that when the intention recognition classifier is used in the subsequent use, it can be better predicted based on the matrix. That is, according to the first matrix and the fourth matrix, the fifth matrix is ​​obtained, and when the fifth matrix is ​​input into the intention recognition classifier, the target intent category to which the target sentence belongs can be more accurately predicted.

[0035] As an optional embodiment, when obtaining the fifth matrix based on the first matrix and the fourth matrix, the first predetermined number of weight values ​​corresponding to the target sentence can be determined first, and the weight value can be the weight value obtained when the matrix is ​​normalized, or it can be a weight value obtained by other means. For the supplementary 0 vector, the weight value can be set to 0, or it can be set to an extremely low weight value. Thus, based on the first predetermined number of weight values, the fourth matrix and the sixth matrix, the first predetermined number of seventh matrices are obtained, wherein the sixth matrix is ​​a matrix obtained by normalizing the first matrix, and the first predetermined number of seventh matrices are spliced ​​to obtain the fifth matrix. Through normalization, simple, accurate and quantitative results can be obtained. By obtaining the weight value and then processing the matrix, the spliced ​​fifth matrix can better express which aspects are important and which aspects are not important, can better balance and make trade-offs, and can pay more attention to effective expression.

[0036] As an optional embodiment, when the target intent category to which the target sentence belongs is predicted by the intent recognition classifier according to the first matrix, the probability that the target sentence belongs to each intent category in multiple intent categories can also be predicted by the intent recognition classifier according to the first matrix, and the maximum probability among the probabilities belonging to multiple intent categories is determined, and the maximum probability is compared with a predetermined threshold. When the maximum probability is greater than the predetermined threshold, the intent category corresponding to the maximum probability is determined to be the target intent category expressed by the target sentence. In the prediction process, there may be a phenomenon that the intent category to which the target sentence belongs belongs to multiple intent categories. In order to avoid errors in intent category classification, the maximum probability value is selected by predicting the probability that the target sentence belongs to each intent category in multiple intent categories. The above maximum probability value is compared with a predetermined threshold. If the maximum probability value is greater than the predetermined threshold, the intent category corresponding to the maximum probability value is the target intent category to which the target sentence belongs, that is, the multiple intent categories include the intent category that the target sentence wants to express. Otherwise, it is determined that the multiple intent categories do not include the intent category that the target sentence wants to express, and a reminder is given. Among them, the above predetermined threshold can be artificially stipulated, or it can be obtained by using a training model based on experience. It can be based on the functional application in different scenarios, and multiple setting methods can be selected more flexibly and accurately. It can more accurately and quickly determine the target intent category to which the target sentence belongs, making the prediction result more accurate.

[0037] As an optional embodiment, before using the intent recognition classifier to predict the target intent category to which the target sentence belongs based on the first matrix, a process of training the intent recognition classifier is also included. For example, the following method can be used: obtaining a training sample, wherein the training sample includes a first sample matrix, a second sample matrix, a first sample intent category to which the first sample sentence corresponding to the first sample matrix belongs, and a second sample intent category to which the second sample sentence corresponding to the second sample matrix belongs, and the second sample sentence is a sample sentence obtained by back-translating the first sample sentence; performing machine training based on the training sample to obtain the intent recognition classifier. The intent recognition classifier is obtained by using the sample matrix and the sample intent category to which the sample sentence corresponding to the sample matrix belongs as the training sample training model. Compared with simply determining the intent recognition classifier based on the sample matrix and the corresponding relationship between the sample intent category to which the sample sentence corresponding to the sample matrix belongs, it can be more intelligent and accurate. Moreover, the sample sentence includes the back-translated sample sentence, which greatly expands the number of training samples, enriches the different expressions representing the same intent category, and improves the accuracy of the prediction results.

[0038] Based on the above embodiments and optional embodiments, an optional implementation is provided, which is described in detail below.

[0039] An optional implementation of the present invention provides an intent recognition method to judge the user's sentence into an accurate intent category, and then generate a corresponding reply based on the identified intent category. For example, if a user expresses "Hello, nice to meet you!", it will be classified into the chat category; if the user expresses "I want to buy some funds", it will be classified into the "product consultation" category; for "I want to complain to you", it will be classified into the "after-sales service" category. An intent recognition method provided in an optional implementation of the present invention can convert the recognition of user intent into a multi-classification task of user intent. Figure 2 is a flowchart of an intention recognition method provided according to an optional embodiment of the present invention. Figure 2 As shown, the method provided by the optional implementation mode of the present invention is described in detail below:

[0040] S1, using the existing ASR (Automatic Speech Recognition) technology to convert the audio file of the user in the intelligent interaction into a target sentence in text form. In an optional embodiment of the present invention, a target sentence is: "Hello, Mr. Wang, I would like to consult what financial products with relatively stable yields are available recently" (such as Figure 2 The operation of multiple sentences is the same as that of the target sentence, which will not be described here.

[0041] S2, input the target sentence into the BERT (Bidirectional Encoder Representation from Transformers, pre-trained language representation) model to obtain a semantic representation in the form of a matrix, that is, the user's true description matrix;

[0042] S2.1, preprocess the target sentence;

[0043] For example, you can use the nltk (Natural Language Toolkit) toolkit to clean the target sentence, remove interfering information such as punctuation, names, and numbers, and process the target sentence into: "Hello, I would like to ask what financial products have relatively stable yields recently."

[0044] S2.2, split the target sentence into a second predetermined number of target words;

[0045] After breaking down, it becomes "what do you want to consult?", "what recent" "income" "rate" "relatively" "stable" "financial" "products" "have".

[0046] S2.3, determining a second predetermined number of target word vectors of predetermined dimensions based on the second predetermined number of target words;

[0047] The input is a word sequence E = {w1,w w ... n}, each word is mapped to a corresponding vector x of dimension d i ∈R d (Assume the dimension d of the vector is 512), the word sequence E can finally be expressed as S∈R n×d The first matrix, such as the target word above, n is 23.

[0048] S2.4, when the second predetermined number 23 is less than the first predetermined number 512, a third predetermined number of 489 zero vectors of predetermined dimensions are added to obtain a first matrix S, wherein the sum of the second predetermined number and the third predetermined number is the first predetermined number. That is, the first matrix S is obtained by using the BERT model to semantically represent the user description (such as Figure 2 Pre-trained language representation word vector layer bert word embedding layer);

[0049] It should be noted that since the target word is usually less than 100 words, and the best sentence length of the BERT model is 512, the sentence length varies greatly, so it is necessary to supplement the 0 vector of the predetermined dimension.

[0050] S2.5, transpose the matrix S with itself T Perform nonlinear transformation to obtain the combination matrix S′ of the user description real vector and the filled 0 vector;

[0051] S2.6, use the MASK method to weaken the filling vector S′ to obtain the matrix α;

[0052] Among them, the weakening method can adopt a multi-head attention mechanism based on the hidden method to weaken the meaningless 0 vector and perform a high-order quantitative transformation on the real user description part, so that the ratio of the filling part is small enough, and the weight allocated in the softmax weight allocation is small enough to be ignored.

[0053] It should be noted that traditional models all use fixed parameter lengths to specify all vector dimensions, and use 0 padding to fill in the dimensions of short sentences, but this method is difficult to capture effective features of sentences. Therefore, in order to weaken this difference, the optional implementation of the present invention uses a MASK method, such as a multi-head attention mechanism based on a hidden method, to weaken the padding vectors that have no meaning, and the irrelevant vectors will not be assigned weights to the 0 vectors in the final softmax classification.

[0054] S2.7, performing a softmax normalization operation on the obtained α matrix to obtain an α′ matrix;

[0055] S2.8, the matrix S and α′ are matched one by one to obtain the final user representation matrix o i , using n different weights W i Get n different o i ;

[0056] S2.9, all o i After concatenation, we get the user's true description matrix H with word meaning weights att , H att As the input part of the three-layer convolution.

[0057] It should be noted that the above processing process can be trained using training samples, wherein the training samples can be obtained by back translation, and the training data set can be expanded by back translation to obtain a larger-scale dialogue text data set for training and better semantic representation.

[0058] For example, the original sentence is translated into English, and then translated back into Chinese to achieve data expansion. For example, the original sentence is "I want to consult what financial products have stable yields recently", which is translated into English as "I want to consult yield to compare stable financial products recently what to have", and then translated back into Chinese as "I want to know what financial products have stable yields recently".

[0059] S3, the obtained user real description matrix is ​​represented as H att Input into the CNN (Convolutional Neural Network) model, and predict the final category through the softmax classifier.

[0060] Based on the first matrix, the intent recognition classifier is used to predict the probability that the target sentence belongs to each of the multiple intent categories, and the maximum probability among the probabilities of belonging to the multiple intent categories is determined. The maximum probability is compared with a predetermined threshold. When the maximum probability is greater than the predetermined threshold, the intent category corresponding to the maximum probability is determined to be the target intent category expressed by the target sentence, that is, sentence label (intent category) prediction is performed.

[0061] It should be noted that in the above process of predicting the target intent category, the cross entropy loss function can be used to calculate the loss value of the intent category prediction probability. The loss value of a single intent category is loss i , the loss value of the overall user's true description is loss all . When using the Adam optimization function to optimize loss all After that, the loss value is reduced, the accuracy is improved, and the new loss all The reverse is passed to the model to iteratively update the model parameters, and the optimal parameters are used to predict the intent category to obtain the predicted probability q(x i ), select the intent category with the highest probability as the category actually described by the user.

[0062] It should also be noted that the prediction intent classification can be trained using training samples, wherein the training samples can be obtained by back translation, and the training data set can be expanded by back translation to obtain a larger-scale conversation text data set for training, so as to obtain better predictions and more accurate prediction results.

[0063] For example, the Chinese sentence text is translated into English, and then translated back into Chinese to achieve data expansion. For example, the original sentence is "I want to consult what financial products have stable yields recently", which is translated into English as "I want to consult yield to compare stable financial products recently what to have", and then translated back into Chinese as "I want to know what financial products have stable yields recently". Convert the original sentence and the translated Chinese sentence into corresponding matrices, input the matrix, and output the prediction results for better prediction.

[0064] Through the above optional implementation, at least the following beneficial effects can be achieved:

[0065] (1) An optional implementation of the present invention expands the user's real description in the intelligent interaction by back-translation and synonym replacement, thereby obtaining a larger data set;

[0066] (2) An optional implementation of the present invention integrates the pre-trained BERT and CNN models and performs intent recognition through a hidden mechanism, thereby solving the problem of poor intent recognition caused by uneven lengths of user descriptions and reducing the phenomenon of answering irrelevant questions.

[0067] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0068] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of various embodiments of the present invention.

[0069] Example 2

[0070] According to an embodiment of the present invention, a device for implementing the above-mentioned intention recognition method is also provided. Figure 3is a structural block diagram of an intention recognition device according to an embodiment of the present invention. Figure 3 As shown, the device includes: a receiving module 302, a determining module 304 and a predicting module 306. The device is described in detail below.

[0071] A receiving module 302 is used to receive a target sentence based on a predetermined task; a determining module 304 is connected to the above-mentioned receiving module 302, and is used to determine a first matrix corresponding to the target sentence, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as the value of the predetermined dimension; a predicting module 306 is connected to the above-mentioned determining module 304, and is used to predict the target intent category to which the target sentence belongs based on the first matrix using an intent recognition classifier.

[0072] It should be noted here that the above-mentioned receiving module 302, determination module 304 and prediction module 306 correspond to steps S102 to S106 in the implementation intention recognition method, and the instances and application scenarios implemented by multiple modules and corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment 1.

[0073] Example 3

[0074] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor, wherein the processor is configured to execute the instructions to implement any one of the above-mentioned intent recognition methods.

[0075] Example 4

[0076] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any of the above-mentioned intent recognition methods.

[0077] Example 5

[0078] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the intention recognition method described in any one of the above is implemented.

[0079] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0080] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0081] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may 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. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0082] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0083] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0084] 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 computer-readable storage medium. Based on this understanding, the technical solution of the present invention, 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, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0085] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for intention recognition, characterized in that: include: receiving target sentences based on predetermined tasks; Determine a first matrix corresponding to the target sentence, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as the value of the predetermined dimension; According to the first matrix, using an intent recognition classifier to predict the target intent category to which the target sentence belongs; Wherein, the method of using an intent recognition classifier to predict the target intent category to which the target sentence belongs based on the first matrix includes: performing a nonlinear transformation on the first matrix and the second matrix to obtain a third matrix, wherein the second matrix is ​​a matrix obtained by transposing the first matrix; using a multi-head attention mechanism based on a hidden method on the third matrix to obtain a fourth matrix; obtaining a fifth matrix based on the first matrix and the fourth matrix; inputting the fifth matrix into the intent recognition classifier to predict the target intent category to which the target sentence belongs; Among them, the fifth matrix is ​​obtained based on the first matrix and the fourth matrix, including: determining a first predetermined number of weight values ​​corresponding to the target sentence; obtaining a first predetermined number of seventh matrices based on the first predetermined number of weight values, the fourth matrix and the sixth matrix, wherein the sixth matrix is ​​a matrix obtained by normalizing the first matrix; splicing the first predetermined number of seventh matrices to obtain the fifth matrix.

2. The method according to claim 1, characterized in that The determining the first matrix corresponding to the target sentence includes: Splitting the target sentence into a second predetermined number of target words; Determining the target word vectors of the second predetermined number of the predetermined dimensions according to the second predetermined number of the target words; When the second predetermined number is lower than the first predetermined number, a third predetermined number of zero vectors of the predetermined dimension is supplemented to obtain the first matrix, wherein the sum of the second predetermined number and the third predetermined number is the first predetermined number.

3. The method according to claim 1, characterized in that The step of using an intent recognition classifier to predict the target intent category to which the target sentence belongs based on the first matrix includes: According to the first matrix, using an intent recognition classifier to predict the probability that the target sentence belongs to each of multiple intent categories, and determining the maximum probability among the probabilities of belonging to the multiple intent categories; comparing the maximum probability with a predetermined threshold; When the maximum probability is greater than the predetermined threshold, the intent category corresponding to the maximum probability is determined to be the target intent category expressed by the target sentence.

4. The method according to claim 1, characterized in that: Before predicting the target intent category to which the target sentence belongs using an intent recognition classifier according to the first matrix, the method further includes: Acquire a training sample, wherein the training sample includes a first sample matrix and a second sample matrix, a first sample intent category to which a first sample sentence corresponding to the first sample matrix belongs, and a second sample intent category to which a second sample sentence corresponding to the second sample matrix belongs, and the second sample sentence is a sample sentence obtained by back-translating the first sample sentence; Machine training is performed based on the training samples to obtain the intent recognition classifier.

5. An intention recognition device, characterized in that: include: A receiving module, used for receiving a target sentence based on a predetermined task; A determination module, configured to determine a first matrix corresponding to the target sentence, wherein the first matrix is ​​composed of a first predetermined number of word vectors of a predetermined dimension, and the first predetermined number is the same as a value of the predetermined dimension; A prediction module, configured to predict the target intent category to which the target sentence belongs using an intent recognition classifier according to the first matrix; The prediction module is further used to perform a nonlinear transformation on the first matrix and the second matrix to obtain a third matrix, wherein the second matrix is ​​a matrix obtained by transposing the first matrix; a multi-head attention mechanism based on a hidden method is used on the third matrix to obtain a fourth matrix; a fifth matrix is ​​obtained based on the first matrix and the fourth matrix; the fifth matrix is ​​input into the intent recognition classifier to predict the target intent category to which the target sentence belongs; Among them, the prediction module is also used to determine a first predetermined number of weight values ​​corresponding to the target sentence; based on the first predetermined number of weight values, the fourth matrix and the sixth matrix, a first predetermined number of seventh matrices are obtained, wherein the sixth matrix is ​​a matrix obtained by normalizing the first matrix; and the first predetermined number of seventh matrices are concatenated to obtain the fifth matrix.

6. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the intention recognition method as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the intention recognition method as described in any one of claims 1 to 4.

8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the intention recognition method according to any one of claims 1 to 4 is implemented.