Text matching method, device, storage medium and computer equipment

Through the Tree-LSTM model encoding the attention correction of the syntax tree and the BERT model, and combining the theme model to generate the theme distribution vector, the problem of poor text matching effect in specific fields is solved and better text matching effect is achieved.

CN114186558BActive Publication Date: 2025-03-28YGSOFT INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111344972.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-15
Publication Date
2025-03-28
Estimated Expiration
2041-11-15

AI Technical Summary

Technical Problem

The prior art has poor text matching effects in specific fields, traditional methods have word meaning and structural limitations, and the pre-trained architecture cannot achieve the best effect in specific fields tasks.

Method used

The Tree-LSTM model is used to encode the syntax tree of the statement, add dependent syntax information through the similarity matrix, and generate topic distribution vectors in combination with the BERT model and the topic model. The splicing vector is processed through artificial neural network to achieve text matching.

Benefits of technology

By learning useful information and supplementary field information in dependency syntax, better text matching effect is achieved, especially in statement matching in specific fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114186558B_ABST
    Figure CN114186558B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a text matching method, device, storage medium and computer equipment, which relate to the field of natural language processing. The text matching method of the present application includes: word similarity matrix construction: first, two sentences are subjected to dependency syntactic analysis; then, according to the result of dependency syntactic analysis, the embedding representation of each word in the sentence is obtained based on Tree-LSTM; finally, the similarity between two words is calculated based on the embedding representation to construct a word similarity matrix. BERT attention model incorporating external knowledge: This step mainly uses the obtained word similarity matrix to correct the underlying attention calculation. Fusion topic model: First, the topic models of the two sentences are obtained respectively, and then they are spliced ​​with the output of the BERT attention model incorporating external knowledge in the second step. Result output: The result after splicing in the third step is input into the fully connected layer, connected to the Softmax layer, and the result of whether it matches is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing, and in particular to a text matching method, apparatus, storage medium and computer equipment. Background Art

[0002] Text matching is a core problem in natural language understanding, and it is applied to a large number of natural language processing tasks, such as information retrieval, question-answering systems, text clustering, etc. Among them, information retrieval can be attributed to the matching of query and document resources, question-answering systems can be attributed to the matching of questions and candidate questions, and text clustering can be attributed to the matching problem between texts.

[0003] Traditional unsupervised text matching methods mainly include Jaccard, Levenshtein, Simhash, TF-idf, Bm25, VSM and other algorithms, which are mainly based on statistical methods to calculate the literal similarity of two texts through vocabulary overlap. However, it is far from enough to measure the matching degree of texts only by literal similarity, because the texts with the same semantics vary in form. Two texts can be similar in words but with different word orders, resulting in completely opposite semantics; they can be similar in words but with different individual words, resulting in completely different meanings; they can also be completely dissimilar in words but with the same semantics, etc. Therefore, traditional matching algorithms have problems such as word meaning limitations and structural limitations.

[0004] Supervised text matching is performed under the condition of annotated predictions, that is, deep learning modeling is performed based on the annotated data, and the similarity value of the text is directly solved through end-to-end learning of the model. Currently, there are three framework structures: (1) "Siamese" architecture; (2) "interactive aggregation" architecture; (3) "pre-training" architecture.

[0005] "Siamese" architecture: In this framework, two texts are input into the same deep learning encoder (such as CNN or RNN) respectively, so that the two sentences are mapped to the same space, and then the distance between the two sentence vectors is measured to finally obtain the similarity value of the short text.

[0006] Its advantage is that shared parameters make the model smaller and easier to train. Although the sentence vector of the text is obtained through the model and has certain semantic information, its disadvantages cannot be ignored. There is no clear interaction between the two texts during the mapping process, and a lot of information that affects each other will be lost.

[0007] "Interactive aggregation" architecture: This framework is proposed to address the shortcomings of the first framework. The front part of its framework is the same as the first framework, which also inputs two texts into the same deep learning encoder to obtain two sentence vectors. However, instead of directly measuring the distance between the two sentence vectors, the two sentence vectors interact with each other through one or more attention mechanisms, and finally aggregate them into one vector, and obtain the text similarity value through value mapping (all connected to one node). This framework captures more interactive features between the two sentences, so it has achieved significant improvement compared to the first framework.

[0008] "Pre-trained" architecture: This framework structure comes from pre-trained models (for example: ELmo model, GPT model and BERT model, etc.). It mainly adopts a two-stage model. In the first stage, a language model is trained using a large general corpus. In the second stage, the pre-trained language model is used to perform similarity calculation tasks, that is, two texts are put into the pre-trained model to obtain the vector after information interaction, and the similarity value of the text is obtained through value mapping (all connected to a node). This framework usually has a large number of parameters, and because it uses a large general corpus, it has better universality and can obtain more hidden interaction features between two texts.

[0009] The most commonly used text matching methods are still based on pre-training architectures. Because pre-training architectures are pre-trained on a large general corpus before use, they cannot achieve the best results in text matching tasks in specific fields. Summary of the invention

[0010] The embodiments of the present application provide a text matching method, device, storage medium and computer equipment, which can solve the problem that the related technology has poor effect on text matching in specific fields. The technical solution is as follows:

[0011] In a first aspect, an embodiment of the present application provides a text matching method, the method comprising:

[0012] Performing word segmentation processing on the first sentence to obtain a word segmentation set a, and performing word segmentation processing on the second sentence to obtain a word segmentation set b;

[0013] Perform dependency syntactic analysis on the word set a to obtain a syntactic tree T a , and performing dependency syntactic analysis on the word set b to obtain a syntactic tree T b ;

[0014] The word vector a of the word segmentation set a is obtained by using a random initialization method emb , and get the word vector b of the word segmentation set b emb ;

[0015] For the word vector a emb and the syntax tree T a Perform Tree-LSTM model encoding to obtain the encoded word vector a' emb , for the word vector b emb and the syntax tree T b Perform Tree-LSTM model encoding to obtain the encoded word vector b′ emb ;

[0016] The encoded word vector a' emb and the encoded word vector b′ emb Perform cross multiplication to obtain the similarity matrix;

[0017] The word vector a emb and the word vector b emb After inputting into the BERT model with attention calculation corrected by the similarity matrix, the encoded word vector C is obtained;

[0018] Generate a topic distribution vector D1 according to the word segmentation set a, and generate a topic distribution vector D2 according to the word segmentation set b;

[0019] The encoded word vector C, the topic distribution vector D1 and the topic distribution vector D2 are concatenated to obtain a concatenated vector X;

[0020] The splicing vector X is processed using an artificial neural network to obtain a matching result.

[0021] In a second aspect, an embodiment of the present application provides a text matching device, the device comprising:

[0022] A word segmentation processing unit, used to perform word segmentation processing on the first sentence to obtain a word segmentation set a, and perform word segmentation processing on the second sentence to obtain a word segmentation set b;

[0023] A syntactic analysis unit is used to perform dependency syntactic analysis on the word set a to obtain a syntactic tree T a , and performing dependency syntactic analysis on the word set b to obtain a syntactic tree T b ;

[0024] A randomization unit is used to obtain the word vector a of the word segmentation set a by using a random initialization method. emb , and get the word vector b of the word segmentation set b emb ;

[0025] Encoding unit, used to encode the word vector a emb The syntactic tree Ta is encoded by Tree-LSTM to obtain the encoded word vector a' emb , for the word vector b embAnd the syntactic tree Tb is encoded by Tree-LSTM to obtain the encoded word vector b′ emb ;

[0026] A multiplication unit is used to multiply the encoded word vector a' emb and the encoded word vector b′ emb Perform cross multiplication to obtain the similarity matrix;

[0027] A correction unit is used to modify the word vector a emb and the word vector b emb After inputting into the BERT model with attention calculation corrected by the similarity matrix, the encoded word vector C is obtained;

[0028] A topic extraction unit, used to generate a topic distribution vector D1 according to the word segmentation set a, and to generate a topic distribution vector D2 according to the word segmentation set b;

[0029] A concatenation unit, used for concatenating the encoded word vector C, the topic distribution vector D1 and the topic distribution vector D2 to obtain a concatenation vector X;

[0030] The recognition unit is used to process the splicing vector X using an artificial neural network to obtain a matching result.

[0031] In a third aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.

[0032] In a fourth aspect, an embodiment of the present application provides a computer device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.

[0033] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:

[0034] The Tree-LSTM model is used to encode the syntax tree of the sentence, and the dependency grammatical information of the sentence is added to the text matching process through the similarity matrix, so that the model can learn useful information in the dependency syntax and achieve better text matching results. Secondly, in the text matching process, the application generates topic distribution connections through the topic model, which better supplements the domain information of the sentence and has better performance in matching sentences in specific fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0036] Figure 1 It is a flowchart of the text matching method provided in the embodiment of the present application;

[0037] Figure 2 is a schematic diagram of a specific process of S109 provided in an embodiment of the present application;

[0038] Figure 3 It is a structural schematic diagram of a text matching device provided by the present application;

[0039] Figure 4 It is a structural schematic diagram of a computer device provided by this application. DETAILED DESCRIPTION

[0040] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0041] It should be noted that the text matching method provided in the present application is generally executed by a computer device, and correspondingly, the text matching device is generally set in the computer device.

[0042] Various communication client applications can be installed on the computer device of the present application, such as: video recording applications, video playback applications, voice interaction applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0043] The computer device can be hardware or software. When the computer device is hardware, it can be various computer devices with a display screen, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers. When the computer device is software, it can be installed in the computer devices listed above. It can be implemented as multiple software or software modules (for example, to provide distributed services), or it can be implemented as a single software or software module, which is not specifically limited here.

[0044] When the computer device is hardware, a display device and a camera may be installed thereon. The display device may be any device capable of realizing a display function, and the camera is used to collect video streams; for example, the display device may be a cathode ray tube display (CR), a light-emitting diode display (LED), an electronic ink screen, a liquid crystal display (LCD), a plasma display panel (PDP), etc. The user may use the display device on the computer device to view displayed text, pictures, videos and other information.

[0045] The following will be combined with the attached Figure 1 , the text matching method provided in the embodiment of the present application is described in detail. Among them, the text matching device in the embodiment of the present application can be Figure 1 Computer equipment shown.

[0046] See also Figure 1 , which is a flowchart of a text matching method provided in an embodiment of the present application. Figure 1 As shown, the method of the embodiment of the present application may include the following steps:

[0047] S101. Perform word segmentation processing on a first sentence to obtain a word segmentation set a, and perform word segmentation processing on a second sentence to obtain a word segmentation set b.

[0048] Among them, the sentences to be matched are obtained: a first sentence and a second sentence, the first sentence and the second sentence are composed of multiple words, the application uses a word segmentation algorithm to segment the first sentence to obtain a word segmentation set a, and segment the second sentence to obtain a word segmentation set b, the word segmentation set a and the word segmentation set b contain multiple words.

[0049] For example, the hidden Markov model in the Stanford CoreNLP natural language processing toolkit is used to segment the first sentence to obtain a segmentation set a, which contains n words. The segmentation set a is expressed as: a = (a1, a2, ..., a n ), n is an integer greater than 1; the second sentence is segmented using the Stanford CoreNLP natural language processing toolkit to obtain a segmentation set b, the segmentation set b contains m words, m is an integer greater than 1, and the segmentation set b is expressed as: b = (b1, b2, ..., b m). Among them, Stanford CoreNLP natural language processing toolkit is a software that integrates many very practical functions, including word segmentation, part-of-speech tagging and syntactic analysis. This application calls the relevant plug-ins of the natural language processing toolkit to perform the corresponding functions.

[0050] S102: Perform dependency syntactic analysis on the word set a to obtain a syntactic tree T a , and perform dependency syntactic analysis on the word set b to obtain the syntactic tree T b .

[0051] Dependency syntactic parsing is used to identify the interdependencies between words in a sentence. This application can use the deep learning algorithm in the Stanford CoreNLP natural language processing toolkit to perform dependency syntactic parsing on the word set a to obtain a syntactic tree T a , and use the Stanford CoreNLP natural language processing tool to perform dependency syntactic analysis on the word set b to obtain the syntactic tree T b The deep learning algorithm vectorizes atomic features (words, parts of speech, category labels) and then extracts features using a multi-layer neural network.

[0052] S103, using the random initialization method to obtain the word vector a of the word segmentation set a emb , and get the word vector b of the word segmentation set b emb

[0053] Among them, each word in the word segmentation set is randomly initialized to obtain the corresponding vector element, and the generated word vector

[0054] S104, word vector a emb and the syntax tree T a Perform Tree-LSTM model encoding to obtain the encoded word vector a' emb , for word vector b emb and the syntax tree T b Perform Tree-LSTM model encoding to obtain the encoded word vector b′ emb .

[0055] Among them, the (Tree-LSTM, Tree-Long Short-Term Memory) model is used to predict the semantic relevance and sentiment analysis of two sentences, and the word vector a emb and the syntax tree T a After inputting into the Tree-LSTM model, the encoded word vector a' is obtained emb , the word vector b emband the syntax tree T b After inputting into the Tree-LSTM model, the encoded word vector b′ is obtained emb The resulting encoded word vector can be expressed as: a' emb =Tree_LSTM(a emb ,T a ), b′ emb =Tree_LSTM(b emb ,T b ), Tree_LSTM represents the encoding process of the Tree-LSTM model.

[0056] S105, encode the word vector a' emb and the encoded word vector b′ emb Perform cross multiplication to get the similarity matrix.

[0057] Among them, the similarity matrix S n×m Each element in is represented by s ij , 1≤i≤n, 1≤j≤m, that is, the similarity matrix contains n×m elements,

[0058] S106, word vector a emb and word vector b emb After inputting into the BERT model with attention calculation corrected by the similarity matrix, the encoded word vector C is obtained.

[0059] The attention model may be a BERT model, and the similarity matrix obtained in S105 is used to correct the calculation of attention of the BERT (Bidirectional Encoder Representations from Transformers) model. Specifically, the BERT model performs a emb and word vector b emb After processing, the attention score is calculated. The following formula can be used to calculate the attention score:

[0060] MultiHead(Q,K,V)=Concat(head1,…head h )W O ;

[0061]

[0062] scores=QK T +MASK;

[0063]

[0064] After the underlying attention is corrected, the following formula is used for calculation:

[0065] MultiHead(Q,K,V)=Concat(head1,…head h )W O ;

[0066]

[0067] scores=QK T ⊙S+MASK;

[0068]

[0069] Then, the output of the BERT model is the output of the last layer of CLS position, expressed as:

[0070] C=BERT'(a,b); where C represents the connection of encoded words, a and b represent the word segmentation sets in S101, and BERT' represents the BERT model enhanced with synonym knowledge.

[0071] S107 , generating a topic distribution vector D1 according to the word segmentation set a, and generating a topic distribution vector D2 according to the word segmentation set b.

[0072] The topic distribution vector is calculated using the subject model. The topic model is a statistical model that clusters the latent semantic structure of the corpus in an unsupervised learning manner. For example, the topic distribution vector is represented by: D1 = TopicModel(a), D2 = TopicModel(b); where a = (a1, a2, ... a n ) and b=(b1,b2,…b m ).

[0073] In one or more possible embodiments, when the first sentence or the second sentence is a long text sentence, a topic distribution vector is generated using an LDA (Latent Dirichlet allocation) subject model; when the first sentence or the second sentence is a short text sentence, a GSDMM (a collapsed Gibbs Sampling algorithm for the Dirichlet Multinomial Mixture model), a contraction Gibbs sampling algorithm based on a Dirichlet multinomial mixture model) topic model is used to generate a topic distribution vector. A method for identifying long text sentences and short text sentences may be, after word segmentation, counting the number of words contained in the sentence, if the number is greater than a number threshold, the sentence is a long text sentence, if the number is less than or equal to the number threshold, the sentence is a short text sentence, the number threshold may be determined according to actual needs, for example: the number threshold is 20.

[0074] S108. Concatenate the encoded word vector C, the topic distribution vector D1, and the topic distribution vector D2 to obtain a concatenated vector X.

[0075] Splicing means fusing multiple vectors into one vector, for example: splicing vector X = [C; D1; D2].

[0076] S109: Using an artificial neural network to process the splicing vector X to obtain a matching result.

[0077] The artificial neural network includes multiple layers: an input layer, a fully connected layer and an output layer. Each layer of the artificial neural network is used to process the splicing connection to obtain the matching result of the first sentence and the second sentence.

[0078] In one or more possible embodiments, see Figure 2 The matching process shown:

[0079] S1091. Use a fully connected layer to process the concatenated vector to obtain an intermediate vector.

[0080] The concatenated vector is input into the fully connected layer, and the intermediate vector is obtained after processing by the fully connected layer. The activation function of the fully connected layer is tanh. For example: the concatenated vector is X, and the intermediate vector F'=W T ×X+Ρ, T represents transposition, and W and P represent the parameter values ​​of the fully connected layer.

[0081] S1092. Use the Softmax layer to process the intermediate vector to obtain the matching probability and the non-matching probability.

[0082] The activation function of the fully connected layer is tanh. For example, the matching result is divided into matching probability and non-matching probability, and the matching result Y = Softmax(tan(F′)).

[0083] S1093: If the matching probability is greater than the non-matching probability, determine that the first statement and the second statement are matched.

[0084] S1094: If the matching probability is less than the mismatching probability, determine that the first statement and the second statement are mismatched.

[0085] The scheme of the embodiment of the present application uses the Tree-LSTM model to encode the syntax tree of the sentence during text matching, and adds the dependency syntax information of the sentence to the text matching process through the similarity matrix, so that the model can learn useful information in the dependency syntax and achieve better text matching results. Secondly, the present application generates topic distribution connections through the topic model in the text matching process, which better supplements the domain information of the sentence and has better performance in matching sentences in specific fields.

[0086] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0087] See also Figure 3 , which shows a schematic diagram of the structure of a text matching device provided by an exemplary embodiment of the present application, hereinafter referred to as device 3. The device 3 can be implemented as all or part of a computer device through software, hardware or a combination of both. The device 3 includes: a word segmentation processing unit 301, a syntactic analysis unit 302, a randomization unit 303, an encoding unit 304, a multiplication unit 305, a correction unit 306, a topic extraction unit 307, a splicing unit 308 and a recognition unit 309.

[0088] A word segmentation processing unit 301 is used to perform word segmentation processing on the first sentence to obtain a word segmentation set a, and perform word segmentation processing on the second sentence to obtain a word segmentation set b;

[0089] The syntax analysis unit 302 is used to perform dependency syntax analysis on the word set a to obtain a syntax tree T a , and performing dependency syntactic analysis on the word set b to obtain a syntactic tree T b ;

[0090] The randomization unit 303 is used to obtain the word vector a of the word segmentation set a by using a random initialization method. emb , and get the word vector b of the word segmentation set b emb ;

[0091] The encoding unit 304 is used to encode the word vector aemb The syntactic tree Ta is encoded by Tree-LSTM to obtain the encoded word vector a' emb , for the word vector b emb And the syntactic tree Tb is encoded by Tree-LSTM to obtain the encoded word vector b′ emb ;

[0092] The multiplication unit 305 is used to multiply the encoded word vector a' emb and the encoded word vector b′ emb Perform cross multiplication to obtain the similarity matrix;

[0093] The correction unit 306 is used to modify the word vector a emb and the word vector b emb After inputting into the BERT model with attention calculation corrected by the similarity matrix, the encoded word vector C is obtained;

[0094] A topic extraction unit 307, configured to generate a topic distribution vector D1 according to the word segmentation set a, and to generate a topic distribution vector D2 according to the word segmentation set b;

[0095] A concatenation unit 308, configured to concatenate the encoded word vector C, the topic distribution vector D1 and the topic distribution vector D2 to obtain a concatenation vector X;

[0096] The identification unit 309 is used to process the splicing vector X using an artificial neural network to obtain a matching result.

[0097] In one or more possible embodiments, the first sentence and the second sentence are segmented using the Stanford CoreNLP natural language processing toolkit.

[0098] In one or more possible embodiments, the Stanford CoreNLP natural language processing toolkit is used to perform dependency syntactic analysis on the word segmentation set a and the word segmentation set b.

[0099] In one or more possible embodiments, when the first sentence or the second sentence is a long text sentence, the topic distribution vector is generated using the LDA subject model; when the first sentence or the second sentence is a short text sentence, the topic distribution vector is generated using the GSDMM topic model.

[0100] In one or more possible embodiments, the using an artificial neural network to process the splicing vector to obtain a matching result includes:

[0101] Using a fully connected layer to process the concatenated vector to obtain an intermediate vector; wherein the activation function of the fully connected layer is tanh;

[0102] The intermediate vector is processed by using a Softmax layer to obtain a matching probability and a non-matching probability;

[0103] If the matching probability is greater than the non-matching probability, determining that the first statement and the second statement are matched;

[0104] If the matching probability is less than the non-matching probability, it is determined that the first statement and the second statement do not match.

[0105] In one or more possible embodiments, the attention model is a BERT attention model.

[0106] It should be noted that, when the device 3 provided in the above embodiment executes the text matching method, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the text matching device provided in the above embodiment belongs to the same concept as the text matching method embodiment. The implementation process thereof is detailed in the method embodiment and will not be repeated here.

[0107] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0108] The present application also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor as described above. Figure 1 or Figure 2 The method steps of the embodiment shown in the figure can be found in the specific execution process. Figure 1 or Figure 2 The specific description of the illustrated embodiment will not be repeated here.

[0109] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the text matching method described in the above embodiments.

[0110] See also Figure 4 , which is a schematic diagram of the structure of a computer device according to an embodiment of the present application. Figure 4 As shown, the computer device 400 may include: at least one processor 401 , at least one network interface 404 , a user interface 403 , a memory 405 , and at least one communication bus 402 .

[0111] The communication bus 402 is used to realize the connection and communication between these components.

[0112] The user interface 403 may include a display screen (Display) and a camera (Camera), and the optional user interface 403 may also include a standard wired interface and a wireless interface.

[0113] The network interface 404 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0114] Among them, the processor 401 may include one or more processing cores. The processor 401 uses various interfaces and lines to connect various parts in the entire terminal 400, and executes various functions and processes data of the terminal 400 by running or executing instructions, programs, code sets or instruction sets stored in the memory 405, and calling data stored in the memory 405. Optionally, the processor 401 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 401 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 401, and it can be implemented separately through a chip.

[0115] Among them, the memory 405 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 405 includes a non-transitory computer-readable storage medium. The memory 405 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 405 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 405 may optionally be at least one storage device located away from the aforementioned processor 401. As Figure 4 As shown, the memory 405 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an application program.

[0116] exist Figure 4 In the computer device 400 shown in FIG. 1 , the user interface 403 is mainly used to provide an input interface for the user and obtain the data input by the user; and the processor 401 can be used to call the application program stored in the memory 405 and specifically execute the following steps: Figure 1 or Figure 2 The specific process can be referred to Figure 1 or Figure 2 As shown, no further description is given here.

[0117] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0118] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A text matching method, characterized in that: include: Performing word segmentation processing on the first sentence to obtain a word segmentation set a, and performing word segmentation processing on the second sentence to obtain a word segmentation set b; Perform dependency syntactic analysis on the word set a to obtain a syntactic tree T a , and performing dependency syntactic analysis on the word set b to obtain a syntactic tree T b ; The word vector a of the word segmentation set a is obtained by using a random initialization method emb , and get the word vector b of the word segmentation set b emb ; For the word vector a emb and the syntax tree T a Perform Tree-LSTM model encoding to obtain the encoded word vector a' emb , for the word vector b emb and the syntax tree T b Perform Tree-LSTM model encoding to obtain the encoded word vector b e ' mb ; The encoded word vector a' emb and the encoded word vector b e ' mb Perform cross multiplication to obtain the similarity matrix; The word vector a emb and the word vector b emb After inputting into the BERT model with attention calculation corrected by the similarity matrix, the encoded word vector C is obtained; Generate a topic distribution vector D1 according to the word segmentation set a, and generate a topic distribution vector D2 according to the word segmentation set b; The encoded word vector C, the topic distribution vector D1 and the topic distribution vector D2 are concatenated to obtain a concatenated vector X; The concatenated vector is processed by a fully connected layer to obtain an intermediate vector; wherein the activation function of the fully connected layer is tanh; the intermediate vector is processed by a Softmax layer to obtain a matching probability and a non-matching probability; wherein the activation function of the fully connected layer is tanh; if the matching probability is greater than the non-matching probability, it is determined that the first statement and the second statement are matched; if the matching probability is less than the non-matching probability, it is determined that the first statement and the second statement are not matched.

2. The method according to claim 1, characterized in that The first sentence and the second sentence are processed by word segmentation using the Stanford CoreNLP natural language processing toolkit.

3. The method according to claim 1 or 2, characterized in that: The Stanford CoreNLP natural language processing toolkit is used to perform dependency syntactic analysis on the word segmentation set a and the word segmentation set b.

4. The method according to claim 3, characterized in that When the first sentence or the second sentence is a long text sentence, the topic distribution vector is generated using the LDA subject model; when the first sentence or the second sentence is a short text sentence, the topic distribution vector is generated using the GSDMM topic model.

5. A text matching device, characterized in that: include: A word segmentation processing unit, used to perform word segmentation processing on the first sentence to obtain a word segmentation set a, and perform word segmentation processing on the second sentence to obtain a word segmentation set b; A syntactic analysis unit is used to perform dependency syntactic analysis on the word set a to obtain a syntactic tree T a , and performing dependency syntactic analysis on the word set b to obtain a syntactic tree T b ; A randomization unit is used to obtain the word vector a of the word segmentation set a by using a random initialization method. emb , and get the word vector b of the word segmentation set b emb ; Encoding unit, used to encode the word vector a emb The syntactic tree Ta is encoded by Tree-LSTM to obtain the encoded word vector a' emb , for the word vector b emb Perform Tree-LSTM encoding with the syntactic tree Tb to obtain the encoded word vector b e ' mb ; A multiplication unit is used to multiply the encoded word vector a' emb and the encoded word vector b e ' mb Perform cross multiplication to obtain the similarity matrix; A correction unit is used to modify the word vector a emb and the word vector b emb After inputting into the BERT model with attention calculation corrected by the similarity matrix, the encoded word vector C is obtained; A topic extraction unit, used to generate a topic distribution vector D1 according to the word segmentation set a, and to generate a topic distribution vector D2 according to the word segmentation set b; A concatenation unit, used for concatenating the encoded word vector C, the topic distribution vector D1 and the topic distribution vector D2 to obtain a concatenation vector X; An identification unit is used to process the concatenated vector using a fully connected layer to obtain an intermediate vector; wherein the activation function of the fully connected layer is tanh; and to process the intermediate vector using a Softmax layer to obtain a matching probability and a non-matching probability; wherein the activation function of the fully connected layer is tanh; if the matching probability is greater than the non-matching probability, it is determined that the first statement and the second statement are matched; if the matching probability is less than the non-matching probability, it is determined that the first statement and the second statement are not matched.

6. The method according to claim 5, characterized in that When the first sentence or the second sentence is a long text sentence, the topic distribution vector is generated using the LDA subject model; when the first sentence or the second sentence is a short text sentence, the topic distribution vector is generated using the GSDMM topic model.

7. A computer storage medium, characterized in that: The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 4.

8. A computer device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Dependence syntax-based data enhancement method and equipment, and readable storage medium

    CN112069799A

  • Systems, devices, and methods for automatic detection of feelings in text

    US20160321243A1