Text intent recognition method, system, vehicle and equipment based on attention mechanism
Through the text intention recognition method based on attention mechanism, the Chinese short text is vectorized and optimized, which solves the accuracy and speed of Chinese short text intention recognition in the prior art, and achieves efficient intention recognition and user experience improvement.
Patent Information
- Application Number
- CN202210780514.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-04
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2042-07-04
AI Technical Summary
The prior art needs to improve the accuracy and recognition speed of identifying the intention of short Chinese texts.
The text intention recognition method based on attention mechanism is adopted, and the input language text information is vectorized based on characters and word segmentation, and multiple convolution kernels, window pooling, RELU activation function and attention mechanism are used for optimization processing, and intention recognition is finally performed through the full connection layer of the neural network.
It realizes the rapid and accurate identification of short Chinese text intentions, improves the natural language understanding ability of the human-machine multi-wheel dialogue system, and improves the user experience.
Smart Images

Figure CN115114908B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular, to a method, system, vehicle and equipment for text intent recognition based on an attention mechanism. Background Art
[0002] With the updating, iteration and rapid development of artificial intelligence related technologies, the interaction technology between humans and machines (humans and intelligent machines) has also made great progress. For example, in the automotive industry, the human-computer multi-round interactive dialogue system can provide car owners with smooth and efficient human-computer interaction.
[0003] The human-computer multi-round interactive dialogue system is easy to operate and can improve the convenience of car owners' life in the car. At the same time, since users no longer need to manually participate in operation control, they will not be distracted, distracted or even divert their attention to operate the vehicle. They only need to control the vehicle through voice dialogue, which can significantly enhance the safety of the vehicle during driving.
[0004] Generally speaking, the human-computer multi-round dialogue system includes several main parts: speech recognition (ASR) technology, natural language understanding (NLU) technology, dialogue management (DM) technology, natural language generation (NLG) technology and speech synthesis (TTS) technology. The technologies of each part are closely linked to each other. In particular, the recognition technology for the intention of Chinese short texts is the key core part of the human-computer multi-round dialogue system to achieve natural language understanding.
[0005] However, the accuracy and speed of the existing technology in recognizing the intent of Chinese short texts need to be improved.
[0006] Patent document CN103902521A (application number: CN201210568325.0) discloses a method and device for recognizing Chinese sentences, the method comprising: receiving a Chinese sentence to be recognized input by a user; obtaining an ambiguous chain of the Chinese sentence to be recognized; segmenting the ambiguous chain according to different segmentation methods, and determining the final segmentation result of the ambiguous chain according to the word frequency, part-of-speech tagging and transfer probability between segmented words obtained by segmentation, and segmenting the Chinese sentence to be recognized according to the final segmentation result of the ambiguous chain. However, the invention does not perform vectorization processing on the language text information based on characters and segmented sentences respectively. Summary of the invention
[0007] In view of the defects in the prior art, the object of the present invention is to provide a text intent recognition method, system, vehicle and equipment based on attention mechanism.
[0008] A text intent recognition method based on an attention mechanism provided by the present invention includes:
[0009] Step S1: obtaining and processing input language text information, and performing vectorization processing on the language text information based on characters and word segmentation sentences to obtain an initial vector based on characters and word segmentation sentences;
[0010] Step S2: performing multiple convolution kernel processing, multiple window pooling processing, RELU activation function processing and cascade processing on the initial vectors based on characters and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors;
[0011] Step S3: The optimized character-based sentence vector and word-based sentence vector are processed by the attention mechanism for concatenation and weighting to obtain a weighted vector based on the character and word-based sentences;
[0012] Step S4: discarding and transforming some elements of the weighted vector based on the character and word segmentation sentence to obtain a target vector based on the character and word segmentation sentence;
[0013] Step S5: The target vector based on the character and word segmentation sentence is calculated through the fully connected layer of the neural network to identify the text intent corresponding to the language text information and the corresponding text intent probability.
[0014] Preferably, in step S1:
[0015] The neural network obtains input language text information;
[0016] Processing language text information according to preset placeholder types, characters and word segmentation lengths that match natural language features;
[0017] In step S2:
[0018] Performing multiple convolution kernel processing on the initial vectors based on characters and word segmentation sentences respectively to obtain multiple convolution vectors based on characters and word segmentation sentences;
[0019] Using a plurality of pre-set pooling windows to perform multi-window pooling processing on a plurality of convolution vectors based on characters and word segmentation sentences respectively to obtain a plurality of pooling vectors based on characters and word segmentation sentences;
[0020] The negative value elements in the multiple pooling vectors based on characters and word segmentation sentences are converted to zero through the RELU activation function, and other elements are kept unchanged to obtain multiple activation vectors based on characters and word segmentation sentences.
[0021] Preferably, in step S3:
[0022] Concatenate multiple activation vectors based on character and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors respectively;
[0023] The optimized character-based sentence vector and word-based sentence vector attention mechanism are concatenated and weighted to obtain the weighted vector based on character and word segmentation sentences;
[0024] In step S4:
[0025] Use the dropout_prob function to randomly drop half of the elements in the weighted vector based on characters and word segmentation sentences and multiply them by 1 / dropout_prob to obtain the target vector based on characters and word segmentation sentences.
[0026] Preferably, in step S5:
[0027] The loss value or accuracy of the predicted text intent and the actual text intent is calculated:
[0028]
[0029]
[0030] Loss is the total loss value of the actual intention and predicted intention of the sample; n represents the total number of samples; m represents the total number of intentions; i represents the number of samples; y represents the total number of samples; i represents the actual intention of the i-th sample; p i Represents the predicted intention probability of the i-th sample;
[0031] Accuracy is the accuracy of intent recognition prediction, TP is the number of samples predicted correctly for positive samples, TN is the number of samples predicted correctly for negative samples, FP is the number of samples predicted incorrectly for positive samples, and FN is the number of samples predicted incorrectly for negative samples;
[0032] The fully connected layer of the neural network uses the formula argmax(y), y=x*w+b and Calculate and identify the text intent corresponding to the language text information and the corresponding text intent probability;
[0033] Where x is the input value, w is the weight, b is the bias, y is the score of all intents corresponding to the text or the score of m intents, n is the n sentences or n language text information in the language text information, m is the preset value of m intent categories, argmax(y) function is to find the intent category with the maximum score, softmax(y i ) function is the probability value of the predicted intent corresponding to the i-th sample, m represents the number of all intents corresponding to the sample, x i Represents a certain predicted intent score for the sample.
[0034] A text intention recognition system based on an attention mechanism provided by the present invention includes:
[0035] Module M1: obtains and processes input language text information, and performs vectorization processing on the language text information based on characters and word segmentation sentences to obtain initial vectors based on characters and word segmentation sentences;
[0036] Module M2: Perform multiple convolution kernel processing, multiple window pooling processing, RELU activation function processing and cascade processing on the initial vectors based on characters and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors;
[0037] Module M3: Optimized character-based sentence vectors and word-based sentence vectors are processed by attention mechanism for concatenation and weighting to obtain weighted vectors based on characters and word-based sentences;
[0038] Module M4: discarding and transforming some elements of the weighted vector based on characters and word segmentation sentences to obtain the target vector based on characters and word segmentation sentences;
[0039] Module M5: The target vector based on characters and word segmentation sentences is calculated through the fully connected layer of the neural network to identify the text intent corresponding to the language text information and the corresponding text intent probability.
[0040] Preferably, in the module M1:
[0041] The neural network obtains input language text information;
[0042] Processing language text information according to preset placeholder types, characters and word segmentation lengths that match natural language features;
[0043] In the module M2:
[0044] Performing multiple convolution kernel processing on the initial vectors based on characters and word segmentation sentences respectively to obtain multiple convolution vectors based on characters and word segmentation sentences;
[0045] Using a plurality of pre-set pooling windows to perform multi-window pooling processing on a plurality of convolution vectors based on characters and word segmentation sentences respectively to obtain a plurality of pooling vectors based on characters and word segmentation sentences;
[0046] The negative value elements in the multiple pooling vectors based on characters and word segmentation sentences are converted to zero through the RELU activation function, and other elements are kept unchanged to obtain multiple activation vectors based on characters and word segmentation sentences.
[0047] Preferably, in the module M3:
[0048] Concatenate multiple activation vectors based on character and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors respectively;
[0049] The optimized character-based sentence vector and word-based sentence vector attention mechanism are concatenated and weighted to obtain the weighted vector based on character and word segmentation sentences;
[0050] In the module M4:
[0051] Use the dropout_prob function to randomly drop half of the elements in the weighted vector based on characters and word segmentation sentences and multiply them by 1 / dropout_prob to obtain the target vector based on characters and word segmentation sentences.
[0052] Preferably, in the module M5:
[0053] The loss value or accuracy of the predicted text intent and the actual text intent is calculated:
[0054]
[0055]
[0056] Loss is the total loss value of the actual intention and predicted intention of the sample; n represents the total number of samples; m represents the total number of intentions; i represents the number of samples; y represents the total number of samples; i represents the actual intention of the i-th sample; p i Represents the predicted intention probability of the i-th sample;
[0057] Accuracy is the accuracy of intent recognition prediction, TP is the number of samples predicted correctly for positive samples, TN is the number of samples predicted correctly for negative samples, FP is the number of samples predicted incorrectly for positive samples, and FN is the number of samples predicted incorrectly for negative samples;
[0058] The fully connected layer of the neural network uses the formula argmax(y), y=x*w+b and Calculate and identify the text intent corresponding to the language text information and the corresponding text intent probability;
[0059] Where x is the input value, w is the weight, b is the bias, y is the score of all intents corresponding to the text or the score of m intents, n is the n sentences or n language text information in the language text information, m is the preset value of m intent categories, argmax(y) function is to find the intent category with the maximum score, softmax(y i ) function is the probability value of the predicted intent corresponding to the i-th sample, m represents the number of all intents corresponding to the sample, x i Represents a certain predicted intent score for the sample.
[0060] A text intention recognition device based on an attention mechanism provided by the present invention includes: a controller;
[0061] The controller includes a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of any one of the text intent recognition methods based on the attention mechanism are implemented; or, the controller includes any one of the text intent recognition systems based on the attention mechanism.
[0062] A vehicle provided according to the present invention includes: the above-mentioned text intent recognition device based on the attention mechanism.
[0063] Compared with the prior art, the present invention has the following beneficial effects:
[0064] 1. The present invention can quickly and accurately identify the intent of Chinese short texts, facilitating the natural language understanding of the human-computer multi-round dialogue system;
[0065] 2. The present invention obtains more text semantic features and information by performing word-based text conversion vector and character-based text conversion vector in parallel, and concatenating and weighting the two vectors through an attention mechanism, so as to make semantic understanding more accurate and improve user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0067] Figure 1 This is a flowchart of an implementation method of a text intent recognition method based on an attention mechanism of the present application;
[0068] Figure 2 A schematic diagram of an implementation method of a neural network for implementing a text intent recognition method in the present application. DETAILED DESCRIPTION
[0069] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0070] Embodiment 1:
[0071] Existing technology:
[0072] 1. A text is converted into character-based text, then converted into a vector and then enters the fully connected layer of the neural network for intent recognition.
[0073] For example: I want to listen to Jay Chou's Blue and White Porcelain
[0074] I want to listen to Jay Chou's Blue and White Porcelain
[0075] 1*384 vector (1 row of 384-dimensional vector)
[0076] 2. A text is converted into a text based on word segmentation, and then converted into a vector and then enters the neural network full connection layer for intent recognition.
[0077] For example: I want to listen to Jay Chou's Blue and White Porcelain
[0078] I want to listen to Jay Chou's Blue and White Porcelain
[0079] 1*384 vector (1 row of 384-dimensional vector)
[0080] Innovation:
[0081] By parallelizing the existing technologies 1 and 2, we can obtain the results of 1 and 2. For a text input, we obtain a 1*384 vector based on characters and a 1*384 vector based on word segmentation. Then, we use the attention mechanism to concatenate and weight these two vectors to form a 1*768 weighted vector. In fact, we weight each character of a text and all the characters or words of the text. This will obtain more text semantic features and information, so that the semantic understanding is more accurate and the user experience is improved.
[0082] For example:
[0083] 1. I want to listen to Jay Chou's Blue and White Porcelain
[0084] 1.1 I want to listen to Jay Chou's Blue and White Porcelain 1*384 vector
[0085] 1.2 I want to listen to Jay Chou's Blue and White Porcelain 1*384 vector
[0086] 1.3 I want to listen to Jay Chou's Blue and White Porcelain I want to listen to Jay Chou's Blue and White Porcelain 1*768 vector 1.4
[0088] a1I a2want to a3listen to a4Jay Chou a5a6Chen a7a8Blue Flowera 10 Porcelain 11 I 12 Want a 13 Listen to 14 Jay Chou 15 a 16 Blue and white porcelain 1*768 weighted vector
[0089] Note (a1, a2, a3, ... a 16 is the weight of the character or word and a1+a2+a3+......+a 16 =1)
[0090] The present application provides a vehicle, a vehicle-mounted device and a text intent recognition method based on an attention mechanism thereof, wherein a neural network obtains input language text information, processes the language text information according to a preset placeholder type, character and word segmentation length, performs vectorization processing on the language text information based on characters and word segmentation sentences to obtain an initial vector based on characters and word segmentation sentences, performs multi-core convolution processing on the initial vectors based on characters and word segmentation sentences respectively to obtain multiple convolution vectors based on characters and word segmentation sentences, uses multiple preset pooling windows to perform maximum pooling processing on the multiple convolution vectors based on characters and word segmentation sentences to obtain multiple pooling vectors based on characters and word segmentation sentences, converts negative value elements in the pooling vectors based on characters and word segmentation sentences to zero through a RELU activation function, and keeps them Other elements remain unchanged to obtain multiple activation vectors based on characters and word segmentation sentences, the multiple activation vectors based on characters and word segmentation sentences processed by the activation function are spliced to obtain optimized sentence vectors based on characters and word segmentation sentences respectively, the optimized sentence vectors based on characters and word segmentation sentences are processed by the attention mechanism, spliced and weighted to obtain weighted vectors based on characters and word segmentation sentences, the weighted vectors based on characters and word segmentation sentences are partially discarded and transformed by the Dropout function to obtain target vectors based on characters and word segmentation sentences, the target vectors based on characters and word segmentation sentences are calculated through a neural network fully connected layer to identify the text intent corresponding to the language text information and the corresponding text intent probability, so as to facilitate the natural language understanding of the human-computer multi-round dialogue system and ensure the user experience of the human-computer dialogue.
[0091] According to a text intent recognition method based on an attention mechanism provided by the present invention, Figure 1-Figure 2 As shown, including:
[0092] Step S1: obtaining and processing input language text information, performing sentence vectorization processing based on characters and word segmentation on the language text information to obtain an initial vector based on characters and word segmentation sentences;
[0093] Specifically, in step S1:
[0094] The neural network obtains input language text information;
[0095] Processing language text information according to preset placeholder types, characters and word segmentation lengths that match natural language features;
[0096] Step S2: performing multiple convolution kernel processing, multiple window pooling processing, RELU activation function processing and cascade processing on the initial vectors based on characters and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors;
[0097] In step S2:
[0098] Performing multiple convolution kernel processing on the initial vectors based on characters and word segmentation sentences respectively to obtain multiple convolution vectors based on characters and word segmentation sentences;
[0099] Using a plurality of pre-set pooling windows to perform multi-window pooling processing on a plurality of convolution vectors based on characters and word segmentation sentences respectively to obtain a plurality of pooling vectors based on characters and word segmentation sentences;
[0100] The negative value elements in the multiple pooling vectors based on characters and word segmentation sentences are converted to zero through the RELU activation function, and other elements are kept unchanged to obtain multiple activation vectors based on characters and word segmentation sentences.
[0101] Step S3: The optimized character-based sentence vector and word-based sentence vector are processed by the attention mechanism for concatenation and weighting to obtain a weighted vector based on the character and word-based sentences;
[0102] Specifically, in step S3:
[0103] Concatenate multiple activation vectors based on character and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors respectively;
[0104] The optimized character-based sentence vector and word-based sentence vector attention mechanism are concatenated and weighted to obtain the weighted vector based on character and word segmentation sentences;
[0105] Step S4: discarding and transforming some elements of the weighted vector based on the character and word segmentation sentence to obtain a target vector based on the character and word segmentation sentence;
[0106] In step S4:
[0107] Use the dropout_prob function to randomly drop half of the elements in the target vector and multiply it by 1 / dropout_prob to obtain the target vector based on characters and word segmentation sentences.
[0108] Step S5: The target vector based on characters and word segments is calculated through the fully connected layer of the neural network to identify the text intent corresponding to the language text information and the corresponding text intent probability.
[0109] Specifically, in step S5:
[0110] The loss value or accuracy of the predicted text intent and the actual text intent is calculated:
[0111]
[0112]
[0113] Loss is the total loss value of the actual intention and predicted intention of the sample; n represents the total number of samples; m represents the total number of intentions; i represents the number of samples; y represents the total number of samples; i represents the actual intention of the i-th sample; p i Represents the predicted intention probability of the i-th sample;
[0114] Accuracy is the accuracy of intent recognition prediction, TP is the number of samples predicted correctly for positive samples, TN is the number of samples predicted correctly for negative samples, FP is the number of samples predicted incorrectly for positive samples, and FN is the number of samples predicted incorrectly for negative samples;
[0115] The fully connected layer of the neural network uses the formula argmax(y), y=x*w+b and Calculate and identify the text intent corresponding to the language text information and the corresponding text intent probability;
[0116] Where x is the input value, w is the weight, b is the bias, y is the score of all intents corresponding to the text or the score of m intents, n is the n sentences or n language text information in the language text information, m is the preset value of m intent categories, argmax(y) function is to find the intent category with the maximum score, softmax(y i ) function is the probability value of the predicted intent corresponding to the i-th sample, m represents the number of all intents corresponding to the sample, x i Represents a certain predicted intent score for the sample.
[0117] A text intention recognition system based on an attention mechanism provided by the present invention includes:
[0118] Module M1: obtains and processes input language text information, and performs vectorization processing on the language text information based on characters and word segmentation sentences to obtain initial vectors based on characters and word segmentation sentences;
[0119] Specifically, in the module M1:
[0120] The neural network obtains input language text information;
[0121] Processing language text information according to preset placeholder types, characters and word segmentation lengths that match natural language features;
[0122] Module M2: Perform multiple convolution kernel processing, multiple window pooling processing, RELU activation function processing and cascade processing on the initial vectors based on characters and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors;
[0123] In the module M2:
[0124] Performing multiple convolution kernel processing on the initial vectors based on characters and word segmentation sentences respectively to obtain multiple convolution vectors based on characters and word segmentation sentences;
[0125] Using a plurality of pre-set pooling windows to perform multi-window pooling processing on a plurality of convolution vectors based on characters and word segmentation sentences respectively to obtain a plurality of pooling vectors based on characters and word segmentation sentences;
[0126] The negative value elements in the multiple pooling vectors based on characters and word segmentation sentences are converted to zero through the RELU activation function, and other elements are kept unchanged to obtain multiple activation vectors based on characters and word segmentation sentences.
[0127] Module M3: Optimized character-based sentence vectors and word-based sentence vectors are processed by attention mechanism for concatenation and weighting to obtain weighted vectors based on characters and word-based sentences;
[0128] Specifically, in the module M3:
[0129] Concatenate multiple activation vectors based on character and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors respectively;
[0130] The optimized character-based sentence vector and word-based sentence vector attention mechanism are concatenated and weighted to obtain the weighted vector based on character and word segmentation sentences;
[0131] Module M4: discarding and transforming some elements of the weighted vector based on characters and word segmentation sentences to obtain the target vector based on characters and word segmentation sentences;
[0132] In the module M4:
[0133] Use the dropout_prob function to randomly drop half of the elements in the target vector and multiply it by 1 / dropout_prob to obtain the target vector based on characters and word segmentation sentences.
[0134] Module M5: The target vector based on characters and word segmentation sentences is calculated through the fully connected layer of the neural network to identify the text intent corresponding to the language text information and the corresponding text intent probability.
[0135] Specifically, in the module M5:
[0136] The loss value or accuracy of the predicted text intent and the actual text intent is calculated:
[0137]
[0138]
[0139] Loss is the total loss value of the actual intention and predicted intention of the sample; n represents the total number of samples; m represents the total number of intentions; i represents the number of samples; y represents the total number of samples; i represents the actual intention of the i-th sample; p i Represents the predicted intention probability of the i-th sample;
[0140] Accuracy is the accuracy of intent recognition prediction, TP is the number of samples predicted correctly for positive samples, TN is the number of samples predicted correctly for negative samples, FP is the number of samples predicted incorrectly for positive samples, and FN is the number of samples predicted incorrectly for negative samples;
[0141] The fully connected layer of the neural network uses the formula argmax(y), y=x*w+b and Calculate and identify the text intent corresponding to the language text information and the corresponding text intent probability;
[0142] Where x is the input value, w is the weight, b is the bias, y is the score of all intents corresponding to the text or the score of m intents, n is the n sentences or n language text information in the language text information, m is the preset value of m intent categories, argmax(y) function is to find the intent category with the maximum score, softmax(y i ) function is the probability value of the predicted intent corresponding to the i-th sample, m represents the number of all intents corresponding to the sample, x i Represents a certain predicted intent score for the sample.
[0143] A text intention recognition device based on an attention mechanism provided by the present invention includes: a controller;
[0144] The controller includes a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of any one of the text intent recognition methods based on the attention mechanism are implemented; or, the controller includes any one of the text intent recognition systems based on the attention mechanism.
[0145] A vehicle provided according to the present invention includes: the above-mentioned text intent recognition device based on the attention mechanism.
[0146] Embodiment 2:
[0147] Embodiment 2 is a preferred example of Embodiment 1, and is used to illustrate the present invention in more detail.
[0148] The present application provides a vehicle, a vehicle-mounted device, and a text intent recognition method based on an attention mechanism. As one implementation method, the text intent recognition method based on the attention mechanism includes:
[0149] The neural network obtains input language text information;
[0150] Processing the language text information according to preset placeholder types, characters and word segmentation lengths;
[0151] Performing sentence vectorization processing based on characters and word segmentation on the language text information to obtain an initial vector based on characters and word segmentation sentences;
[0152] Performing multi-core convolution processing on the initial vectorization based on characters and word segmentation sentences respectively to obtain multiple convolution vectors based on characters and word segmentation sentences;
[0153] Using a plurality of pre-set pooling windows to perform pooling processing on a plurality of convolution vectors based on characters and word segmentation sentences, so as to obtain a plurality of pooling vectors based on characters and word segmentation sentences;
[0154] Convert negative value elements in the multiple pooling vectors based on characters and word segmentation sentences to zero through a RELU activation function, and keep other elements unchanged, so as to obtain multiple activation vectors based on characters and word segmentation sentences;
[0155] splicing the plurality of activation vectors based on characters and word segmentation sentences to obtain optimized vectors based on characters and word segmentation sentences respectively;
[0156] The optimized vectors based on characters and word segmentation sentences are processed by an attention mechanism, and are concatenated and weighted to obtain weighted vectors based on characters and word segmentation sentences;
[0157] The Dropout function is used to discard some elements of the weighted vectors based on characters and word segmentation sentences and perform certain transformations to obtain the target vectors based on characters and word segmentation sentences;
[0158] The neural network fully connected layer calculates the target vector based on the character and word segmentation sentence to identify the text intent corresponding to the language text information and the corresponding text intent probability.
[0159] As one implementation manner, the step of calculating the target vector based on the character and word segmentation sentence by the neural network fully connected layer to identify the text intent corresponding to the language text information and the corresponding text intent probability also includes:
[0160] The loss value or accuracy of the predicted text intent and the actual text intent is calculated:
[0161]
[0162]
[0163] Loss is the total loss value of the actual intention and predicted intention of the sample; n represents the total number of samples; m represents the total number of intentions; i represents the number of samples; y represents the total number of samples; i represents the actual intention of the i-th sample; p i Represents the predicted intention probability of the i-th sample;
[0164] Accuracy is the accuracy of intent recognition prediction, TP is the number of samples predicted correctly for positive samples, TN is the number of samples predicted correctly for negative samples, FP is the number of samples predicted incorrectly for positive samples, and FN is the number of samples predicted incorrectly for negative samples;
[0165] The fully connected layer of the neural network uses the formula argmax(y), y=x*w+b and Calculate and identify the text intent corresponding to the language text information and the corresponding text intent probability;
[0166] Where x is the input value, w is the weight, b is the bias, y is the score of all intents corresponding to the text or the score of m intents, n is the n sentences or n language text information in the language text information, m is the preset value of m intent categories, argmax(y) function is to find the intent category with the maximum score, softmax(y i ) function is the probability value of the predicted intent corresponding to the i-th sample, m represents the number of all intents corresponding to the sample, x i Represents a certain predicted intent score for the sample.
[0167] For example:
[0168] A sample: I want to navigate to People's Square
[0169] Intents include: navigation, music, and car control
[0170] Suppose the intention recognition prediction probability results of this sample are: navigation: 0.9; music: 0.55; car control: 0.45
[0171] The actual intention of this sample is navigation: vector y i =1,0,0;
[0172] The Loss of this sample = -(ln 0.9*1+ln 0.55*0+ln 0.45*0) = ln 0.9
[0173] This is the Loss calculation process of one sample. If it is the loss value of n samples, then the Loss of all samples is summed or averaged.
[0174] Accuracy represents the accuracy of intent recognition prediction, TP represents the number of samples predicted correctly for positive samples, TN represents the number of samples predicted correctly for negative samples, FP represents the number of samples predicted incorrectly for positive samples, and FN represents the number of samples predicted incorrectly for negative samples.
[0175] For example:
[0176] There are 10 samples in total, 5 positive and 5 negative. Among the 5 positive samples, 3 of them are correct and 2 are wrong. Among the 5 negative samples, 3 of them are correct and 2 are wrong. So Accuracy = (3+3) / (3+3+2+2) = 0.6
[0177] The final intent for output is obtained by cross entropy processing between the predicted intent category probability obtained through training and the actual intent category.
[0178] As one implementation manner, the step of processing the language text information according to the preset placeholder type, character and word segmentation length specifically includes:
[0179] The language text information is processed according to preset placeholder types, characters and word segmentation lengths that match natural language features.
[0180] As one implementation manner, the placeholder type is input int32~input int32, output float32~output float32, the character length is 70 bytes~90 bytes, and the word length is 30 bytes~50 bytes.
[0181] As one of the implementation modes, in the step of performing character and word segmentation sentence vectorization processing on the language text information to obtain an initial vector based on character and word segmentation sentences, the dimension of each character and word segmentation vector is between 25 and 35.
[0182] As one implementation manner, the step of performing multi-core convolution processing on the initial vector based on the character and word segmentation sentence to obtain a plurality of corresponding convolution vectors based on the character and word segmentation sentence specifically includes:
[0183] The language text information is convolved y=x*w+b using convolution kernels of 3*32*128, 4*32*128 and 5*32*128 and a bias of 1*128 to obtain three types of convolution vectors of 78*1*128, 77*1*128 and 76*1*128 based on characters, and three types of convolution vectors of 33*1*128, 32*1*128 and 31*1*128 based on word segmentation are obtained. Among them, 3, 4 and 5 of the convolution kernel represent the width of the convolution kernel.
[0184] As one of the implementations:
[0185] The step of using a plurality of preset pooling windows to perform maximum pooling max(x) processing on the plurality of convolution vectors based on characters and word segmentation sentences specifically includes: using pooling windows with preset sizes of 78*1*128, 77*1*128 and 76*1*128 to perform maximum pooling processing on the three types of convolution vectors based on characters to form three 1*128 vectors based on character sentences, and simultaneously using pooling windows with preset sizes of 33*1*128, 32*1*128 and 31*1*128 to perform maximum pooling processing on the three types of convolution vectors based on word segmentation to form three 1*128 vectors based on word segmentation sentences;
[0186] As one implementation manner, the step of performing a RELU activation function on a plurality of pooling vector pooling matrices based on characters and word segmentation sentences processed by a plurality of pooling windows specifically includes:
[0187] The RELU activation function max(0, x) is used to convert the negative value elements in multiple pooling vectors based on characters and word segmentation sentences to zero, and keep other elements unchanged to obtain multiple activation vectors based on characters and word segmentation sentences.
[0188] The step of splicing multiple activation vectors based on characters and word segmentation sentences to obtain optimized vectors based on characters and word segmentation sentences specifically includes: splicing three 1*128 character-based vectors processed by the activation function to form a 1*384 vector, and splicing three 1*128 word-based vectors processed by the activation function to form a 1*384 vector;
[0189] The optimized vectors based on characters and word segmentation sentences are processed by the attention mechanism ∝=softmat(vu), v=tanh(x*w+b), u=(attentionSize, 1), b=(attentionSize, 1), w=(hiddenSize, attentionSize), and concatenated and weighted to obtain the weighted vector based on characters and word segmentation sentences 1*768;
[0190] The step of discarding some elements in the splicing and certain transformation specifically includes: using the dropout_prob function to randomly discard half of the elements in the weighted vector based on the character and word segmentation sentence and multiplying by 1 / dropout_prob to transform to obtain a target vector 1*768 based on the character and word segmentation sentence;
[0191] The neural network fully connected layer calculates the target vector to identify the text intent corresponding to the language text information and the corresponding text intent probability step, specifically including: the neural network fully connected layer uses the formula argmax(y), y=x*w+b and Calculate to identify the text intent corresponding to the language text information and the corresponding text intent probability, where the input value x = n*768, the weight w = 768*m, the bias b = 1*m, calculate the scores y of m text intents, n is the n sentences or n language text information in the language text information, m is the preset value of m intent categories, the argmax(y) function is to find the intent category with the maximum score, and softmax(y i ) function finds the probability of each intention.
[0192] Softmax(yi) represents the probability value of a sample corresponding to the predicted intent, m represents the number of all intents corresponding to the sample, and x i Represents a certain predicted intent score for the sample.
[0193] For example:
[0194] I want to listen to Jay Chou's Blue and White Porcelain, the actual intention is music
[0195] m is 3, which are navigation, music and car control
[0196] The intention prediction scores of this sample are: navigation 0.05; music 0.9; car control 0.05
[0197] Then the predicted probabilities of the sample intention are
[0198] In order to solve the above technical problems, the present application also provides a vehicle-mounted device. As one of the implementation modes, the vehicle-mounted device is configured with a processor, and the processor is used to execute a computer program to implement the text intent recognition method based on the attention mechanism as described above.
[0199] In order to solve the above technical problems, the present application also provides a vehicle. As one of the implementation modes, the vehicle is equipped with the vehicle-mounted device as described above, so as to perform multi-round voice interaction between a person and the vehicle through the vehicle-mounted device.
[0200] After testing, the data set is 1867172, with 112 intents. The training set, validation set, and test set are divided in a ratio of 8:1:1. The vectors based on characters and word segmentation sentences are 32-dimensional, 64-dimensional, 128-dimensional, etc. The accuracy of intent recognition verification on the test set is about 99.2. However, we finally chose the 32-dimensional vector dimension based on characters and word segmentation because the training and reasoning performance of this dimension can be improved by at least 2 times.
[0201] Those skilled in the art know that, in addition to implementing the system, device and its various modules provided by the present invention in a purely computer-readable program code, it is entirely possible to implement the same program in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and its various modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing the method and structures within the hardware component.
[0202] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A text intent recognition method based on attention mechanism, characterized in that: include: Step S1: obtaining and processing input language text information, and performing vectorization processing on the language text information based on characters and word segmentation sentences to obtain an initial vector based on characters and word segmentation sentences; Step S2: performing multiple convolution kernel processing, multiple window pooling processing, RELU activation function processing and cascade processing on the initial vectors based on characters and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors; Step S3: The optimized character-based sentence vector and word-based sentence vector are processed by the attention mechanism for concatenation and weighting to obtain a weighted vector based on the character and word-based sentences; Step S4: discarding and transforming some elements of the weighted vector based on the character and word segmentation sentence to obtain a target vector based on the character and word segmentation sentence; Step S5: The target vector based on the character and word segmentation sentence is calculated through the fully connected layer of the neural network to identify the text intent corresponding to the language text information and the corresponding text intent probability.
2. The method for text intent recognition based on attention mechanism according to claim 1, characterized in that: In step S1: The neural network obtains input language text information; Processing language text information according to preset placeholder types, characters and word segmentation lengths that match natural language features; In step S2: Performing multiple convolution kernel processing on the initial vectors based on characters and word segmentation sentences respectively to obtain multiple convolution vectors based on characters and word segmentation sentences; Using a plurality of pre-set pooling windows to perform multi-window pooling processing on a plurality of convolution vectors based on characters and word segmentation sentences respectively to obtain a plurality of pooling vectors based on characters and word segmentation sentences; The negative value elements in the multiple pooling vectors based on characters and word segmentation sentences are converted to zero through the RELU activation function, and other elements are kept unchanged to obtain multiple activation vectors based on characters and word segmentation sentences.
3. The method for text intent recognition based on attention mechanism according to claim 1, characterized in that: In step S3: Concatenate multiple activation vectors based on character and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors respectively; The optimized character-based sentence vector and word-based sentence vector attention mechanism are concatenated and weighted to obtain the weighted vector based on character and word segmentation sentences; In step S4: Use the dropout_prob function to randomly drop half of the elements in the target vector and multiply it by 1 / dropout_prob to obtain the target vector based on characters and word segmentation sentences.
4. The method for text intent recognition based on attention mechanism according to claim 1, characterized in that: In step S5: The loss value or accuracy of the predicted text intent and the actual text intent is calculated: Loss is the total loss value between the actual intention and predicted intention of the sample; n represents the total number of samples; m represents the total number of intentions; i represents the number of samples; y i represents the actual intention of the i-th sample; p i Represents the predicted intention probability of the i-th sample; Accuracy is the accuracy of intent recognition prediction, TP is the number of samples predicted correctly for positive samples, TN is the number of samples predicted correctly for negative samples, FP is the number of samples predicted incorrectly for positive samples, and FN is the number of samples predicted incorrectly for negative samples; The fully connected layer of the neural network uses the formula argmax(y), y=x*w+b and Calculate and identify the text intent corresponding to the language text information and the corresponding text intent probability; Where x is the input value, w is the weight, b is the bias, y is the score of all intents corresponding to the text or the score of m intents, n is the n sentences or n language text information in the language text information, m is the preset value of m intent categories, argmax(y) function is to find the intent category with the maximum score, softmax(y i ) function is the probability value of the predicted intent corresponding to the i-th sample, m represents the number of all intents corresponding to the sample, x i Represents a certain predicted intent score for the sample.
5. A text intent recognition system based on attention mechanism, characterized in that: include: Module M1: obtains and processes input language text information, and performs vectorization processing on the language text information based on characters and word segmentation sentences to obtain initial vectors based on characters and word segmentation sentences; Module M2: Perform multiple convolution kernel processing, multiple window pooling processing, RELU activation function processing and cascade processing on the initial vectors based on characters and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors; Module M3: Optimized character-based sentence vectors and word-based sentence vectors are processed by attention mechanism for concatenation and weighting to obtain weighted vectors based on characters and word-based sentences; Module M4: discarding and transforming some elements of the weighted vector based on characters and word segmentation sentences to obtain the target vector based on characters and word segmentation sentences; Module M5: The target vector based on characters and word segmentation sentences is calculated through the fully connected layer of the neural network to identify the text intent corresponding to the language text information and the corresponding text intent probability.
6. The text intent recognition system based on the attention mechanism according to claim 5, characterized in that: In the module M1: The neural network obtains input language text information; Processing language text information according to preset placeholder types, characters and word segmentation lengths that match natural language features; In the module M2: Performing multiple convolution kernel processing on the initial vectors based on characters and word segmentation sentences respectively to obtain multiple convolution vectors based on characters and word segmentation sentences; Using a plurality of pre-set pooling windows to perform multi-window pooling processing on a plurality of convolution vectors based on characters and word segmentation sentences respectively to obtain a plurality of pooling vectors based on characters and word segmentation sentences; The negative value elements in the multiple pooling vectors based on characters and word segmentation sentences are converted to zero through the RELU activation function, and other elements are kept unchanged to obtain multiple activation vectors based on characters and word segmentation sentences.
7. The text intent recognition system based on the attention mechanism according to claim 5, characterized in that: In the module M3: Concatenate multiple activation vectors based on character and word segmentation sentences to obtain optimized character-based sentence vectors and word segmentation-based sentence vectors respectively; The optimized character-based sentence vector and word-based sentence vector attention mechanism are concatenated and weighted to obtain the weighted vector based on character and word segmentation sentences; In the module M4: Use the dropout_prob function to randomly drop half of the elements in the target vector and multiply it by 1 / dropout_prob to obtain the target vector based on characters and word segmentation sentences.
8. The text intent recognition system based on attention mechanism according to claim 5, characterized in that: In the module M5: The loss value or accuracy of the predicted text intent and the actual text intent is calculated: Loss is the total loss value between the actual intention and predicted intention of the sample; n represents the total number of samples; m represents the total number of intentions; i represents the number of samples; y i represents the actual intention of the i-th sample; p i Represents the predicted intention probability of the i-th sample; Accuracy is the accuracy of intent recognition prediction, TP is the number of samples predicted correctly for positive samples, TN is the number of samples predicted correctly for negative samples, FP is the number of samples predicted incorrectly for positive samples, and FN is the number of samples predicted incorrectly for negative samples; The fully connected layer of the neural network uses the formula argmax(y), y=x*w+b and Calculate and identify the text intent corresponding to the language text information and the corresponding text intent probability; Where x is the input value, w is the weight, b is the bias, y is the score of all intents corresponding to the text or the score of m intents, n is the n sentences or n language text information in the language text information, m is the preset value of m intent categories, argmax(y) function is to find the intent category with the maximum score, softmax(y i ) function is the probability value of the predicted intent corresponding to the i-th sample, m represents the number of all intents corresponding to the sample, x i Represents a certain predicted intent score for the sample.
9. A text intent recognition device based on an attention mechanism, characterized in that: include: Controller; The controller includes a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the text intent recognition method based on the attention mechanism described in any one of claims 1 to 4 are implemented; or, the controller includes the text intent recognition system based on the attention mechanism described in any one of claims 5 to 8.
10. A vehicle, characterized in that: include: The text intent recognition device based on the attention mechanism as described in claim 9.
Citation Information
Patent Citations
Chinese statement identification method and device
CN103902521A
A Chinese sentence recognition method and device
CN103902521B
Vehicle, vehicle machine equipment and text intention recognition method thereof based on neural network
CN110263139A
Short text classification method based on semantic enhancement and multi-level label embedding
CN110866117A