Similar question matching method based on Coarse2Fine network

Through the combination of Coarse2Fine network and ESIM network, BM25 and BiLSTM are used to match similar problems, which solves the problems of excessive matching results and long time-consuming in the existing technology, and achieves higher matching accuracy and operating efficiency.

CN113988081BActive Publication Date: 2024-09-06JIANGSU UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111188461.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-12
Publication Date
2024-09-06
Estimated Expiration
2041-10-12

AI Technical Summary

Technical Problem

Existing similar question matching technology in intelligent customer service and chat robots has the problem of too many matching results and the inability to select the best match, and it takes a long time to train and run.

Method used

A similar problem matching method based on the Coarse2Fine network is used, coarse-grained matching is performed through the BM25 model, feature values ​​are extracted using the ESIM network, and fine-grained analysis is performed in combination with word embedding and BiLSTM, and attention mechanisms and multi-layer perceptual classifiers are used to improve matching accuracy. .

Benefits of technology

The matching accuracy has been improved from 40% to 60% to 70%, which solves the problem of difficulty in selecting high-scoring items and significantly improves the running speed and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113988081B
    Figure CN113988081B
Patent Text Reader

Abstract

The present invention discloses a similar problem matching method based on Coarse2Fine network, comprising the following steps: Step 1: Use data set training to obtain a corresponding Coarse2Fine model; Step 2: Use the BM25 model in the Coarse2Fine model to perform coarse-grained similarity matching between the statement to be processed and the statement in the database to obtain several matching statements; Step 3: Extract feature values ​​of the statement to be processed and the matching statement in the ESIM network, and calculate the difference value between the feature value of the statement to be processed and the feature value of several matching statements one by one; Step 4: Extract matching statements with small difference values ​​in the ESIM network as the output result of similar statements. The present invention solves the problem that too many high-scoring items cannot be selected for the best matching result due to the use of ESIM network matching alone.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of language matching, and in particular to a similar question matching method based on a Coarse2Fine network. Background Art

[0002] Similar question matching technology plays a key role in the current natural language processing applications such as intelligent customer service and chatbots. In actual applications, the core of similar question matching is to establish a similar question matching model. Common technologies are mainly divided into two types: one is based on the sentence vector representation of word embedding stacking, and the similarity is judged by calculating the cosine vector between two sentences; the second is to calculate the semantics of two sentences, using word embedding, RNN, LSTM, etc. to represent the semantics of the sentences, and then use cosine to calculate the distance or full connection and softmax layer to calculate the probability of synonymy and non-synonymy of the sentences. Commonly used models include Google Bert model and Baidu's Erine series. Both models are trained based on massive data and have achieved 86.9% and 87.9% accuracy on the LCQMC model respectively. However, due to the large size of Bert and Erine models, training and running take a long time, so the enhanced LSTM network, namely ESIM text reasoning network, is selected to implement similar question matching technology. Summary of the invention

[0003] The technical problem to be solved by the present invention is: given a question, feature extraction is performed, question similarity matching is performed according to feature values, and high-scoring matching items are obtained as similar questions.

[0004] In order to achieve the above-mentioned purpose, the technical solution of the present invention is realized.

[0005] A similar question matching method based on Coarse2Fine network includes the following steps:

[0006] Step 1: Upload the dataset to the database and use the dataset to train the corresponding Coarse2Fine model;

[0007] Step 2: Upload the statement to be processed through the upload interface of the Coarse2Fine model interface, use the BM25 model in the Coarse2Fine model to perform coarse-grained similarity matching between the statement to be processed and the statements in the database, obtain several matching statements, and use the statement to be processed and several matching statements as the input of the ESIM network of the Coarse2Fine model;

[0008] Step 3: Extract the feature values ​​of the sentence to be processed and the matching sentence in the ESIM network, and calculate the difference value between the feature value of the sentence to be processed and the feature values ​​of several matching sentences one by one;

[0009] Step 4: Extract matching statements with small difference values ​​in the ESIM network as the output results of similar statements.

[0010] Furthermore, in step 2, the BM25 model in the Coarse2Fine model is used to perform coarse-grained similarity matching between the sentence to be processed and the sentence in the database, and several matching sentences are obtained, specifically:

[0011] Perform morpheme analysis on the sentence to be processed and a sentence in the database, and then calculate the score of the correlation between the two sentences. The score calculation formula is as follows:

[0012]

[0013] Among them, Q represents the input statement, d represents the statement to be matched in the database, and q i Represents the basic unit of question matching, W i Indicates q i The weight of R(q i , d) represents the morpheme q i Correlation score with d.

[0014] Finally, based on the relevance scores, several matching statements with high scores that meet the requirements are extracted.

[0015] Furthermore, in step 3, the specific method for extracting the feature values ​​of the to-be-processed statement and the matching statement in the ESIM network is as follows:

[0016] The ESIM network uses word embedding and BiLSTM to relearn the word representations of the sentences to be processed and the matching sentences according to the context, obtains the encoded representations of the sentences to be processed and the matching sentences, obtains the weighted encoded representations of the sentences to be processed and the matching sentences according to the attention weights, and uses the encoded representations and weighted encoded representations as feature values.

[0017] Furthermore, in step 3, the ESIM network uses word embedding and BiLSTM to relearn the word representation of the sentence to be processed and the matching sentence according to the context, and obtains the specific formula of the encoding representation of the sentence to be processed and the matching sentence as follows:

[0018]

[0019]

[0020] Among them, a and b represent two sentences input respectively, i and j represent the sequence number of a word in the sentence, l a and lb represent the lengths of sentences a and b, and are the vector representations of a word in the input sentences a and b respectively.

[0021] Furthermore, in step 3, the specific method of obtaining the weighted coding representation of the sentence to be processed and the matching sentence according to the attention weight is: using the attention mechanism to calculate the word vector connection between the sentence to be processed and the matching sentence:

[0022]

[0023] in, Represents the product of the transposition of each word vector in input sentence a and each word vector in input sentence b;

[0024] Then, the weighted values ​​of the statements to be processed and the matching statements are calculated according to the following formula, and the specific formulas for the weighted coding representation of the statements to be processed and the matching statements are obtained as follows:

[0025]

[0026] in, and Represent the weighted encoding representation of a word in input sentences a and b respectively.

[0027] Furthermore, in step 3, and Perform difference and dot product operations respectively to obtain the difference value m a and m b , the difference value calculation formula is as follows:

[0028]

[0029] in, and Represent the encoding value and weighted encoding value of input sentences a and b respectively.

[0030] Furthermore, the step 4 is specifically as follows:

[0031] The local reasoning information and context information of the difference value are obtained through the BiLSTM layer, the obtained results are subjected to maximum pooling and average pooling, and the pooled values ​​are concatenated again and put into a new vector. The vector is input into the multi-layer perception classifier, and finally the softmax function is used in the output layer to obtain the matching sentences with small difference values.

[0032] Compared with the prior art, the advantages of the present invention are:

[0033] 1) The matching probability output by ESIM is combined with the probability output after the initial word vector stacking and matching according to the weights, making the model more general and achieving better matching results without retraining the word vectors. This solves the problem of too many high-scoring items and being unable to select the best matching result when using only the ESIM network for matching.

[0034] 2) The top ten matches with the highest matching rate were extracted using the 1-to-N similarity matching mode, and the matching accuracy was increased from 40% to 60% to 70%.

[0035] 3) Since there are cases where sentences have high matching but irrelevant meanings, the present invention designs a combination method of coarse-to-fine similarity matching + pre-training model, using a large data set to train a broad teacher model, and then training it on a special data set. The improved algorithm has significantly improved both the running speed and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The features and advantages of the present invention will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the present invention in any way. In the accompanying drawings:

[0037] Figure 1 It is the overall framework for the application of the model of the present invention;

[0038] Figure 2 This is a structural diagram of the ESIM model used in the present invention. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution 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 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 those skilled in the art without creative work are within the scope of protection of the present invention.

[0040] In order to explain the present invention more clearly, the following explanation is given for the implementation method: the present invention gives a premise p and derives a hypothesis h. The goal of its loss function is to determine whether p is related to h, that is, whether h can be derived from p. Therefore, the model can also do text matching, but the goal of the loss function is whether the two sequences are synonymous sentences, and p and h are also understood as sentence a and sentence b. The core of the present invention is to use enhanced LSTM for fine-grained feature extraction, that is, ESIM network feature extraction, which has three main key components: input encoding layer, Local InferenceModeling layer, and combined inference layer.

[0041] like Figure 1 and 2 As shown, the specific embodiment of the present invention is as follows: A similar question matching method based on Coarse2Fine network, characterized in that it includes the following steps:

[0042] Step 1: Upload the dataset to the database and use the dataset to train the corresponding Coarse2Fine model; this model can provide the function of similarity calculation for similar problem matching.

[0043] Step 2: Upload the sentence to be processed through the upload interface of the Coarse2Fine model interface, use the BM25 model in the Coarse2Fine model to perform coarse-grained similarity matching between the sentence to be processed and the sentences in the database, and obtain several matching sentences. The sentence to be processed and several matching sentences are used as the input of the ESIM network of the Coarse2Fine model; through the coarse-grained matching stage, the sentence to be processed and the sentence to be matched in the database can be analyzed for morphemes, and the correlation score between the two sentences can be calculated for preliminary matching, thereby improving the matching speed.

[0044] Specifically:

[0045] Perform morpheme analysis on the sentence to be processed and a sentence in the database, and then calculate the score of the correlation between the two sentences. The score calculation formula is as follows:

[0046]

[0047] Among them, Q represents the input statement, d represents the statement to be matched in the database, and q i Represents the basic unit of question matching, W i Indicates q i The weight of R(q i , d) represents the morpheme q i Correlation score with d.

[0048] Finally, based on the relevance scores, several matching statements with high scores that meet the requirements are extracted.

[0049] Step 3: Extract the feature values ​​of the sentences to be processed and the matching sentences in the ESIM network.

[0050] The specific method is as follows:

[0051] The ESIM network uses word embedding and BiLSTM to relearn the word representations of the sentences to be processed and the matching sentences according to the context, and obtains the encoded representations of the sentences to be processed and the matching sentences.

[0052] The specific formula is as follows:

[0053]

[0054] Among them, a and b represent two sentences input respectively, i and j represent the sequence number of a word in the sentence, l a and lb represent the lengths of sentences a and b, and are the vector representations of a word in input sentences a and b respectively.

[0055] According to the attention weights, weighted coding representations of the sentences to be processed and the matching sentences are obtained, and the coding representations and the weighted coding representations are used as feature values;

[0056] The specific method is: use the attention mechanism to calculate the word vector connection between the sentence to be processed and the matching sentence:

[0057]

[0058] in, Represents the product of the transposition of each word vector in input sentence a and each word vector in input sentence b;

[0059] Then, the weighted values ​​of the statements to be processed and the matching statements are calculated according to the following formula, and the specific formulas for the weighted coding representation of the statements to be processed and the matching statements are obtained as follows:

[0060]

[0061] in, and Represent the weighted encoding representation of a word in input sentences a and b respectively;

[0062] Will Perform difference and dot product operations respectively to obtain the difference value m a and m b , the difference value calculation formula is as follows:

[0063]

[0064] in, and Represent the encoding value and weighted encoding value of input sentences a and b respectively,

[0065] Calculate the difference value between the feature value of the sentence to be processed and the feature values ​​of several matching sentences one by one;

[0066] Specifically, the ESIM network is divided into an encoding layer and a local inference modeling layer. The input sentence is encoded, and the similarity between the words in the two sentences is calculated to obtain a two-dimensional similarity matrix as a weight. The encoded representation and weighted encoded representation of the input sentence and the sentence to be matched are obtained as the difference value of the sentence.

[0067] Step 4: Extract matching statements with small difference values ​​in the ESIM network as the output results of similar statements.

[0068] The details are as follows:

[0069] The local reasoning information and context information of the difference value are obtained through the BiLSTM layer, the obtained results are subjected to maximum pooling and average pooling, and the pooled values ​​are concatenated again and put into a new vector. The vector is input into the multi-layer perception classifier, and finally the softmax function is used in the output layer to obtain the matching sentences with small difference values.

[0070] The difference values ​​obtained in step 3 are subjected to difference and dot product operations and put into a new vector. The matching sentences with small difference values ​​are obtained with the help of multi-layer perceptron classifier and softmax function.

[0071] In general, the three parts of ESIM have their own functions. In the input encoding layer, ESIM uses word embedding and BiLSTM to relearn to represent a word according to the context. Generally speaking, pre-trained word vectors are used. This layer can also be understood as a feature extraction layer. The output of this layer is and Where i and j represent a and b at different times. Here a and b are the results of the two input sentences after word embedding. and It can be expressed as the following formula:

[0072]

[0073] The BiLSTM here is a bidirectionally encoded LSTM. Compared with LSTM which only focuses on the context, BiLSTM uses bidirectional encoding to focus on the context.

[0074]

[0075] The next task of Local Inference Modeling is to calculate the difference of the feature values ​​obtained in the previous round, using the attention mechanism. The weight calculation method of attention is, and then the weighted value of a and b is calculated based on the weight of attention. The calculation method is as follows.

[0076] After obtaining the encoding and weighted encoding, the ESIM network performs a difference calculation on these two values. This is also an improvement of the ESIM model. The interaction between sentence a and sentence b is performed in the middle layer, which is different from the previous pure sentence meaning calculation. The formula for difference calculation is shown in the figure below. The formula contains positional subtraction and positional multiplication. After the calculation is completed, the ESIM network splices these encoded values ​​together.

[0077]

[0078] The last layer is the Inference Compostion layer, which is the combined inference layer. In this layer, the data from the upper layer will continue to be sent to the BiLSTM layer. However, the function of the BiLSTM here is different from that of the BiLSTM in the first encoding layer. The BiLSTM here mainly obtains local reasoning information and context to facilitate the next step of reasoning. Finally, the values ​​obtained by the BiLSTM are pooled, including maximum pooling and average pooling, and the pooled values ​​are concatenated again.

[0079]

[0080] V=[V a,ave ; V a,max ; V b,ave ; V b,max ]

[0081] The last layer of the network is the fully connected layer and the softmax layer for classification tasks, and the activation function uses tanh.

[0082] This embodiment develops a model based on the Coarse2Fine network for similar question matching. The system combines the matching probability output by ESIM with the probability output after the initial word vector stacking match according to the weight, so that the model is more general without retraining the word vector, and the matching effect is better, which solves the problem of too many high-scoring items and unable to select the best matching result caused by using only the ESIM network matching. Experiments have found that ESIM has an accuracy of 83.85% on the LCQMC dataset, but after preliminary coarse-grained matching using BM25, the effect is similar to other mainstream models, but the training speed is much faster. For the case where the sentence matching score is high but the sentence meaning is irrelevant, the present invention uses a combination method of coarse-to-fine similarity matching + pre-training model, selects a large data set to train a broad teacher model, and then trains it on a special data set. When calculating the results, the similarity result is calculated by the ESIM network, and the sentence vector is calculated by word2vec to calculate the similarity, and finally the results of the two are weighted according to the corresponding proportion to obtain the final result. The matching mode of the present invention is 1:N matching, and the first few items with the highest scores are selected each time. When the ESIM network is used alone, about 4 to 5 of the first ten items are irrelevant items but still get high scores. After adopting the improved algorithm of the present invention, the accuracy is greatly improved, and only 1 to 2 sentences are judged incorrectly, and the algorithm improvement effect is significant.

[0083] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A similar question matching method based on Coarse2Fine network, characterized in that: The following steps are involved: Step 1: Upload the dataset to the database and use the dataset to train the corresponding Coarse2Fine model; Step 2: Upload the statement to be processed through the upload interface of the Coarse2Fine model interface, use the BM25 model in the Coarse2Fine model to perform coarse-grained similarity matching between the statement to be processed and the statements in the database, and obtain several matching statements. The statement to be processed and several matching statements are used as the input of the ESIM network of the Coarse2Fine model. Among them, the BM25 model in the Coarse2Fine model is used to perform coarse-grained similarity matching between the sentences to be processed and the sentences in the database, and several matching sentences are obtained, specifically: Perform morpheme analysis on the sentence to be processed and a sentence in the database, and then calculate the score of the correlation between the two sentences. The score calculation formula is as follows: Among them, Q represents the input statement, d represents the statement to be matched in the database, and q i Represents the basic unit of question matching, W i Indicates q i The weight of R(q i , d) represents the morpheme q i correlation score with d; Finally, according to the relevance score, several matching statements with high scores and meeting the requirements are extracted; Step 3: Extract the feature values ​​of the sentences to be processed and the matching sentences in the ESIM network, and calculate the difference values ​​between the feature values ​​of the sentences to be processed and the feature values ​​of several matching sentences one by one. Among them, the specific method of extracting the feature values ​​of the sentences to be processed and the matching sentences in the ESIM network is as follows: The ESIM network uses word embedding and BiLSTM to relearn the word representation of the sentence to be processed and the matching sentence according to the context, and obtains the encoding representation of the sentence to be processed and the matching sentence. The specific formula is as follows: Among them, a and b represent two sentences input respectively, i and j represent the sequence number of a word in the sentence, l a and l b represents the length of sentences a and b, and are the vector representations of a word in input sentences a and b respectively; The weighted encoding representation of the sentence to be processed and the matching sentence is obtained according to the attention weight. The specific method is: use the attention mechanism to calculate the word vector connection between the sentence to be processed and the matching sentence: in, Represents the product of the transposition of each word vector in input sentence a and each word vector in input sentence b; Then, the weighted values ​​of the statements to be processed and the matching statements are calculated according to the following formula, and the specific formulas for the weighted coding representation of the statements to be processed and the matching statements are obtained as follows: in, and Represent the weighted encoding representation of a word in input sentences a and b respectively; Will and Perform difference and dot product operations respectively to obtain the difference value m a and m b , the difference value calculation formula is as follows: in, and Represent the encoding value and weighted encoding value of input sentences a and b respectively; The coded representation and the weighted coded representation are used as feature values; Step 4: Extract matching statements with small difference values ​​in the ESIM network as the output results of similar statements.

2. The similar question matching method based on Coarse2Fine network according to claim 1, characterized in that: The step 4 is specifically as follows: The local reasoning information and context information of the difference value are obtained through the BiLSTM layer, the obtained results are subjected to maximum pooling and average pooling, and the pooled values ​​are concatenated again and put into a new vector. The vector is input into the multi-layer perception classifier, and finally the softmax function is used in the output layer to obtain the matching sentences with small difference values.