A multi-channel short text matching method integrating external knowledge and syntactic structure
Through a multi-channel short text matching method that integrates external knowledge and syntactic structures, the problem of difficulty in capturing long-distance dependencies and utilizing external knowledge in the prior art is solved, and a more accurate and robust short text matching effect is achieved.
Patent Information
- Application Number
- CN202411840041.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-08
AI Technical Summary
Existing short text matching methods are difficult to effectively capture long-distance dependencies, especially in complex semantic and syntactic analysis, and insufficient utilization of external knowledge, affecting the accuracy of text matching.
A multi-channel short text matching method that integrates external knowledge and syntactic structures is proposed. By obtaining the text to be matched, semantic eigenvectors and syntactic structure feature vectors are generated, and fused them to generate a comprehensive eigenvector, and finally input the classifier to output the matching result.
By introducing external knowledge resources such as HowNet, calculating semantic similarity of vocabulary, and combining attention mechanisms, the model can more accurately identify synonyms and syntactic structures, improving the accuracy and robustness of short text matching.
Smart Images

Figure CN119782512A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning technology, and more specifically to a multi-channel short text matching method integrating external knowledge and syntactic structure. Background Art
[0002] In the study of short text matching, how to accurately parse and compare key information in the text is crucial for application scenarios such as search engine optimization, intelligent question answering systems, and information retrieval. However, due to the flexible and diverse expression of text, which often contains complex factors such as semantic ambiguity, synonyms, and phrase structure differences, the text matching task faces huge challenges.
[0003] Current short text matching methods are mainly divided into three categories: rule- and template-based methods, traditional machine learning-based methods, and deep learning-based methods.
[0004] Rule- and template-based methods perform well when processing structured texts, but they show significant limitations when it comes to diverse and complex text expressions. The main problem is the lack of flexibility and difficulty in dealing with the diversity and ambiguity in the text.
[0005] Traditional machine learning methods such as decision trees and support vector machines have improved the accuracy of matching to a certain extent, but they usually rely on a lot of feature engineering and have limited effects when dealing with semantic understanding and contextual associations in text. Feature engineering requires manual design and selection of features, which is insufficient for dealing with polysemous words, contexts, and syntactic structures in complex texts.
[0006] Deep learning-based methods such as long short-term memory (LSTM) and convolutional neural networks (CNN) have made significant progress in the field of natural language processing in recent years and have demonstrated good results in text matching tasks. Deep learning methods can reduce reliance on manual feature engineering by automatically learning features. However, these deep learning-based methods still have shortcomings and are difficult to effectively capture long-distance dependencies, especially in complex semantic and syntactic analysis. In addition, existing deep learning models do not fully utilize external knowledge such as dictionaries and knowledge graphs.
[0007] In summary, due to the diversity and complexity of text expressions, the deep learning models constructed by the existing short text matching methods have poor processing effects on newly emerging short texts and complex structures, are difficult to cope with diverse language phenomena, and cannot effectively capture long-distance dependencies, affecting the accuracy of text matching. Summary of the invention
[0008] In response to the problems existing in the above-mentioned fields, the present invention proposes a multi-channel short text matching method that integrates external knowledge and syntactic structure, performs feature extraction on the text to be matched, generates semantic feature vectors of the text that integrates the original meaning information and the syntactic structure feature vectors of the text, and integrates them, aiming to achieve efficient and accurate matching of short texts through multi-dimensional fusion information.
[0009] In order to solve the above technical problems, the present invention discloses a multi-channel short text matching method integrating external knowledge and syntactic structure, comprising the following steps:
[0010] Get the text to be matched;
[0011] According to the obtained text to be matched, based on the semantic relationship of the sememes in the external knowledge base HowNet, the semantic similarity between words is calculated by topological distance, and the sememe similarity matrix between words is determined; by calculating the attention score of the text, the attention weight of each word in the text is obtained; according to the sememe similarity matrix between words and the attention weight of each word in the text, the semantic feature vector of the text pair that integrates the sememe information is generated;
[0012] By parsing the dependency relationship of the text and constructing a dependency structure graph, the initial features of each node and the features of the edge are determined; based on the initial features of each node and the features of the edge, the node features are updated through the graph matching network GMN, and the nodes, edges and their features of the graph are encoded into vector representations to obtain the syntactic structure feature vector of the text;
[0013] The semantic feature vector and the syntactic structure feature vector are fused to obtain a comprehensive feature vector;
[0014] The comprehensive feature vector is input into the classifier and the text matching result is output.
[0015] Preferably, determining the semantic similarity matrix between words specifically includes:
[0016] Get the texts A and B to be matched, and encode the words of texts A and B using Word2Vec;
[0017] Divide text A and B into single vocabulary units respectively, and define text A containing m words as Text B is in, represents the i-th character of text A, Represents the jth character of text B;
[0018] According to the divided single vocabulary units, use Word2Vec to build a vocabulary, which contains all the words that appear in the text, and each word has a unique ID;
[0019] Word2Vec learns the word vector of each word through the continuous bag of words model, where the continuous bag of words model predicts the current word through the surrounding words of the context word; for a given text, Word2Vec averages the word vectors in it to get the vector representation of the entire text;
[0020] The output of the Word2Vec model is recorded as Represents the i-th hidden layer vector of the model output text A, Represents the jth hidden layer vector of the model output text B;
[0021] Output of the Word2Vec model Out Word2Vec Input into the BiLSTM model and get the output vector h A ,h B ; Obtain the global semantic features of the text through the BiLSTM model;
[0022] Based on the semantic relationship of the sememes in the external knowledge base HowNet, the size of the constructed sememe similarity matrix is m×n, and the values in the sememe similarity matrix SimMatrix are calculated;
[0023] When the word pair When the content in is a synonym in HowNet, the corresponding cell position is 1; when it is not a synonym, the similarity is calculated based on the topological distance in HowNet, and the similarity score is set to a value between 0 and 1; when one or both of the two words do not exist in HowNet, or the similarity value is invalid, the similarity score is set to 0.
[0024] Preferably, generating a semantic feature vector of the text pair integrating the semantic primitive information specifically includes:
[0025] In the collaborative attention layer, the affinity matrix C of two texts A and B is calculated through the Parallel paradigm. Among them, W c is the training weight matrix;
[0026] Calculate the hidden layer feature representation H of text A and B A and H B , the calculation formula is:
[0027] H A =tanh(W1h A +(W2h B )C)
[0028] H B =tanh(W2h B +(W1h A )C)
[0029] Among them, W1 and W2 are the training weight matrices;
[0030] Calculate the attention score and incorporate the semantic similarity matrix into the calculation. The improved formula is as follows:
[0031]
[0032]
[0033] in, is the training weight matrix, SimMatrix is the sememe similarity matrix;
[0034] Apply the obtained attention score to each word in the text to obtain a new text feature vector, i.e. h' A =∑ i Scores A (i) H A (i), h' B =∑ i Scores B (i) H B (i), where Scores A (i) represents the attention weight of the i-th word in text A;
[0035] The text feature vector h of the collaborative attention layer A ' and h B 'Concatenate the texts to obtain the semantic feature vector h1 that integrates the original meaning information of the text.
[0036] Preferably, the determining of the initial features of each node and the features of the edge comprises the following steps:
[0037] Get the dependency structure graph G constructed by text A A =(N A ,E A ), where: Nx = {a1, a2, …, a n} represents the set of word nodes, E A ={(a i ,a j ,r ij )} represents the set of dependency edges, a i , a j For words, r ij For dependency relationship;
[0038] Determine the initial features of each node as Represents each node in the graph, Including vocabulary embedding and part-of-speech embedding, the embedded vector obtained by concatenation is used as the final feature of the node: word i For word w i The embedding vector of POS i For word w i The part-of-speech embedding vector of
[0039] Determine the characteristics of the edge as Represents the dependency type, assigns a unique identifier to each dependency according to the category, and creates an initial embedding matrix in which each row corresponds to the embedding vector of a dependency category, that is, the dependency embedding of edge (i, j) is e ij .
[0040] Preferably, the step of obtaining the syntactic structure feature vector of the text comprises the following steps:
[0041] The node features are updated through the graph matching network GMN. The nodes, edges and their features of the graph are encoded as vector representations. The graph neural network GNN is used to capture the local and global structural information in the graph. The update is completed by combining the information of neighbor nodes. The formula is as follows:
[0042]
[0043] in, represents the feature representation of node v at layer l+1, represents the feature representation of neighbor node u at layer l, N'(v) is the set of neighbor nodes of node v, is the feature representation of edge vu (i.e., the edge connecting node v and node u) at layer l, W (l) is the weight matrix, b (l) represents the bias term of the lth layer;
[0044] After updating nodes in multiple layers, we get the graph representation G of two texts A and B. A ', G B '; The graph matching network GMN uses an interactive mechanism to calculate the similarity between two graphs through a similarity measurement function. The formula is as follows:
[0045]
[0046] in, Indicates the feature similarity between nodes, and the feature similarity is calculated by cosine similarity; is the attention weight of node matching, indicating the matching degree between nodes v1 and v2, and adopts the exponential decay of node distance, that is, λ is an adjustable parameter;
[0047] The calculated S(G' A ,G B') as the similarity feature vector of the syntactic structures of the two texts, that is, the syntactic structure feature vector h2.
[0048] Preferably, it also includes:
[0049] Encode through the Bert model to obtain the context representation vector of each word and the context semantic feature vector of the text pair;
[0050] The semantic feature vector, the syntactic structure feature vector and the text context semantic feature vector are fused to obtain a comprehensive feature vector;
[0051] The comprehensive feature vector is input into the classifier, and the three-channel text matching result is output.
[0052] Preferably, the obtaining of the text-to-context semantic feature vector specifically includes:
[0053] Encode through the Bert model to obtain the context representation vector of each word;
[0054] Concatenate the two input texts A and B and add [CLS] and [SEP] tags to get in, represents the i-th character of text A, Represents the jth character of text B, and inputs it into the Bert model accordingly, and the output of the Bert model is:
[0055]
[0056] in, represents the i-th hidden layer vector of text A, Represents the jth hidden layer vector of text B;
[0057] After the Bert model output, the [CLS] part is extracted to obtain the text pair context semantic feature vector h3.
[0058] Preferably, the step of obtaining a comprehensive feature vector specifically includes:
[0059] The obtained semantic feature vector h1 of the text pair fusion original information, the syntactic structure feature vector h2 and the text pair context semantic feature vector h3 are weighted fused respectively, that is, the vector h i (i=1,2,3) perform weighted fusion to obtain the weighted feature vectors h'1, h'2 and h'3 of each channel;
[0060] The weighted feature vectors h'1, h'2 and h'3 of each channel are concatenated to form a comprehensive feature vector h final =[h′1;h′2;h′3].
[0061] Preferably, the output text matching result specifically includes:
[0062] The comprehensive feature vector h final Input into the fully connected classifier softmax, and output the final matching result y as:
[0063] y=softmax(W c ·h final +b c )
[0064] Among them, W c is the weight matrix, b c is the bias term.
[0065] Compared with the prior art, the present invention has the following beneficial effects:
[0066] The multi-channel short text matching method integrating external knowledge and syntactic structure proposed in the present invention introduces HowNet external knowledge resources through the constructed multi-channel short text matching model, constructs a semantic similarity matrix by calculating the semantic similarity of words in the short text, enables the model to more accurately identify synonyms, near synonyms and abbreviations, improves the semantic understanding in short text matching, and enhances the robustness of the model in polysemous word processing. The similarity matrix is combined with the attention mechanism, so that the model pays more attention to the word pairs with high semantic correlation in the short text. By parsing the dependency relationship of the text, a dependency structure graph is constructed, in which the nodes represent the vocabulary, the edges represent the dependency relationship between words, and the features of the two are part of speech and dependency relationship type, respectively. Through the graph matching network GMN, the model can compare the syntactic structure similarity of two texts, thereby capturing the grammatical structure and logical level of the text. The dependency structure graph can not only capture the syntactic features of the text, but also enhance the understanding of the syntactic dependency relationship through the graph neural network, so that the model has higher robustness in complex syntactic matching. The model generates a comprehensive feature vector by effectively integrating the semantic similarity information of the external knowledge base channel and the syntactic structure information of the dependency graph channel. Through the interaction and fusion of features at these levels, it not only improves the understanding of the grammatical and semantic structure of short texts, but also uses external knowledge to enhance the ability to handle language ambiguity, ultimately achieving accurate matching of short texts. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 A flow chart of the multi-channel short text matching method integrating external knowledge and syntactic structure proposed by the present invention;
[0068] Figure 2 The two-channel short text matching network architecture proposed by the present invention that integrates external knowledge and syntactic structure;
[0069] Figure 3 The three-channel short text matching network architecture proposed in the present invention integrates external knowledge and syntactic structure. DETAILED DESCRIPTION
[0070] The following will be combined with the attached embodiment of the present invention Figure 1-Figure 3 , the technical solutions in the embodiments of the present invention are clearly and completely described. It should be understood that the terms described in the present invention are only used to describe specific implementation methods and are not used to limit the present invention.
[0071] The multi-channel short text matching method constructed by the present invention combines the semantic encoding of Word2Vec and BiLSTM models, the semantic similarity calculation of the external knowledge base and the dependency structure graph to extract text features from multiple dimensions, specifically:
[0072] First, Word2Vec is used to provide basic semantic embedding for words in short texts, and BiLSTM is used to further encode these word vectors in context, capturing contextual information and dependencies in word sequences, and enhancing word-level semantic representation. The bidirectional structure of the BiLSTM model ensures the capture of contextual information at each time step, improving global semantic understanding. The semantic similarity matrix based on the external knowledge base is integrated in the collaborative attention layer to calculate the semantic similarity of words, thereby helping the model identify synonyms, antonyms, abbreviations, and other phenomena, and improving the accuracy and robustness of matching. The dependency graph channel captures the structural relationship between words by parsing the syntactic structure and dependency relationships in the text, enhancing the model's ability to parse complex syntactic structures.
[0073] The matching method proposed in the present invention comprehensively considers the text semantics, vocabulary parts of speech and text syntactic structure characteristics, can comprehensively cope with the grammatical and semantic challenges in short texts, and significantly enhances the matching ability of the model.
[0074] like Figure 1 As shown, the present invention proposes a multi-channel short text matching method integrating external knowledge and syntactic structure, comprising the following steps:
[0075] Get the text to be matched;
[0076] According to the obtained text to be matched, based on the semantic relationship of the sememes in the external knowledge base HowNet, the semantic similarity between words is calculated by topological distance, and the sememe similarity matrix between words is determined; by calculating the attention score of the text, the attention weight of each word in the text is obtained; according to the sememe similarity matrix between words and the attention weight of each word in the text, the semantic feature vector of the text pair that integrates the sememe information is generated;
[0077] By parsing the dependency relationship of the text and constructing a dependency structure graph, the initial features of each node and the features of the edge are determined; based on the initial features of each node and the features of the edge, the node features are updated through the graph matching network GMN, and the nodes, edges and their features of the graph are encoded into vector representations to obtain the syntactic structure feature vector of the text;
[0078] The semantic feature vector and the syntactic structure feature vector are fused to obtain a comprehensive feature vector;
[0079] The comprehensive feature vector is input into the classifier and the text matching result is output.
[0080] Specifically, determining the semantic similarity matrix between words includes:
[0081] like Figure 2 As shown, obtain the texts A and B to be matched, and encode the words of texts A and B through Word2Vec;
[0082] Divide text A and B into single vocabulary units respectively, and define text A containing m words as Text B is in, represents the i-th character of text A, Represents the jth character of text B;
[0083] According to the divided single vocabulary units, use Word2Vec to build a vocabulary, which contains all the words that appear in the text, and each word has a unique ID;
[0084] Word2Vec learns the word vector of each word through the continuous bag of words model, where the continuous bag of words model predicts the current word through the surrounding words of the context word; for a given text, Word2Vec averages the word vectors in it to get the vector representation of the entire text;
[0085] The output of the Word2Vec model is recorded as Represents the i-th hidden layer vector of the model output text A, Represents the jth hidden layer vector of the model output text B;
[0086] Output of the Word2Vec model Out Word2Vec Input into the BiLSTM model and get the output vector h A ,h B ; The global semantic features of the text are obtained through the BiLSTM model; the semantic similarity matrix is integrated into the collaborative attention mechanism to supplement the semantic similarity and obtain the semantic similarity information of the two texts.
[0087] Based on the semantic relationship of the sememes in the external knowledge base HowNet, the size of the constructed sememe similarity matrix is m×n, and the values in the sememe similarity matrix SimMatrix are calculated;
[0088] When the word pair When the content in is a synonym in HowNet, the corresponding cell position is 1; when it is not a synonym, the similarity is calculated based on the topological distance in HowNet, and the similarity score is set to a value between 0 and 1; when one or both of the two words do not exist in HowNet, or the similarity value is invalid, the similarity score is set to 0.
[0089] Generate a semantic feature vector of the text pair that integrates the original meaning information, including:
[0090] In the collaborative attention layer, the affinity matrix C of two texts A and B is calculated through the Parallel paradigm. Among them, W c is the training weight matrix;
[0091] Calculate the hidden layer feature representation H of text A and B A and H B , the calculation formula is:
[0092] H A =tanh(W1h A +(W2h B )C)
[0093] H B =tanh(W2h B +(W1h A )C)
[0094] Among them, W1 and W2 are the training weight matrices;
[0095] Calculate the attention score and incorporate the semantic similarity matrix into the calculation. The improved formula is as follows:
[0096]
[0097] in, is the training weight matrix, SimMatrix is the sememe similarity matrix;
[0098] Apply the obtained attention score to each word in the text to obtain a new text feature vector, i.e. h' A =∑ i Scores A (i) H A (i), h' B =∑ i Scores B(i) H B (i), where Scpres A (i) represents the attention weight of the i-th word in text A;
[0099] The text feature vector h of the collaborative attention layer A ' and h B 'Concatenate the texts to obtain the semantic feature vector h1 that integrates the original meaning information of the text.
[0100] Determining the initial features of each node and the features of the edge includes the following steps:
[0101] Consider the similarity measurement channel of syntactic structure and part of speech, parse dependency relations and construct dependency structure graph. Obtain the dependency structure graph G constructed by text A A =(N A ,E A ), where: N A ={a1,a2,…,a n} represents the set of word nodes, E A ={(a i ,a j ,r ij )} represents the set of dependency edges, a i , a j For words, r ij For dependency relationship;
[0102] Determine the initial features of each node as Represents each node in the graph, Including vocabulary embedding and part-of-speech embedding, the embedded vector obtained by concatenation is used as the final feature of the node: word i For word w i The embedding vector of POS i For word w i The part-of-speech embedding vector of
[0103] Determine the characteristics of the edge as Represents the dependency type, assigns a unique identifier to each dependency according to the category, and creates an initial embedding matrix in which each row corresponds to the embedding vector of a dependency category, that is, the dependency embedding of edge (i, j) is e ij .
[0104] Obtaining the syntactic structure feature vector of the text includes the following steps:
[0105] The node features are updated through the graph matching network GMN. The nodes, edges and their features of the graph are encoded as vector representations. The graph neural network GNN is used to capture the local and global structural information in the graph. The update is completed by combining the information of neighbor nodes. The formula is as follows:
[0106]
[0107] in, represents the feature representation of node v at layer l+1, represents the feature representation of neighbor node u at layer l, N'(v) is the set of neighbor nodes of node v, is the feature representation of edge vu (i.e., the edge connecting node v and node u) at layer l, W (l) is the weight matrix, b (l) represents the bias term of the lth layer;
[0108] After updating nodes in multiple layers, we get the graph representation G of two texts A and B. A ', G B '; The graph matching network GMN uses an interactive mechanism to calculate the similarity between two graphs through a similarity measurement function. The formula is as follows:
[0109]
[0110] in, Indicates the feature similarity between nodes, and the feature similarity is calculated by cosine similarity; is the attention weight of node matching, indicating the matching degree between nodes v1 and v2, and adopts the exponential decay of node distance, that is, λ is an adjustable parameter;
[0111] The calculated S(G' A ,G B ') as the similarity feature vector of the syntactic structures of the two texts, that is, the syntactic structure feature vector h2.
[0112] Obtain a comprehensive feature vector, including:
[0113] The obtained text pairs are weightedly fused with the semantic feature vector h1 and the syntactic structure feature vector h2, that is, the vector h i (i=1,2) weighted fusion is performed to obtain the weighted feature vectors h'1 and h'2 of each channel;
[0114] The weighted feature vectors h'1 and h'2 of each channel are concatenated to form a comprehensive feature vector h final =[h′1;h′2].
[0115] Output text matching results, including:
[0116] The comprehensive feature vector h final Input into the fully connected classifier softmax, and output the final matching result y as:
[0117] y=softmax(W c ·h final +b c )
[0118] Among them, W c is the weight matrix, b c is the bias term.
[0119] The multi-channel short text matching model constructed by this method can achieve accurate matching of short texts.
[0120] Example
[0121] In order to verify the feasibility of the method proposed in the present invention, the present invention proposes a three-channel short text matching method, such as Figure 3 As shown, the following steps are included:
[0122] S1: Word2Vec is used to embed the words in the matching text at the word level, and the full-text dependency information of the word sequence is extracted through BiLSTM and input into the collaborative attention layer. This step is combined with the semantic similarity matrix built based on the external knowledge base HowNet. By calculating the semantic similarity between words, the ability to capture complex semantic phenomena such as synonyms and antonyms is enhanced, and finally a semantic feature vector that integrates the semantic information is generated.
[0123] S2: Through dependency parsing, the dependency structure graph of the text is constructed and input into the graph matching network GMN to capture the part-of-speech and dependency relationship features in the text, generate a graph similarity vector of the dependency structure, and obtain the syntactic structure feature vector of the text.
[0124] S3: Encode through the Bert model to obtain the contextual semantic feature vector of the text pair.
[0125] S4: The semantic feature vectors, syntactic structure feature vectors and text context semantic feature vectors generated by the above three channels are input into the feature fusion layer based on the self-attention mechanism for feature fusion. By dynamically adjusting the weights of each channel, a comprehensive feature vector is generated and input into the classifier.
[0126] This method effectively improves the accuracy and robustness of short text matching by fusing three levels of features: text semantics of semantic information, context semantics, and syntactic structure similarity.
[0127] Specifically, obtaining a text pair context semantic feature vector includes the following steps:
[0128] Encode through the Bert model to obtain the context representation vector of each word and the context semantic feature vector of the text pair;
[0129] The semantic feature vector, the syntactic structure feature vector and the text context semantic feature vector are fused to obtain a comprehensive feature vector;
[0130] The comprehensive feature vector is input into the classifier, and the three-channel text matching result is output.
[0131] Specifically include:
[0132] Encode through the Bert model to obtain the context representation vector of each word;
[0133] Concatenate the two input texts and add [CLS] and [SEP] tags, that is, the input of the Bert model is in, represents the i-th character of text A, represents the jth character of text B; and inputs it into the Bert model, the output of the Bert model is:
[0134]
[0135] in, represents the i-th hidden layer vector of text A, Represents the jth hidden layer vector of text B.
[0136] After the Bert model output, the [CLS] part is extracted to obtain the text pair context semantic feature vector h3.
[0137] In step S3, the text matching result is output, which specifically includes:
[0138] The semantic feature vector h1 of the obtained text pair fusion semantic information, the syntactic structure feature vector h2 and the text pair context semantic feature vector h3 are respectively input into the feature fusion layer for weighted fusion to obtain the weighted feature vectors h'1, h'2 and h'3 for each channel.
[0139] Concatenate the weighted feature vectors h'1, h'2 and h'3 of each channel to form a comprehensive feature vector h final =[h'1;h'2;h'3], the comprehensive feature vector h final Input into the fully connected classifier softmax and output the final matching result y.
[0140] The three-channel short text matching method provided in this embodiment effectively improves the accuracy and robustness of short text matching by fusing the three levels of features of text semantics of semantic source information, syntactic structure similarity, and contextual semantics.
[0141] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
[0142] In addition, unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as commonly understood by those skilled in the art to which the present invention belongs. All documents mentioned in this specification are incorporated by reference to disclose and describe the methods related to the documents. In the event of any conflict with any incorporated document, the content of this specification shall prevail.
Claims
1. A multi-channel short text matching method integrating external knowledge and syntactic structure, characterized in that: The following steps are involved: Get the text to be matched; According to the obtained text to be matched, based on the semantic relationship of the sememes in the external knowledge base HowNet, the semantic similarity between words is calculated by topological distance, and the sememe similarity matrix between words is determined; by calculating the attention score of the text, the attention weight of each word in the text is obtained; according to the sememe similarity matrix between words and the attention weight of each word in the text, the semantic feature vector of the text pair that integrates the sememe information is generated; By parsing the dependency relationship of the text and constructing a dependency structure graph, the initial features of each node and the features of the edge are determined; based on the initial features of each node and the features of the edge, the node features are updated through the graph matching network GMN, and the nodes, edges and their features of the graph are encoded into vector representations to obtain the syntactic structure feature vector of the text; The semantic feature vector and the syntactic structure feature vector are fused to obtain a comprehensive feature vector; The comprehensive feature vector is input into the classifier and the text matching result is output.
2. The multi-channel short text matching method integrating external knowledge and syntactic structure according to claim 1 is characterized in that: Determining the semantic similarity matrix between words specifically includes: Get the texts A and B to be matched, and encode the words of texts A and B using Word2Vec; Divide text A and B into single vocabulary units respectively, and define text A containing m words as Text B is in, represents the i-th character of text A, Represents the jth character of text B; According to the divided single vocabulary units, use Word2Vec to build a vocabulary, which contains all the words that appear in the text, and each word has a unique ID; Word2Vec learns the word vector of each word through the continuous bag of words model, where the continuous bag of words model predicts the current word through the surrounding words of the context word; for a given text, Word2Vec averages the word vectors in it to get the vector representation of the entire text; The output of the Word2Vec model is recorded as Represents the i-th hidden layer vector of the model output text A, Represents the jth hidden layer vector of the model output text B; Output of the Word2Vec model Out Word2Vec Input into the BiLSTM model and get the output vector h A ,h B ; Obtain the global semantic features of the text through the BiLSTM model; Based on the semantic relationship of the sememes in the external knowledge base HowNet, the size of the constructed sememe similarity matrix is m×n, and the values in the sememe similarity matrix SimMatrix are calculated; When the word pair When the content in is a synonym in HowNet, the corresponding cell position is 1; when it is not a synonym, the similarity is calculated based on the topological distance in HowNet, and the similarity score is set to a value between 0 and 1; when one or both of the two words do not exist in HowNet, or the similarity value is invalid, the similarity score is set to 0.
3. The multi-channel short text matching method integrating external knowledge and syntactic structure according to claim 2 is characterized in that: The generating of the semantic feature vector of the text pair integrating the semantic primitive information specifically includes: In the collaborative attention layer, the affinity matrix C of two texts A and B is calculated through the Parallel paradigm. Among them, W c is the training weight matrix; Calculate the hidden layer feature representation H of text A and B A and H B , the calculation formula is: H A =tanh(W1h A +(W2h B )C) H B =tanh(W2h B +(W1h A )C) Among them, w1 and W2 are the weight matrices for training; Calculate the attention score and incorporate the semantic similarity matrix into the calculation. The improved formula is as follows: in, is the training weight matrix, SimMatrix is the sememe similarity matrix; Apply the obtained attention score to each word in the text to obtain a new text feature vector, i.e. h' A =∑ i Scores A (i) H A (i), h' B =∑ i Scores B (i) H B (i), where Scores A (i) represents the attention weight of the i-th word in text A; The text feature vector h of the collaborative attention layer A ' and h B 'Concatenate the texts to obtain the semantic feature vector h1 that integrates the original meaning information of the text.
4. The multi-channel short text matching method integrating external knowledge and syntactic structure according to claim 3 is characterized in that: Determining the initial features of each node and the features of each edge comprises the following steps: Get the dependency structure graph G constructed by text A A =(N A ,E A ), where: N A ={a1,a2,…,a n } represents the set of word nodes, E A ={(a i ,a j ,r ij )} represents the set of dependency edges, a i , a j For words, r ij For dependency relationship; Determine the initial features of each node as v∈N, represents each node in the graph, Including vocabulary embedding and part-of-speech embedding, the embedded vector obtained by concatenation is used as the final feature of the node: word i For word w i The embedding vector of POS i For word w i The part-of-speech embedding vector of Determine the characteristics of the edge as Represents the dependency type, assigns a unique identifier to each dependency according to the category, and creates an initial embedding matrix in which each row corresponds to the embedding vector of a dependency category, that is, the dependency embedding of edge (i, j) is e ij .
5. The multi-channel short text matching method integrating external knowledge and syntactic structure according to claim 4 is characterized in that: The step of obtaining the syntactic structure feature vector of the text comprises the following steps: The node features are updated through the graph matching network GMN. The nodes, edges and their features of the graph are encoded as vector representations. The graph neural network GNN is used to capture the local and global structural information in the graph. The update is completed by combining the information of neighbor nodes. The formula is as follows: in, represents the feature representation of node v at layer l+1, represents the feature representation of neighbor node u at layer l, N'(v) is the set of neighbor nodes of node v, is the feature representation of edge vu (i.e., the edge connecting node v and node u) at layer l, W (l) is the weight matrix, b (l) represents the bias term of the lth layer; After updating nodes in multiple layers, we get the graph representation G of two texts A and B. A ', G B '; The graph matching network GMN uses an interactive mechanism to calculate the similarity between two graphs through a similarity measurement function. The formula is as follows: in, Indicates the feature similarity between nodes, and the feature similarity is calculated by cosine similarity; is the attention weight of node matching, indicating the matching degree between nodes v1 and v2, and adopts the exponential decay of node distance, that is, λ is an adjustable parameter; The calculated S(G' A ,G B ') as the similarity feature vector of the syntactic structures of the two texts, that is, the syntactic structure feature vector h2.
6. The multi-channel short text matching method integrating external knowledge and syntactic structure according to claim 5 is characterized in that: Also includes: Encode through the Bert model to obtain the context representation vector of each word and the context semantic feature vector of the text pair; The semantic feature vector, the syntactic structure feature vector and the text context semantic feature vector are fused to obtain a comprehensive feature vector; The comprehensive feature vector is input into the classifier, and the three-channel text matching result is output.
7. The multi-channel short text matching method integrating external knowledge and syntactic structure according to claim 6 is characterized in that: The obtaining of the context semantic feature vector of the text pair specifically includes: Encode through the Bert model to obtain the context representation vector of each word; Concatenate the two input texts A and B and add [CLS] and [SEP] tags to get in, represents the i-th character of text A, Represents the jth character of text B, and inputs it into the Bert model accordingly, and the output of the Bert model is: in, represents the i-th hidden layer vector of text A, Represents the jth hidden layer vector of text B; After the Bert model output, the [CLS] part is extracted to obtain the text pair context semantic feature vector h3.
8. The multi-channel short text matching method integrating external knowledge and syntactic structure according to claim 7 is characterized in that: The obtaining of the comprehensive feature vector specifically includes: The obtained semantic feature vector h1 of the text pair fusion original information, the syntactic structure feature vector h2 and the text pair context semantic feature vector h3 are weighted fused respectively, that is, the vector h i (i=1,2,3) perform weighted fusion to obtain the weighted feature vectors h'1, h'2 and h'3 of each channel; The weighted feature vectors h'1, h'2 and h'3 of each channel are concatenated to form a comprehensive feature vector h final =[h'1;h'2;h'3].
9. The multi-channel short text matching method integrating external knowledge and syntactic structure according to claim 8 is characterized in that: The output text matching result specifically includes: The comprehensive feature vector h final Input into the fully connected classifier softmax, and output the final matching result y as: y =softmax(W c ·h final +b c ) Among them, W c is the weight matrix, b c is the bias term.
Citation Information
Cited By
Long text semantic classification method based on deep learning
CN120316255A
Emotion tuple extraction method and system based on syntax and semantic fusion
CN120952009A
Text-oriented violent word abbreviation detection method and device, equipment and storage medium
CN121212140A
Text-oriented violent word abbreviation detection method, device and equipment and storage medium
CN121212140B