A text matching method, device, system and storage medium

By segmenting the text dataset and processing it with a pre-trained model, and combining Bi-LSTM and GAT networks, the problems of computational complexity and loss of semantic information in long text matching are solved, achieving efficient text matching results.

CN117131153BActive Publication Date: 2025-11-25GUILIN UNIV OF ELECTRONIC TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310928224.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-26
Publication Date
2025-11-25
Estimated Expiration
2043-07-26

AI Technical Summary

Technical Problem

Existing text matching methods struggle to effectively handle long texts, leading to increased computational complexity, slower training and inference speeds, and potential loss of semantic information due to truncation of long text sequences.

Method used

By segmenting the original text dataset into words, the segmented text sentences are grouped into pairs. The jieba word segmentation library and the pre-trained model SimBERT are used for vectorization. Bi-LSTM, Graph Attention Network (GAT) and Deep Pyramid Convolutional Neural Network (DPCNN) are combined to extract sentence features and make predictions to obtain text matching results.

Benefits of technology

It improves feature extraction performance, enhances data efficiency and model generalization ability, reduces computational load, saves training costs, and better captures global information of sentences, thus solving the long-range dependency problem in long text matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117131153B_ABST
    Figure CN117131153B_ABST
Patent Text Reader

Abstract

The application provides a text matching method, device and system and a storage medium, and belongs to the field of text matching, and the method comprises the following steps: importing an original text dataset, performing word segmentation on the original text dataset to obtain a plurality of segmented text sentences; all the segmented text sentences are divided into groups two by two to obtain a plurality of segmented text sentence groups; each segmented text sentence group is updated to obtain a target text sentence group; and each target text sentence group is predicted to obtain a text matching result. The application improves the feature extraction effect, enhances the data efficiency and the generalization ability of the model, reduces the calculation amount, saves the training cost, can better obtain the global information of a sentence, and solves the long-range dependence problem in long text matching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates primarily to the field of text matching technology, specifically to a text matching method, apparatus, system, and storage medium. Background Technology

[0002] Existing text matching methods often struggle to model long texts effectively. When handling long text matching tasks, models need to consider more semantic information and contextual relationships. This increases the computational complexity of the model and slows down training and inference. Furthermore, because long texts typically have longer sequence lengths, models may be limited by sequence truncation, leading to the loss of some important semantic information. Summary of the Invention

[0003] The technical problem to be solved by the present invention is to provide a text matching method, apparatus, system and storage medium to address the shortcomings of the prior art.

[0004] The technical solution of the present invention to solve the above-mentioned technical problems is as follows: A text matching method, comprising the following steps:

[0005] Import the original text dataset, perform word segmentation on the original text dataset, and obtain multiple segmented text sentences;

[0006] All the segmented text sentences are divided into pairs to obtain multiple groups of segmented text sentences.

[0007] Each segmented text sentence group is updated to obtain the target text sentence group corresponding to each segmented text sentence group.

[0008] Each of the target text sentence groups is predicted to obtain a prediction score corresponding to each target text sentence group, and all the prediction scores are used as the text matching result.

[0009] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: A text matching device, comprising:

[0010] The import module is used to import raw text datasets;

[0011] The word segmentation module is used to segment the original text dataset into multiple segmented text sentences.

[0012] The grouping module is used to divide all the segmented text sentences into pairs to obtain multiple groups of segmented text sentences.

[0013] The update module is used to update each of the segmented text sentence groups respectively to obtain the target text sentence groups corresponding to each of the segmented text sentence groups;

[0014] The text matching result acquisition module is used to predict each of the target text sentence groups, obtain the prediction score corresponding to each of the target text sentence groups, and use all the prediction scores as the text matching result.

[0015] Based on the above-mentioned text matching method, the present invention also provides a text matching system.

[0016] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: a text matching system, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the text matching method described above is implemented.

[0017] Based on the above-described text matching method, the present invention also provides a computer-readable storage medium.

[0018] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the text matching method as described above.

[0019] The beneficial effects of this invention are as follows: by segmenting the original text dataset to obtain segmented text sentences, dividing the segmented text sentences into pairs to obtain segmented text sentence groups, updating the segmented text sentence groups to obtain target text sentence groups, and predicting the target text sentence groups to obtain text matching results, the effect of feature extraction is improved, data efficiency and model generalization ability are enhanced, while reducing the amount of computation, saving training costs, and enabling better acquisition of global information of sentences, thus solving problems such as long-range dependencies in long text matching. Attached Figure Description

[0020] Figure 1 A flowchart illustrating a text matching method provided in an embodiment of the present invention;

[0021] Figure 2 This is a block diagram of a text matching device provided in an embodiment of the present invention. Detailed Implementation

[0022] The principles and features of the present invention are described below with reference to the accompanying drawings. The examples given are only for explaining the present invention and are not intended to limit the scope of the present invention.

[0023] Figure 1 This is a flowchart illustrating a text matching method provided in an embodiment of the present invention.

[0024] like Figure 1 As shown, a text matching method includes the following steps:

[0025] Import the original text dataset, perform word segmentation on the original text dataset, and obtain multiple segmented text sentences;

[0026] All the segmented text sentences are divided into pairs to obtain multiple groups of segmented text sentences.

[0027] Each segmented text sentence group is updated to obtain the target text sentence group corresponding to each segmented text sentence group.

[0028] Each of the target text sentence groups is predicted to obtain a prediction score corresponding to each target text sentence group, and all the prediction scores are used as the text matching result.

[0029] In the above embodiments, segmented text sentences are obtained by word segmentation of the original text dataset. The segmented text sentences are then divided into pairs to form segmented text sentence groups. The target text sentence groups are obtained by updating the segmented text sentence groups. The text matching results are obtained by predicting the target text sentence groups. This improves the feature extraction effect, enhances data efficiency and the generalization ability of the model, reduces the amount of computation, saves training costs, and can better obtain global information of sentences, thus solving problems such as long-range dependencies in long text matching.

[0030] Optionally, as an embodiment of the present invention, the process of performing word segmentation on the original text dataset to obtain multiple segmented text sentences includes:

[0031] The original text dataset was segmented using the jieba word segmentation library to obtain multiple segmented text sentences.

[0032] As should be understood, the original dataset is first preprocessed by using the Python package jieba (i.e., the jieba word segmentation library) to segment the dataset, separating words in sentences with spaces, and creating a dictionary file.

[0033] Specifically, the jieba word segmentation library is a popular Chinese word segmentation library used to segment Chinese text into individual words. It is an open-source project, characterized by ease of use and high performance, and is widely used in Chinese natural language processing tasks. In short, jieba is a powerful Chinese word segmentation library that provides a simple and easy-to-use interface and multiple segmentation modes, playing a vital role in Chinese text processing. Whether in information retrieval, text classification, or sentiment analysis, jieba can provide a reliable solution for Chinese text segmentation needs.

[0034] In the above embodiments, the jieba word segmentation library is used to segment the original text dataset to obtain multiple segmented text sentences, which can build a dictionary file, lay the foundation for subsequent data processing, enhance data efficiency and the generalization ability of the model, and at the same time reduce the amount of computation and save training costs.

[0035] Optionally, as an embodiment of the present invention, the process of updating each of the segmented text sentence groups to obtain the target text sentence group corresponding to each of the segmented text sentence groups includes:

[0036] The pre-trained model SimBERT is used to vectorize each of the segmented text sentence groups to obtain the hidden layer text vectors corresponding to each of the segmented text sentence groups.

[0037] Each hidden layer text vector is updated to obtain an updated text vector corresponding to each segmented text sentence group.

[0038] The hidden layer text vectors and the updated text vectors corresponding to each segmented text sentence group are concatenated to obtain the target text sentence group corresponding to each segmented text sentence group.

[0039] It should be understood that the pre-trained model SimBERT is a BERT-based model designed by Microsoft, based on the UniLM concept, combining retrieval and generation tasks to further fine-tune the model. It has the ability to generate similar questions and retrieve similar sentences.12 It is used in various applications, such as generating synonyms and text similarity retrieval.2

[0040] Specifically, sentences 1 and 2 (i.e., the segmented text sentence groups) are imported into the pre-trained SimBERT model. Each sentence contains three parts: a position vector, a segment vector, and a word vector. Different sentences are distinguished by the labels [CLS] and [SEP]. [CLS] represents a specific symbol for the output, and [SEP] represents a specific symbol for separating non-contiguous token sequences, while preserving the positional information of each sentence. The word vector is the word vector corresponding to each token in the input sentence. The shared weight characteristic of Siamese networks is utilized. The results are fed into the Transformer encoder, where each token is represented by bidirectional encoding. The Transformer encoder includes a self-attention layer, a residual layer, a normalization layer, and a feedforward neural network layer. The encoder takes the superimposed character-level vectors as input and finally obtains the semantically informative hidden layer vector, which is the last layer output of the pre-trained model and contains [CLS] and [SEP]. This yields the hidden layer vector (P, Q) (i.e., the hidden layer text vector).

[0041] In the above embodiments, each segmented text sentence group is updated to obtain the target text sentence group, which better extracts the global information and contextual relationships of the sentences, realizes weight sharing between sentences, and solves the problem that it is difficult to capture the global information and contextual relationships of sentences during the matching process.

[0042] Optionally, as an embodiment of the present invention, the process of updating the hidden layer text vectors to obtain the updated text vectors corresponding to the segmented text sentence groups includes:

[0043] The global word sense is extracted from each of the hidden layer text vectors using the Bi-LSTM model to obtain the global word sense vector corresponding to each of the segmented text sentence groups. The global word sense vector includes multiple global word sense nodes.

[0044] Each of the global word sense nodes corresponding to each of the segmented text sentence groups is updated to obtain multiple updated global word sense nodes corresponding to each of the segmented text sentence groups.

[0045] By performing max pooling on multiple updated global semantic nodes corresponding to each of the segmented text sentence groups using the first formula, the updated text vector corresponding to each of the segmented text sentence groups is obtained. The first formula is:

[0046]

[0047] Where, conv x Let be the updated text vector corresponding to the x-th segmented text sentence group, where max pool is the max pooling function and ReLU is the activation function. Let be the i-th updated global word sense node corresponding to the x-th segmented text sentence group, where U is the weight matrix and b is the bias.

[0048] It should be understood that the output (P, Q) of the upper network (i.e., the hidden layer text vectors) is fed into the Bi-LSTM layer (i.e., the Bi-LSTM model) to obtain global word meaning information, as shown in the following formula:

[0049]

[0050] in

[0051] It should be understood that the Bi-LSTM model, or Bidirectional Long Short-Term Memory Network (BiLSTM for short), is a model based on Recurrent Neural Networks (RNNs). Compared with traditional unidirectional LSTM models, BiLSTM can simultaneously consider historical and future information, thereby improving the model's ability to model sequential data. BiLSTM obtains the final output by inputting the input sequence into two LSTM layers in chronological and reverse chronological order, respectively, and concatenating their outputs along the time axis. In this way, the model can extract features from both past and future contexts and better capture long-term dependencies in sequential data. BiLSTM has wide applications in natural language processing, audio signal processing, handwriting recognition, and other fields, especially in tasks requiring classification, annotation, and generation of sequential data, where it has become a commonly used model.

[0052] Specifically, DPCNN mainly consists of a Redion embedding layer (text region embedding layer), two convolution blocks (each block consists of two conv convolution functions with a fixed kernel size of 3) (the layers constructed by the two blocks can be directly connected through pre-activation), and a Repeat structure, with a Max-polling layer added before the conv and after the pre-activation.

[0053] Specifically, the two vectors with recalculated node information (i.e., the updated global word meaning nodes) are calculated as follows:

[0054]

[0055] Where f represents the ReLU activation function, U represents the weight matrix, and b represents the bias. The max pooling of the two sentences (i.e., the updated text vectors) is calculated as follows:

[0056] conv = max pool(X, X1).

[0057] In the above embodiments, updating the text vectors of each hidden layer to obtain updated text vectors can better capture global information of the text, alleviate the gradient vanishing problem, and learn feature representations more effectively, which is beneficial for extracting contextual relationships.

[0058] Optionally, as an embodiment of the present invention, the process of updating the multiple global semantic nodes corresponding to each of the segmented text sentence groups to obtain multiple updated global semantic nodes corresponding to each of the segmented text sentence groups includes:

[0059] The attention coefficients of each of the global semantic nodes and the remaining global semantic nodes are calculated using the second formula to obtain multiple attention coefficients corresponding to each of the segmented text sentence groups. The second formula is:

[0060]

[0061] Among them, (α) ij ) x Let be the attention coefficients between the i-th and j-th global sense nodes corresponding to the x-th segmented text sentence group, and LeakyReLU be the activation function. Let W be the self-attention matrix and W be the weight matrix. This refers to the i-th global word sense node corresponding to the x-th segmented text sentence group. This refers to the j-th global word sense node corresponding to the x-th segmented text sentence group. This refers to the k-th global word sense node corresponding to the x-th segmented text sentence group. The global sense nodes corresponding to the x-th segmented text sentence group, excluding the i-th global sense node;

[0062] The third formula is used to calculate the node update for multiple attention coefficients and multiple global semantic nodes corresponding to each of the segmented text sentence groups, respectively, to obtain multiple updated global semantic nodes corresponding to each of the segmented text sentence groups.

[0063]

[0064] in, For the i-th updated global word sense node corresponding to the x-th segmented text sentence group, (α) ij ) x Let be the attention coefficient between the i-th global sense node and the j-th global sense node corresponding to the x-th segmented text sentence group. This refers to the j-th global word sense node corresponding to the x-th segmented text sentence group. Let σ be the j-th global semantic node corresponding to the x-th segmented text sentence group, and σ be the activation function. Let W be the global sense nodes (excluding the i-th global sense node) corresponding to the text sentence group after the x-th word segmentation, and let W be the weight matrix.

[0065] It should be understood that the vector of the output of the upper layer network (i.e., multiple global semantic nodes) are used as the layer input of GAT, where n represents the number of nodes and F represents the number of features of each node.

[0066] Specifically, the attention scores of the sentence word vector center node and its neighbor nodes are calculated as follows:

[0067]

[0068] Where ij represent two adjacent neighbor nodes, and w is a weight matrix used to train the nodes. This represents two word vectors in a sentence. Then, self-attention—a shared attention mechanism 'a'—is performed on the node, as follows:

[0069]

[0070] We introduce softmax to regularize all neighboring nodes j of i, as shown in the following equation:

[0071]

[0072] Attention mechanism 'a' is a single-layer feedforward neural network, and the following equation is then introduced:

[0073]

[0074] Where LeaKyReLU is a non-linear activation function, as shown in the following equation:

[0075]

[0076] It should be understood that the output of the newly calculated node information (i.e., the updated global semantic nodes) is obtained as follows:

[0077]

[0078] In the above embodiments, node updates are performed on multiple global word sense nodes to obtain updated global word sense nodes, which can better capture global information of the text, alleviate the gradient vanishing problem, and learn feature representations more effectively, which is beneficial for extracting contextual relationships.

[0079] Optionally, as an embodiment of the present invention, the process of concatenating each of the hidden layer text vectors and the updated text vectors corresponding to each of the segmented text sentence groups to obtain the target text sentence groups corresponding to each of the segmented text sentence groups includes:

[0080] By concatenating the hidden layer text vectors and the updated text vectors corresponding to each segmented text sentence group using the fourth formula, the target text sentence group corresponding to each segmented text sentence group is obtained. The fourth formula is:

[0081]

[0082] in, For the target text sentence group corresponding to the x-th segmented text sentence group, conv x Let B be the updated text vector corresponding to the x-th segmented text sentence group. x This is the hidden layer text vector corresponding to the text sentence group after the xth word segmentation.

[0083] Understandably, the two sentences are pre-trained through an encoding layer and then fed into a GAT layer for overall sentence modeling. Sentence features are then extracted using DPCNN. Finally, the outputs of the two sentences (i.e., the updated text vector and the hidden layer text vector) are connected to a fully connected layer for final classification prediction (i.e., the target text sentence group).

[0084] Specifically, the output of the pre-trained encoding layer (i.e., the hidden layer text vector) and the output of DPCNN (i.e., the updated text vector) are residually concatenated to obtain the output (i.e., the target text sentence group), as shown in the following formula:

[0085] y out =concat(conv, (P, Q)),

[0086] Concat is a commonly used vector concatenation operation in deep learning. Concat refers to the operation of connecting two or more tensors along a certain dimension. This operation concatenates the input tensors along the specified dimension to form a new tensor. This operation can be performed using the NumPy utility package in PyTorch. This step can better reflect the differences between two texts and reduce the complexity of the network.

[0087] In the above embodiments, by concatenating the text vectors of each hidden layer and the updated text vectors using the fourth method, the target text sentence group can be obtained, which can better reflect the differences between the two texts and reduce the complexity of the network.

[0088] Optionally, as an embodiment of the present invention, the process of predicting each of the target text sentence groups to obtain the prediction score corresponding to each of the target text sentence groups includes:

[0089] The fifth formula is used to predict each target text sentence group, thereby obtaining a prediction score corresponding to each target text sentence group.

[0090]

[0091] in, Let be the predicted score for the text sentence group after the x-th word segmentation, and softmax be the activation function. Let U1 be the target text sentence group corresponding to the xth segmented text sentence group, where U1 is the weight matrix and b is the bias.

[0092] Specifically, softmax classification prediction is performed as follows:

[0093]

[0094] U1 represents the weight matrix, and b represents the bias.

[0095] In the above embodiments, the prediction scores are obtained by predicting each group of target text sentences using the fifth method, which improves the effect of feature extraction, enhances data efficiency and the generalization ability of the model, reduces the amount of computation, saves training costs, and can better obtain global information of sentences, thus solving problems such as long-range dependencies in long text matching.

[0096] Optionally, as another embodiment of the present invention, the original dataset is first processed to construct vector sentences suitable for input into the network. Next, the two matched sentences are input into the pre-trained Siamese BERT network (SimBERT) to obtain vector representations. Then, a graph representing sentence relationships is constructed and fed into the graph attention network GAT. Subsequently, the obtained sentence features are extracted using a DPCNN network, and finally, the results are processed by a fully connected layer for classification.

[0097] This invention primarily introduces the concept of a graph into text matching tasks, using each word vector in a sentence as a node in the graph and the relationships between vectors as edges. Utilizing a graph attention network allows for better acquisition of global information about the sentence, addressing long-range dependencies in long text matching. Simultaneously, it leverages the weight-sharing mechanism of the SimBERT pre-trained model, which reduces the number of model parameters, improves feature extraction, enhances data efficiency, and strengthens the model's generalization ability. DPCNN also reduces computational cost, significantly saving on training expenses.

[0098] Optionally, as another embodiment of the present invention, this invention utilizes graphs, a data structure capable of better modeling global information, to extract global information and contextual relationships of sentences more effectively. Simultaneously, using the SimBERT Siamese pre-trained model and the DPCNN network can better save training costs, reduce computational load, and improve the efficiency of the model matching process. This method enhances the interactivity between sentences, enabling the model to better obtain the global contextual relationships of the text.

[0099] Alternatively, as another embodiment of the present invention, the technical problem to be solved by the present invention is as follows:

[0100] Current text matching models are not good at capturing the connections between sentences in long texts or obtaining global topic information, which greatly weakens the semantic matching effect.

[0101] At the same time, the current models for long text matching have a large amount of computation and parameters, which is not conducive to saving matching costs.

[0102] Alternatively, as another embodiment of the present invention, the technical method for solving the problem is as follows:

[0103] To address the challenge of capturing global information and contextual relationships within sentences during matching, this paper proposes a text representation method combining a Siamese pre-trained model and a graph attention network. Leveraging graphs, a data structure capable of better modeling global information, this method improves the extraction of global information and contextual relationships within sentences. A Siamese pre-trained model, SimBERT, is constructed to achieve weight sharing between sentences, thereby building a matching model that facilitates the extraction of contextual relationships.

[0104] Finally, in the process of extracting sentence features, DPCNN (Deep Pyramid Convolutional Model) is used, employing residual connections to pass information across layers, allowing the model to better capture global information of the text. Residual connections can alleviate the vanishing gradient problem and help the model learn feature representations more effectively.

[0105] Figure 2 This is a block diagram of a text matching device provided in an embodiment of the present invention.

[0106] Alternatively, as another embodiment of the present invention, such as Figure 2 As shown, a text matching device includes:

[0107] The import module is used to import raw text datasets;

[0108] The word segmentation module is used to segment the original text dataset into multiple segmented text sentences.

[0109] The grouping module is used to divide all the segmented text sentences into pairs to obtain multiple groups of segmented text sentences.

[0110] The update module is used to update each of the segmented text sentence groups respectively to obtain the target text sentence groups corresponding to each of the segmented text sentence groups;

[0111] The text matching result acquisition module is used to predict each of the target text sentence groups, obtain the prediction score corresponding to each of the target text sentence groups, and use all the prediction scores as the text matching result.

[0112] Optionally, another embodiment of the present invention provides a text matching system, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the text matching method as described above. This system can be a computer or similar system.

[0113] Optionally, another embodiment of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the text matching method as described above.

[0114] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0115] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described apparatus and unit can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0116] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.

[0117] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.

[0118] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0119] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0120] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A text matching method, characterized in that, Includes the following steps: Import the original text dataset, perform word segmentation on the original text dataset, and obtain multiple segmented text sentences; All the segmented text sentences are divided into pairs to obtain multiple groups of segmented text sentences. Each segmented text sentence group is updated to obtain the target text sentence group corresponding to each segmented text sentence group. Each target text sentence group is predicted to obtain a prediction score corresponding to each target text sentence group, and all prediction scores are used as the text matching result. The process of updating each of the segmented text sentence groups to obtain the target text sentence group corresponding to each of the segmented text sentence groups includes: The pre-trained model SimBERT is used to vectorize each of the segmented text sentence groups to obtain the hidden layer text vectors corresponding to each of the segmented text sentence groups. Each hidden layer text vector is updated to obtain an updated text vector corresponding to each segmented text sentence group. Each hidden layer text vector and the updated text vector corresponding to each segmented text sentence group are concatenated to obtain the target text sentence group corresponding to each segmented text sentence group. The process of updating the hidden layer text vectors to obtain the updated text vectors corresponding to each segmented text sentence group includes: The global word sense is extracted from each of the hidden layer text vectors using the Bi-LSTM model to obtain the global word sense vector corresponding to each of the segmented text sentence groups. The global word sense vector includes multiple global word sense nodes. Each of the global word sense nodes corresponding to each of the segmented text sentence groups is updated to obtain multiple updated global word sense nodes corresponding to each of the segmented text sentence groups. By performing max pooling on the multiple updated global semantic nodes corresponding to each of the segmented text sentence groups using the first formula, the updated text vector corresponding to each of the segmented text sentence groups is obtained. The first formula is: Where, conv x Let be the updated text vector corresponding to the x-th segmented text sentence group, where max pool is the max pooling function and ReLU is the activation function. Let be the i-th updated global word sense node corresponding to the x-th segmented text sentence group, where U is the weight matrix and b is the bias; The process of updating the global semantic nodes corresponding to each of the segmented text sentence groups to obtain the updated global semantic nodes corresponding to each of the segmented text sentence groups includes: The attention coefficients of each of the global semantic nodes and the remaining global semantic nodes are calculated using the second formula to obtain multiple attention coefficients corresponding to each of the segmented text sentence groups. The second formula is: Among them, (α) ij ) x Let be the attention coefficients between the i-th and j-th global sense nodes corresponding to the x-th segmented text sentence group, and LeakyReLU be the activation function. Let W be the self-attention matrix and W be the weight matrix. This refers to the i-th global word sense node corresponding to the x-th segmented text sentence group. This refers to the j-th global word sense node corresponding to the x-th segmented text sentence group. This refers to the k-th global word sense node corresponding to the x-th segmented text sentence group. The global sense nodes corresponding to the x-th segmented text sentence group, excluding the i-th global sense node; The third formula is used to calculate the node update for multiple attention coefficients and multiple global semantic nodes corresponding to each of the segmented text sentence groups, respectively, to obtain multiple updated global semantic nodes corresponding to each of the segmented text sentence groups. in, For the i-th updated global word sense node corresponding to the x-th segmented text sentence group, (α) ij ) x Let be the attention coefficient between the i-th global sense node and the j-th global sense node corresponding to the x-th segmented text sentence group. This refers to the j-th global word sense node corresponding to the x-th segmented text sentence group. Let σ be the j-th global semantic node corresponding to the x-th segmented text sentence group, and σ be the activation function. Let W be the global sense nodes (excluding the i-th global sense node) corresponding to the text sentence group after the x-th word segmentation, and let W be the weight matrix.

2. The text matching method according to claim 1, characterized in that, The process of segmenting the original text dataset to obtain multiple segmented text sentences includes: The original text dataset was segmented using the jieba word segmentation library to obtain multiple segmented text sentences.

3. The text matching method according to claim 1, characterized in that, The process of concatenating the hidden layer text vectors and the updated text vectors corresponding to each segmented text sentence group to obtain the target text sentence group corresponding to each segmented text sentence group includes: By concatenating the hidden layer text vectors and the updated text vectors corresponding to each segmented text sentence group using the fourth formula, the target text sentence group corresponding to each segmented text sentence group is obtained. The fourth formula is: in, For the target text sentence group corresponding to the x-th segmented text sentence group, conv x Let B be the updated text vector corresponding to the x-th segmented text sentence group. x This is the hidden layer text vector corresponding to the text sentence group after the xth word segmentation.

4. The text matching method according to claim 1, characterized in that, The process of predicting each of the target text sentence groups to obtain the prediction score corresponding to each target text sentence group includes: The fifth formula is used to predict each target text sentence group, thereby obtaining a prediction score corresponding to each target text sentence group. in, Let be the predicted score for the text sentence group after the x-th word segmentation, and softmax be the activation function. Let U1 be the target text sentence group corresponding to the xth segmented text sentence group, where U1 is the weight matrix and b is the bias.

5. A text matching device, characterized in that, include: The import module is used to import raw text datasets; The word segmentation module is used to segment the original text dataset into multiple segmented text sentences. The grouping module is used to divide all the segmented text sentences into pairs to obtain multiple groups of segmented text sentences. The update module is used to update each of the segmented text sentence groups respectively to obtain the target text sentence groups corresponding to each of the segmented text sentence groups; The text matching result acquisition module is used to predict each of the target text sentence groups respectively, obtain the prediction score corresponding to each of the target text sentence groups, and use all the prediction scores as the text matching result; The update module is specifically used for: The pre-trained model SimBERT is used to vectorize each of the segmented text sentence groups to obtain the hidden layer text vectors corresponding to each of the segmented text sentence groups. Each hidden layer text vector is updated to obtain an updated text vector corresponding to each segmented text sentence group. Each hidden layer text vector and the updated text vector corresponding to each segmented text sentence group are concatenated to obtain the target text sentence group corresponding to each segmented text sentence group. The update module includes the following process: updating the hidden layer text vectors to obtain the updated text vectors corresponding to each segmented text sentence group. The global word sense is extracted from each of the hidden layer text vectors using the Bi-LSTM model to obtain the global word sense vector corresponding to each of the segmented text sentence groups. The global word sense vector includes multiple global word sense nodes. Each of the global word sense nodes corresponding to each of the segmented text sentence groups is updated to obtain multiple updated global word sense nodes corresponding to each of the segmented text sentence groups. By performing max pooling on the multiple updated global semantic nodes corresponding to each of the segmented text sentence groups using the first formula, the updated text vector corresponding to each of the segmented text sentence groups is obtained. The first formula is: Where, conv x Let be the updated text vector corresponding to the x-th segmented text sentence group, where max pool is the max pooling function and ReLU is the activation function. Let be the i-th updated global word sense node corresponding to the x-th segmented text sentence group, where U is the weight matrix and b is the bias; The update module includes the following process: updating the global semantic nodes corresponding to each segmented text sentence group to obtain the updated global semantic nodes corresponding to each segmented text sentence group. The attention coefficients of each of the global semantic nodes and the remaining global semantic nodes are calculated using the second formula to obtain multiple attention coefficients corresponding to each of the segmented text sentence groups. The second formula is: Among them, (α) ij ) x Let be the attention coefficients between the i-th and j-th global sense nodes corresponding to the x-th segmented text sentence group, and LeakyReLU be the activation function. Let W be the self-attention matrix and W be the weight matrix. This refers to the i-th global word sense node corresponding to the x-th segmented text sentence group. This refers to the j-th global word sense node corresponding to the x-th segmented text sentence group. This refers to the k-th global word sense node corresponding to the x-th segmented text sentence group. The global sense nodes corresponding to the x-th segmented text sentence group, excluding the i-th global sense node; The third formula is used to calculate the node update for multiple attention coefficients and multiple global semantic nodes corresponding to each of the segmented text sentence groups, respectively, to obtain multiple updated global semantic nodes corresponding to each of the segmented text sentence groups. in, For the i-th updated global word sense node corresponding to the x-th segmented text sentence group, (α) ij ) x Let be the attention coefficient between the i-th global sense node and the j-th global sense node corresponding to the x-th segmented text sentence group. This refers to the j-th global word sense node corresponding to the x-th segmented text sentence group. Let σ be the j-th global semantic node corresponding to the x-th segmented text sentence group, and σ be the activation function. Let W be the global sense nodes (excluding the i-th global sense node) corresponding to the text sentence group after the x-th word segmentation, and let W be the weight matrix.

6. A text matching system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the text matching method as described in any one of claims 1 to 4.

7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the text matching method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Chinese semantic matching method based on pinyin and BERT embedding

    CN111414481A

  • Chinese text matching method and system

    CN111914067A