Chronic disease question and answer intention recognition method and device based on local features and context features

By combining deep learning technologies such as RoBERTa-WWM, TextCNN, BiGRU and TextRCNN, local and contextual features of text are extracted and fused, which solves the problem of insufficient combination of local features and global features in existing intent recognition methods and improves the accuracy of intent recognition. performance and robustness.

CN118689986APending Publication Date: 2024-09-24ZHEJIANG UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410811271.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

When dealing with user intentions, existing intent recognition methods over-rely on local features and ignore global context features, or vice versa, resulting in insufficient recognition accuracy, and there are problems of small coverage and misrecognition based on rule templates and statistical methods.

Method used

A multi-level feature fusion strategy is adopted, combining the RoBERTa-WWM pre-training model, TextCNN, BiGRU, TextRCNN and multi-head attention mechanism to extract local and contextual features of the text. Local features are extracted through TextCNN, deep semantic features are extracted through BiGRU and TextRCNN, and The multi-head attention mechanism is fused, and the softmax function is finally used for intent classification.

Benefits of technology

It achieves a more comprehensive and in-depth understanding of user intentions, improves the accuracy and robustness of intention recognition, and can more accurately identify users' real needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118689986A
    Figure CN118689986A
Patent Text Reader

Abstract

The invention discloses a chronic disease question and answer intention recognition method and device based on local features and context features. The method comprises the following steps that firstly, text data is converted into vector representation through RoBERTa-WWM; secondly, capturing local key information in a vector by using TextCNN, and learning sequence information from key features by using BiGRU; inputting the learned features into a multi-head attention mechanism so as to more accurately learn and extract important information; and meanwhile, inputting a text vector into the TextRCNN model to learn the overall features of the text. And finally, connecting the local features with the overall features to form a final feature vector, comprehensively considering the local features and the context features, and more accurately identifying the user intention.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent question-answering for chronic diseases, and in particular to a method and device for identifying intentions based on local features and contextual features. Background Art

[0002] Intent recognition is an important task in the field of natural language processing. It aims to obtain the user's intention or purpose through analysis. It is indispensable in the field of human-computer interaction such as question-answering systems. In the user intent recognition stage, how to parse the question semantics, analyze the semantic environment, and obtain the user's intention, a common method is to regard the intent recognition task as a question classification task. The system can accurately judge the user's intention based on the semantic features and context of the question, and make corresponding responses or processing. This method can help the system better understand user needs and improve the efficiency and quality of interaction.

[0003] Traditional intent recognition methods include rule template methods and statistics-based methods. Rule template-based intent recognition methods require experts to manually write rule templates, which is labor-intensive and prone to conflicts. At the same time, rule templates have a small coverage and are not universal. Statistical methods use intent dictionaries to calculate word frequencies. Although the coverage has been improved to a certain extent, it is easy to misidentify. Compared with rule template methods, statistical methods have improved coverage to a certain extent because they can handle more scenarios and contexts. At present, methods based on deep learning have gradually become a research hotspot, but there are still some limitations. Some methods rely too much on local features and ignore global context features, while other methods focus more on global features and ignore local details. The key to improving the accuracy of user intent recognition lies in how to effectively extract deep local features and context features and use them in combination. Summary of the invention

[0004] The present invention aims to overcome the above shortcomings and proposes a text feature extraction framework based on a multi-level feature fusion strategy. It combines the advantages of RoBERTa-WWM pre-training method of full-word masking technology, TextCNN, BiGRU, TextRCNN and attention mechanism and other deep learning technologies, and realizes accurate recognition of intent by fusing local features and contextual features of text.

[0005] The present invention achieves the above object through the following technical solutions:

[0006] The first aspect of the present invention relates to a method for identifying the intention of a chronic disease question and answer based on local features and context features, comprising the following steps:

[0007] (1) The text is converted into a vector representation T = {T1, T2, ···, T N};

[0008] (2) Construct the intent recognition model TBGMA-TR, which includes the sequentially arranged TextCNN model, BiGRU model, multi-head attention mechanism, and TextRCNN model;

[0009] (3) Input the vector T obtained in step (1) into the TextCNN network model, and obtain the output vector after convolution, pooling and concatenation. in Represents the feature vector extracted by different convolution kernels;

[0010] (4) Input the vector C into the BiGRU network model to extract deeper semantic features, and further learn through the multi-head attention mechanism to output the key local feature vector MHead(H);

[0011] (5) Input the vector representation T in step (1) into the TextRCNN model to obtain comprehensive context feature information and output the context feature vector R;

[0012] (6) The key local feature MHead(H) and the context feature R are concatenated as the final feature vector MHR, and the softmax function is used to classify its intent after dimensionality reduction.

[0013] Preferably, the step (3) is specifically as follows:

[0014] (3.1) Convert the vector representation T into a matrix X of dimension d:

[0015]

[0016] Where n is the length of the text, d is the dimension of the word vector, and x i,j Represents the value of the i-th word in the j-dimension, which is sent to CNN for further processing;

[0017] (3.2) Extract local features of the text in the convolution layer. Use a convolution kernel of size h×d to perform a convolution operation on the input matrix, where h is the height of the convolution kernel and d is the word vector T. i The convolution kernel moves downward with a fixed step size to perform convolution operations on the matrix area it covers until it moves to the bottom of the matrix. Each movement is calculated once, and finally a set of feature vectors C = {C1, C2, ···, C n}, n represents n convolution kernels of different sizes, and the convolution operation can be expressed as:

[0018] c i =f(w·X i:i+h-1 +b) (2)

[0019] Where f(·) represents the activation function, X i:i+h-1 represents the i-th row to the i+h-1th row of the matrix X, and b is the bias term;

[0020] (3.3) For each feature map C of the feature vector C i The dimension is reduced by maximum pooling to obtain the pooled feature vector in is the feature map C i The maximum value of . After concatenation, we get the feature vector that is finally output after TextCNN processing.

[0021] Preferably, the implementation method of obtaining the key local features through learning of the BiGRU network and the multi-head attention mechanism in step (4) is as follows:

[0022] (4.1) For the feature vector output by TextCNN The calculation of the BiGRU network model can be expressed as:

[0023]

[0024] in, and They represent the forward and backward hidden states at time t, respectively. represents the tth element of the input vector, h t is the final hidden state at time t, and are weights, b t is the bias, then the final output of BiGRU is H = [h1, h2, ···, h n ];

[0025] (4.2) The output H of BiGRU is used as the input of the multi-head attention mechanism. There are n attention heads. For each attention head i , H is mapped into query (Q), key (K), value (V) matrices through linear transformation:

[0026] Q i =HW i Q (6)

[0027] K i =HW i K (7)

[0028] V i =HWx V (8)

[0029] Among them, W Q , W K and w V Represent the learned weight matrices respectively;

[0030] (4.3) By scaling the dot product, the output of each attention head is calculated as follows:

[0031]

[0032] Among them, d k are the dimensions of Q and K;

[0033] (4.4) By concatenating the outputs of n attention heads, we get the final output:

[0034] MHead(H)=Concat(head1,head2,···,head n )W O (10)

[0035] Among them, W O is the weight matrix, and Concat represents the concatenation operation.

[0036] Preferably, in step (5), inputting the vector representation T in step (1) into the TextRCNN model to obtain comprehensive context feature information specifically includes:

[0037] (5.1) For each word t i And the corresponding word vector T i , after bidirectional RNN extracts features, the output is as follows:

[0038] c l (t i )=f(W l c l (t i-1 )+W sl T i-1 ) (11)

[0039] c r (t i )=f(W l c r (t i+1 )+W sr T i+1 ) (12)

[0040] Among them, l and r represent the left and right sides of the word respectively;

[0041] (5.2) Concatenate the output of the bidirectional RNN and the word vector corresponding to the word to form a new word vector representation:

[0042] xi =[c l (t i ),T i ,c r (t i )] (13)

[0043] (5.3) Use the tanh activation function and obtain the contextual features of the sentence through maximum pooling:

[0044]

[0045] in, represents the latent semantic vector.

[0046] Preferably, the step (6) concatenates the key local feature MHead(H) and the context feature R to form a final feature vector MHR, and uses a softmax function to perform intent classification on the final feature vector after dimensionality reduction, specifically including the following steps:

[0047] (6.1) Vector concatenation:

[0048] MHR=[MHead(H),R] (16)

[0049] Among them, MHR is the final feature vector;

[0050] (6.2) The classification calculation formula can be expressed as:

[0051] S = softmax(w1·MHR+b1) (17)

[0052] Where S is the final classification result, w1 and b1 are weights and biases.

[0053] The second aspect of the present invention relates to a device for identifying the intention of a question and answer about a chronic disease based on local features and contextual features, comprising a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement a method for identifying the intention of a question and answer about a chronic disease based on local features and contextual features of the present invention.

[0054] The third aspect of the present invention relates to a computer-readable storage medium, characterized in that a program is stored thereon, and when the program is executed by a processor, a method of identifying the intention of a chronic disease question and answer based on local features and contextual features of the present invention is implemented.

[0055] The beneficial effect of the present invention is that local features and overall features are cleverly combined to form a comprehensive feature vector. This combination not only makes our model more comprehensive and in-depth in understanding user intent, but also can more accurately identify the user's real needs. Through RoBERTa-WWM, TextCNN, BiGRU, and multi-head attention modules, local key information in the text is captured to enhance the understanding of the deep structure of the text; the application of the TextRCNN model enables us to comprehensively learn the overall characteristics of the text, which is of great significance for understanding the user's indirect intent and contextual background. Therefore, the intent recognition method of the present invention has higher accuracy and stronger robustness, which has brought important breakthroughs and progress to the field of natural language processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 It is a schematic flow chart of the method of the present invention;

[0057] Figure 2 is a schematic diagram of the TBGMA-TR model structure of an embodiment of the present invention;

[0058] Figure 3 It is a schematic diagram of the structure of the RoBERTa-WWM model according to an embodiment of the present invention;

[0059] Figure 4 Schematic diagram of the TextCNN model structure of an embodiment of the present invention;

[0060] Figure 5 Schematic diagram of the BiGRU model structure of an embodiment of the present invention;

[0061] Figure 6 Schematic diagram of the TextRCNN model structure of an embodiment of the present invention. DETAILED DESCRIPTION

[0062] The principles and technical solutions of the present invention are described in detail below in conjunction with specific embodiments and drawings. It should be understood that the protection scope of the present invention is not limited thereto:

[0063] Example 1

[0064] Chronic disease intelligent question-answering intent is pre-classified into 15 categories, including disease_symptom (symptom), disease_cause (cause), disease_acompany (complication), disease_drug (recommended drug), disease_cureway (treatment method), etc. Figure 2 As shown in the figure, a method for identifying the intention of chronic disease question answering based on local features and context features is as follows:

[0065] Step 1: Convert the text into a vector representation T = {T1, T2, ···, T N};

[0066] The RoBERTa-WWM model evolved from the BERT model. In order to more accurately capture the complex bidirectional relationship in the sentence, a multi-layer bidirectional Transformer encoder is used as the core structure, and the connection between any two words in the sentence is strengthened through the attention mechanism. The network structure is shown in the figure Figure 3 shown.

[0067] Step 2: Build the intent recognition model TBGMA-TR, including the sequentially arranged TextCNN model, BiGRU model, multi-head attention mechanism, and TextRCNN model;

[0068] Step 3: Input the vector representation T into the TextCNN network model, and obtain the output vector through convolution, pooling and concatenation. in Represents the feature vector extracted by different convolution kernels;

[0069] The basic idea of ​​TextCNN is to extract the features of the input text through a series of convolution and pooling operations, and pass these features to the fully connected layer for classification. The model structure is as follows Figure 4 shown.

[0070] Step 3.1: Convert the vector representation T into a matrix X of dimension d:

[0071]

[0072] Where n is the length of the text, d is the dimension of the word vector, and x i,j Represents the value of the i-th word in the j-dimension, which is sent to CNN for further processing;

[0073] Step 3.2: Extract local features of the text in the convolution layer. Using convolution kernels of different sizes helps capture semantic information in different ranges. Smaller convolution kernels focus on local word combinations and phrase structures, and can capture subtle features and local patterns in the text, thereby modeling word-level semantic information. Larger convolution kernels cover a wider range of text and can capture more macroscopic semantic structures and sentence-level features. At the same time, convolution kernels of different sizes can increase the receptive field of the model and enrich the feature representation, so that the model can better understand the semantic information of different levels and different ranges of the text, thereby improving the performance of the model in tasks such as text classification. Use a convolution kernel of size h×d to perform a convolution operation on the input matrix X. The convolution kernel is in the window X. i:i+h-1 The up-convolution operation can be expressed as:

[0074] c i =f(w·X i:i+h-1 +b) (2)

[0075] Where f(·) represents the activation function, X i:i+h-1 represents the i-th row to the i+h-1th row of the matrix X, and b is the bias term;

[0076] The feature vector generated after the convolution kernel slides down:

[0077] C i =[c1, c2, ..., c n-h+1 ] (18)

[0078] A set of feature vectors obtained by n convolution kernels of different sizes is:

[0079] C={C1、C2、···、C n} (19)

[0080] Step 3.3: For each feature map C of the feature vector C i The dimension is reduced by maximum pooling, and the feature vector is finally output after being processed by TextCNN. The calculation formula is as follows:

[0081]

[0082] in Feature vectors extracted by different convolution kernels.

[0083] Step 4: Input the vector C into the BiGRU network model to extract deeper semantic features, and further learn through the multi-head attention mechanism to output the key local feature vector MHead(H).

[0084] The BiGRU model is a bidirectional recurrent neural network consisting of two independent gated recurrent units (GRUs). One GRU unit processes input data in the forward direction of the time series, while the other GRU unit processes input data in the reverse direction of the time series. This bidirectional structure allows the model to consider both previous and subsequent information at each time step, thereby better capturing patterns and dependencies in sequence data. The GRU unit structure is as follows: Figure 5 shown.

[0085] Step 4.1: For the feature vector output by TextCNN The forward and backward calculations of the BiGRU network model can be expressed as:

[0086]

[0087] in, and They represent the forward and backward hidden states at time t, respectively. represents the tth element of the input vector;

[0088] Then the final hidden state at time t is:

[0089]

[0090] in, and are weights, b t is bias;

[0091] Then the final output of BiGRU is H = [h1, h2, ···, h n ];

[0092] The multi-head attention mechanism is a variant of the self-attention mechanism. It captures multi-level semantic information through multiple attention heads, which helps to better capture long-distance dependencies. At the same time, it combines the outputs of multiple attention heads to effectively reduce the overfitting risk of a single head output and improve the expressiveness and generalization capabilities of the model.

[0093] Step 4.2: Take the output H of BiGRU as the input of the multi-head attention mechanism. There are n attention heads. For each attention head i , H is mapped into query (Q), key (K), value (V) matrices through linear transformation:

[0094] Q i =HW i Q (6)

[0095] K i =HW i K (7)

[0096] V i =HWi V (8)

[0097] Among them, W Q , W K and W V Represent the learned weight matrices respectively;

[0098] Step 4.3: By scaling the dot product, the output of each attention head is calculated as follows:

[0099]

[0100]

[0101] Among them, dk are the dimensions of Q and K;

[0102] Step 4.4: Get the final output by concatenating the outputs of n attention heads:

[0103] MHead(H)=Concat(head1,head2,···,head n )W O (10)

[0104] Among them, W O is the weight matrix, and Concat represents the concatenation operation.

[0105] Step 5: Input the vector representation T into the TextRCNN model to obtain comprehensive context feature information and output the context feature vector R;

[0106] TextRCNN combines the advantages of CNN and RNN, considers context information, and combines the original word embedding with context information to form a new word embedding representation, which is conducive to capturing the semantics of long texts. Figure 6 .

[0107] Step 5.1: For each word t i And the corresponding word vector T i , after bidirectional RNN extracts features, the output is as follows:

[0108] c l (t i )=f(W l c l (t i-1 )+W sl T i-1 ) (11)

[0109] c r (t i )=f(W l c r (t i+1 )+W sr T i+1 ) (12)

[0110] Among them, l and r represent the left and right sides of the word respectively;

[0111] Step 5.2: Concatenate the output of the bidirectional RNN and the word vector corresponding to the word to form a new word vector representation:

[0112] x i =[c l (t i ),T i ,c r (ti )] (13)

[0113] Step 5.3: Use the tanh activation function and obtain the contextual features of the sentence through maximum pooling:

[0114]

[0115] in, represents the latent semantic vector.

[0116] Step 6: Concatenate the key local feature MHead(H) and the context feature R as the final feature vector MHR, and use the softmax function to classify its intent after dimensionality reduction.

[0117] Step 6.1: Vector stitching:

[0118] MHR=[MHead(H),R] (16)

[0119] Among them, MHR is the final feature vector;

[0120] Step 6.2: The classification calculation formula can be expressed as:

[0121] S = softmax(w1·MHR+b1) (17)

[0122] Where S is the final classification result, w1 and b1 are weights and biases.

[0123] Example 2

[0124] The present embodiment relates to a device for identifying the intention of a question and answer for a chronic disease based on local features and contextual features, comprising a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement a method for identifying the intention of a question and answer for a chronic disease based on local features and contextual features of embodiment 1.

[0125] Example 3

[0126] This embodiment relates to a computer-readable storage medium on which a program is stored. When the program is executed by a processor, a method for identifying the intention of a chronic disease question and answer based on local features and context features of embodiment 1 is implemented.

[0127] The above is a preferred embodiment of the present invention. Even if some adjustments or changes are made according to the concept of the present invention, as long as the new functions or effects produced still comply with the spirit and principles covered by the specification and drawings, these adjustments or changes should still be deemed to be within the scope of protection of the present invention.

Claims

1. A method for identifying the intention of chronic disease question answering based on local features and context features, characterized in that: The steps include: (1) The text is converted into a vector representation T = {T1, T2, ..., T N }; (2) Construct the intent recognition model TBGMA-TR, which includes the sequentially arranged TextCNN model, BiGRU model, multi-head attention mechanism, and TextRCNN model; (3) Input the vector T obtained in step (1) into the TextCNN network model, and obtain the output vector after convolution, pooling and concatenation. in Represents the feature vector extracted by different convolution kernels; (4) Input the vector C into the BiGRU network model to extract deeper semantic features, and further learn through the multi-head attention mechanism to output the key local feature vector MHead(H); (5) Input the vector representation T in step (1) into the TextRCNN model to obtain comprehensive context feature information and output the context feature vector R; (6) The key local feature MHead(H) and the context feature R are concatenated as the final feature vector MHR, and the softmax function is used to classify its intent after dimensionality reduction.

2. According to claim 1, a method for identifying the intention of chronic disease question and answer based on local features and context features, characterized in that: The step (3) is specifically as follows: (3.1) Convert the vector representation T into a matrix X of dimension d: Where n is the length of the text, d is the dimension of the word vector, and x i,j Represents the value of the i-th word in the j-dimension, which is sent to CNN for further processing; (3.2) Extract local features of the text in the convolution layer. Use a convolution kernel of size h×d to perform a convolution operation on the input matrix, where h is the height of the convolution kernel and d is the word vector T. i The convolution kernel moves downward with a fixed step length to perform convolution operations on the matrix area it covers until it moves to the bottom of the matrix. Each movement is calculated once, and finally a set of feature vectors C = {C1, C2, ..., C n }, n represents n convolution kernels of different sizes, and the convolution operation can be expressed as: c i =f(w·X i:i+h-1 +b) (2) Where f(·) represents the activation function, X i:i+h-1 represents the i-th row to the i+h-1th row of the matrix X, and b is the bias term; (3.3) For each feature map C of the feature vector C i The dimension is reduced by maximum pooling to obtain the pooled feature vector in is the feature map C i The maximum value of . After concatenation, we get the feature vector that is finally output after TextCNN processing.

3. According to claim 1, a method for identifying the intention of chronic disease question and answer based on local features and context features, characterized in that: The implementation method of obtaining the key local features through learning of the BiGRU network and the multi-head attention mechanism in step (4) is as follows: (4.1) For the feature vector output by TextCNN The calculation of the BiGRU network model can be expressed as: in, and They represent the forward and backward hidden states at time t, respectively. represents the tth element of the input vector, h t is the final hidden state at time t, and are weights, b t is the bias, then the final output of BiGRU is H = [h1, h2, ..., h n ]; (4.2) The output H of BiGRU is used as the input of the multi-head attention mechanism. There are n attention heads. For each attention head i , H is mapped into query (Q), key (K), value (V) matrices through linear transformation: Q i =HW i Q (6) K i =HW i K (7) V i =HW i V (8) Among them, W Q , W K and W V Represent the learned weight matrices respectively; (4.3) By scaling the dot product, the output of each attention head is calculated as follows: Among them, d k are the dimensions of Q and K; (4.4) By concatenating the outputs of n attention heads, we get the final output: MHead(H)=Concat(head1,head2,…,head n )W O (10) Among them, W O is the weight matrix, and Concat represents the concatenation operation.

4. According to claim 1, a method for identifying the intention of chronic disease question and answer based on local features and context features, characterized in that: The step (5) specifically comprises: (5.1) For each word t i And the corresponding word vector T i , after bidirectional RNN extracts features, the output is as follows: c l (t i )=f(W l c l (t i-1 )+W sl T i-1 ) (11) c r (t i )=f(W l c r (t i+1 )+W sr T i+1 ) (12) Among them, 1 and r represent the left and right sides of the word respectively; (5.2) Concatenate the output of the bidirectional RNN and the word vector corresponding to the word to form a new word vector representation: x i =[c l (t i ), T i , c r (t i )] (13)(5.3) Use the tanh activation function and the maximum pooling to obtain the contextual features of the sentence: y i (2) =tanh(W (2) x i +b (2) ) (14) Among them, y i (2) represents the latent semantic vector.

5. According to claim 1, a method for identifying the intention of chronic disease question and answer based on local features and context features, characterized in that: The step (6) specifically comprises the following steps: (6.1) Vector concatenation: MHR=[MHead(H), R] (16) Among them, MHR is the final feature vector; (6.2) The classification calculation formula can be expressed as: S=s0ftmax(w1·MHR+b1)(17) Where S is the final classification result, w1 and b1 are weights and biases.

6. A device for identifying the intention of chronic disease question and answer based on local features and context features, characterized in that: It includes a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, it is used to implement a method for identifying the intention of chronic disease question and answer based on local features and context features as described in any one of claims 1-5.

7. A computer-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, a method for identifying the intention of a chronic disease question and answer based on local features and context features as described in any one of claims 1-5 is implemented.