A text matching method and related device
By combining multi-dimensional feature extraction through concatenation and convolution kernels with the unified encoding of the BERT network, the problem of insufficient semantic feature fusion in existing text matching is solved, thereby improving the accuracy and efficiency of text matching.
Patent Information
- Application Number
- CN202411933342.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2026-06-26
Smart Images

Figure CN122286319A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text processing technology, specifically to a text matching method and related equipment, which may include a text matching device, electronic equipment, computer program products, and computer-readable storage media. Background Technology
[0002] In recent years, with the rapid development of internet technology, natural language processing has become increasingly convenient. Text matching is a fundamental technique in natural language processing. Current text matching often employs a dual-tower model to semantically encode the text on both sides, fuse the encoded semantic features, and then perform semantic matching and classification on the fused semantic features to obtain the text matching result.
[0003] In the process of researching and practicing current technologies, the inventors of this application have found that current semantic feature fusion is just a simple splicing, which often results in poor interaction of semantic information between the two sides. In addition, in the process of semantic encoding, each side often needs to encode, and the encoded semantic features also need to be effectively semantically aligned, thereby increasing the encoding parameters. Therefore, the accuracy and efficiency of text matching are low. Summary of the Invention
[0004] This application provides a text matching method and related equipment. The related equipment may include a text matching device, an electronic device, a computer program product, and a computer-readable storage medium, which can improve the accuracy and efficiency of text matching.
[0005] A text matching method, comprising:
[0006] Obtain at least one pair of texts to be matched, and concatenate the texts to be matched in the pair to obtain the concatenated text;
[0007] Semantic features are extracted from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text.
[0008] Each of the aforementioned text word features is fused with the aforementioned text features to obtain the fused text features;
[0009] Using a convolution kernel of at least one size, multi-dimensional feature extraction is performed on the fused text features to obtain the target convolutional features;
[0010] Based on the target convolutional features and the text features, the matching result of the text pair to be matched is determined.
[0011] Accordingly, embodiments of this application provide a text matching device, including:
[0012] The acquisition unit is used to acquire at least one pair of texts to be matched, and to concatenate the texts to be matched in the pair of texts to be matched to obtain the concatenated text;
[0013] The first extraction unit is used to extract semantic features from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text.
[0014] The fusion unit is used to fuse each of the text word features with the text features respectively to obtain the fused text features;
[0015] The second extraction unit is used to extract multi-dimensional features from the fused text features using a convolution kernel of at least one size to obtain the target convolution features.
[0016] The determining unit is used to determine the matching result of the text pair to be matched based on the target convolutional features and the text features.
[0017] In some embodiments, the second extraction unit may be specifically used to extract multi-dimensional features from the fused text features using a convolutional kernel of at least one size in a convolutional network of a text matching model, to obtain convolutional features corresponding to each convolutional kernel; to perform pooling processing on the convolutional features, and to concatenate the pooled convolutional features to obtain target convolutional features.
[0018] In some embodiments, the second extraction unit may be specifically used to obtain the size of each convolutional kernel in the convolutional network of the text matching model; determine the receptive field of the convolutional kernel in the fused text features based on the size of the convolutional kernel; and perform a convolution operation on the fused text features according to the receptive field to obtain the convolutional features corresponding to each convolutional kernel.
[0019] In some embodiments, the text matching device may further include a training unit, which is specifically configured to acquire at least one text sample pair, concatenate the text samples in the text sample pair to obtain a concatenated text sample; extract features from the concatenated text sample using a preset text matching model to obtain text feature samples of the concatenated text sample and fused text feature samples of the text sample pair; extract multi-dimensional features from the fused text feature samples using a convolutional kernel of at least one size in the preset text matching model, and predict the matching result of the text sample pair based on the extracted convolutional feature samples and the text feature samples to obtain a predicted matching result; determine the matching loss of the preset text matching model based on the predicted matching result, and converge the preset text matching model based on the matching loss to obtain the text matching model.
[0020] In some embodiments, the training unit may be specifically used to obtain the labeled matching parameters of each text sample pair, wherein the labeled matching parameters indicate the actual matching result of the text sample pair; determine the initial matching loss of the text sample pair based on the predicted matching result and the labeled matching parameters; fuse the initial matching loss and invert the fused matching loss to obtain the matching loss of the preset text matching model.
[0021] In some embodiments, the determining unit may be specifically used to concatenate the target convolutional features and the text features to obtain the matching features of the text pair to be matched; and based on the matching features, to perform matching classification on the text pair to be matched to obtain the matching result of the text pair to be matched.
[0022] In some embodiments, the determining unit may be specifically used to identify the current feature dimension in the text features; adjust the target convolutional feature based on the current feature dimension to obtain an adjusted convolutional feature, wherein the adjusted convolutional feature is aligned with the feature dimension of the text features; and concatenate the adjusted convolutional feature with the text features to obtain the matching feature of the text pair to be matched.
[0023] In some embodiments, the determining unit may be specifically used to determine the dimension parameters corresponding to the target convolutional feature based on the current feature dimension, wherein the dimension parameters include feature mapping parameters and dimension bias parameters; perform feature mapping on the target convolutional feature according to the feature mapping parameters, and adjust the mapped convolutional feature based on the dimension bias parameters to obtain candidate convolutional features; and perform feature activation on the candidate convolutional features to obtain adjusted convolutional features.
[0024] In some embodiments, the fusion unit may be specifically used to concatenate each text word feature with the text feature to obtain the concatenated text feature corresponding to each text word; combine the concatenated text features to obtain the concatenated text feature matrix; and use the concatenated text feature matrix as the fused text feature.
[0025] In some embodiments, the fusion unit may be specifically used to identify the position of each text word in the concatenated text to obtain the text position of the text word; sort the concatenated text features based on the text position to obtain a sorting result; and combine the concatenated text features according to the sorting result to obtain a concatenated text feature matrix.
[0026] In some embodiments, the first extraction unit may be specifically used to segment the concatenated text to obtain at least one text word, and obtain the text attribute information of the text word in the concatenated text; based on the text attribute information, perform feature extraction on the concatenated text to obtain the text word features of the text word and the text features of the concatenated text.
[0027] Furthermore, embodiments of this application also provide an electronic device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to execute the text matching method provided in embodiments of this application.
[0028] Furthermore, embodiments of this application also provide a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in any of the text matching methods provided in embodiments of this application.
[0029] Furthermore, embodiments of this application also provide a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps in the text matching method provided in embodiments of this application.
[0030] In this embodiment, at least one text pair to be matched is obtained, and the texts to be matched in the text pair are concatenated to obtain the concatenated text. Then, semantic features are extracted from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text. Each text word feature is fused with the text features to obtain the fused text features. Then, a convolutional kernel of at least one size is used to extract multi-dimensional features from the fused text features to obtain the target convolutional features. Based on the target convolutional features and the fused text features, the matching result of the text pair to be matched is determined. Since this scheme can perform concatenation preprocessing on both sides of the text before unified encoding and semantic space alignment, the encoding parameters are reduced. In addition, the implicit associations between texts are extracted from multiple dimensions through the convolutional kernel, and the convolutional kernels of different sizes can effectively improve the interaction between the coarse and fine granular information of both sides, thereby strengthening the interaction between the information of both sides. Therefore, the accuracy and efficiency of text matching can be improved. Attached Figure Description
[0031] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0032] Figure 1This is a schematic diagram of a scenario for the text matching method provided in an embodiment of this application;
[0033] Figure 2 This is a flowchart illustrating the text matching method provided in an embodiment of this application;
[0034] Figure 3 This is a schematic diagram illustrating the multi-dimensional feature extraction of fused text provided in an embodiment of this application;
[0035] Figure 4 This is a schematic diagram illustrating pooling and concatenating convolutional features according to an embodiment of this application;
[0036] Figure 5 This is a schematic diagram of the overall structure of the text matching model provided in the embodiments of this application;
[0037] Figure 6 This is another flowchart illustrating the text matching method provided in the embodiments of this application;
[0038] Figure 7 This is a schematic diagram of the structure of the text matching device provided in the embodiments of this application;
[0039] Figure 8 This is another structural schematic diagram of the text matching device provided in the embodiments of this application;
[0040] Figure 9 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0041] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0042] This application provides a text matching method and related equipment. The related equipment may include a text matching device, an electronic device, a computer program product, and a computer-readable storage medium. The text matching device may be integrated into an electronic device, which may be a server or a terminal, etc.
[0043] The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN), and big data and artificial intelligence platforms. The terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. The terminal and server can be directly or indirectly connected via wired or wireless communication, which is not limited herein.
[0044] For example, see Figure 1 Taking the integration of a text matching device into an electronic device as an example, the electronic device can acquire at least one text pair to be matched, concatenate the texts to be matched in the text pair to obtain the concatenated text, extract semantic features from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text, fuse each text word feature with the text features to obtain the fused text features, and then use a convolution kernel of at least one size to perform multi-dimensional feature extraction on the fused text features to obtain the target convolution features. Based on the target convolution features and the fused text features, the matching result of the text pair to be matched is determined, thereby improving the accuracy and efficiency of text matching.
[0045] It is understood that, in the specific embodiments of this application, the text pairs or texts to be matched of the objects involved, as well as related data, require permission or consent when the following embodiments of this application are applied to specific products or technologies. Furthermore, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0046] The following sections provide detailed descriptions of each example. It should be noted that the order in which the embodiments are described is not intended to limit the preferred order of the embodiments.
[0047] This embodiment will be described from the perspective of a text matching device, which can be integrated into an electronic device, such as a server or a terminal. The terminal can include tablet computers, laptops, personal computers (PCs), wearable devices, virtual reality devices, or other smart devices capable of text matching.
[0048] A text matching method, comprising:
[0049] At least one text pair to be matched is obtained, and the texts to be matched in the text pair are concatenated to obtain the concatenated text. Semantic features are extracted from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text. Each text word feature is fused with the text features to obtain the fused text features. A convolution kernel of at least one size is used to extract multi-dimensional features from the fused text features to obtain the target convolution features. Based on the target convolution features and the fused text features, the matching result of the text pair to be matched is determined.
[0050] like Figure 2 As shown, the specific process of this text matching method is as follows:
[0051] 101. Obtain at least one text pair to be matched, and concatenate the text to be matched in the text pair to obtain the concatenated text.
[0052] In this context, a text pair to be matched can be understood as a pair of texts containing two texts to be matched. The text to be matched can be understood as the text for which a text matching task is required. A text matching task can also be understood as a text similarity task, a fundamental natural language processing task and a widely used basic technology in business applications. For example, search systems often use text matching between query text and document titles (doc content), and text similarity calculations are also performed between text content (doc) itself.
[0053] There are several ways to obtain at least one text pair to be matched, as follows:
[0054] For example, at least one text pair to be matched can be uploaded directly from the terminal or client; or, at least one query text can be received, and candidate texts corresponding to each query text can be filtered from the candidate text set, and the query text and candidate texts can be used as texts to be matched, thereby obtaining at least one matching text pair; or, at least one original text pair can be filtered from the original text set and used as the text pair to be matched; or, a text matching request can be received, which carries the storage address of at least one text pair to be matched, and at least one text pair to be matched can be obtained based on the storage address, and so on.
[0055] After obtaining at least one text to be matched, the text to be matched in the text pair can be concatenated to obtain the concatenated text. There are several ways to concatenate the text to be matched in the text pair. For example, concatenation characters can be used to concatenate the beginning and end of the two texts to be matched to obtain the concatenated text, as shown in formula (1). Specifically, it can be as follows:
[0056] Text = [text1[sep]text2] (1)
[0057] Where Text is the concatenated text, text1 and text2 are the texts to be matched in the text pair to be matched, and [sep] is the concatenation character.
[0058] Optionally, in some embodiments, the text to be matched in the text pair can be directly concatenated end to end to obtain the concatenated text.
[0059] 102. Extract semantic features from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text.
[0060] In this context, text word features can be understood as the semantic features of each text word in the concatenated text. A text word can be understood as each character or word in the concatenated text. Text features can be understood as the overall semantic features of the concatenated text. There are various ways to extract semantic features from the concatenated text, including the following:
[0061] For example, the concatenated text can be segmented to obtain at least one text word, and the text attribute information of the text word in the concatenated text can be obtained. Based on the text attribute information, feature extraction can be performed on the concatenated text to obtain the text word features of the text word and the text features of the concatenated text.
[0062] Text attribute information can be understood as the attribute information of text words in the concatenated text. There are various types of text attribute information, such as the positional information of text words in the concatenated text, the contextual information of text words in the concatenated text, and so on. Based on text attribute information, there are various ways to extract features from the concatenated text. For example, a feature extraction network of a text matching model can be used to encode features of text words and the concatenated text based on text attribute information, obtaining the text word features of each text word and the text features of the concatenated text.
[0063] The feature extraction network can have various structures, such as BERT (a feature extraction network), LSTM (a context network), or deep networks that can encode text features, etc. Taking BERT as an example, feature encoding is performed on text words and concatenated text to obtain the text word features of each text word and the text features of the concatenated text, as shown in formula (2), specifically as follows:
[0064] D_embedding = BERT([CLS]text1[SEP]text2) (2)
[0065] Where D_embedding=[cls,e1,e2,..,en], ei is each word vector (text word feature), where n is the text length, and cls is the sentence semantic vector (text feature) output by BERT.
[0066] 103. Fuse each text word feature with the text feature separately to obtain the fused text feature.
[0067] For example, each text word feature can be concatenated with the text feature to obtain the concatenated text feature corresponding to each text word. The concatenated text features can then be combined to obtain the concatenated text feature matrix, which can then be used as the fused text feature.
[0068] There are several ways to concatenate each text word feature with the text feature. For example, each text word feature can be directly concatenated with the text feature, or concatenation characters can be obtained and used to connect the text word features with the text feature to obtain the concatenated text feature corresponding to each text word. For instance, if the concatenated text A contains text words A1 and A2, and the text feature of the concatenated text is B, with text word feature A1 being B1 and text word feature A2 being B2, then the concatenated text feature corresponding to text word A1 can be B1+A1, and the concatenated text feature corresponding to text word A2 can be B2+A1, and so on.
[0069] After concatenating each text word feature with the text features individually, the concatenated text features can be combined to obtain the concatenated text features. There are several ways to combine the concatenated text features. For example, the position of each text word can be identified in the concatenated text to obtain the text position of the text word. Based on the text position, the concatenated text features can be sorted to obtain the sorting result. Based on the sorting result, the concatenated text features can be combined to obtain the concatenated text feature matrix.
[0070] After combining the spliced text features, the resulting spliced text feature matrix can be used as the fused text features.
[0071] 104. Using a convolution kernel of at least one size, perform multi-dimensional feature extraction on the fused text features to obtain the target convolutional features.
[0072] The convolutional kernel is a key concept in Convolutional Neural Networks (CNNs). It is a small matrix used to perform convolution operations on input data (such as images, feature / vector matrices). The convolutional kernel extracts features by sliding across the input data and calculating a weighted sum, thus generating a feature map. Using convolutional kernels of at least one size, there are various ways to extract multi-dimensional features from fused text features, as follows:
[0073] For example, a convolutional kernel of at least one size in the convolutional network of a text matching model can be used to extract multi-dimensional features from the fused text features, obtain the convolutional features corresponding to each convolutional kernel, perform pooling on the convolutional features, and then concatenate the pooled convolutional features to obtain the target convolutional features.
[0074] Among them, there are several ways to extract multi-dimensional features from the fused text features using a convolutional network with at least one convolutional kernel of a certain size. For example, the size of each convolutional kernel in the convolutional network of the text matching model can be obtained. Based on the size of the convolutional kernel, the receptive field of the convolutional kernel in the fused text features can be determined. Based on the receptive field, the convolutional operation is performed on the fused text features to obtain the convolutional features corresponding to each convolutional kernel.
[0075] The receptive field describes the spatial extent of the input text / text features corresponding to the output (usually a pixel on the feature map) of a layer in a convolutional network. This extent represents the region of the input text / text features that the output can "see" or influence; that is, the point on the feature map is calculated from the receptive field size of the input text / text features. A larger receptive field can capture coarser-grained information, while a smaller receptive field can capture finer-grained information. Therefore, by controlling the size of the receptive field in the convolutional kernel, the interaction between the coarse and fine-grained features on both sides of the text pair to be matched can be effectively improved. Taking a fused text feature size of 5*6 and a convolutional kernel size of 5*1 (1-gram), 5*2 (2-gram), 5*3 (3-gram), or 5*4 (4-gram) as an example, the process of multi-dimensional feature extraction of the fused text features can be described as follows: Figure 3 As shown, the size of the convolutional features output by a 1-gram convolutional kernel can be 5*1, the size of the convolutional features output by a 2-gram convolutional kernel can be 4*1, the size of the convolutional features output by a 3-gram convolutional kernel can be 3*1, and the size of the convolutional features output by a 4-gram convolutional kernel can be 2*1.
[0076] In a convolutional network employing a text matching model, after extracting multi-dimensional features from the fused text features using convolutional kernels of at least one size, pooling can be performed on the convolutional features corresponding to each extracted kernel to obtain pooled convolutional features. There are various ways to pool convolutional features. For example, max pooling, average pooling, or min pooling can be performed, among others.
[0077] After pooling the convolutional features, the pooled convolutional features can be concatenated to obtain the target convolutional features. The method of concatenating the pooled convolutional features is similar to the method of concatenating text word features with text features, as described above, and will not be repeated here.
[0078] Taking max pooling as an example, the process of pooling convolutional features and concatenating the pooled convolutional features to obtain the target convolutional features can be described as follows: Figure 4 As shown.
[0079] Optionally, in some embodiments, the text matching model can be set by maintenance personnel or trained by the text matching device itself. That is, before the step "using at least one size of convolutional kernel in the convolutional network of the text matching model to perform multi-dimensional feature processing on the fused text features to obtain the convolutional features corresponding to each convolutional kernel", the text matching method includes:
[0080] At least one text sample pair is obtained, and the text samples in the text sample pair are concatenated to obtain a concatenated text sample. A pre-defined text matching model is used to extract features from the concatenated text sample to obtain text feature samples of the concatenated text sample and fused text feature samples of the text sample pair. A convolutional kernel of at least one size in the pre-defined text matching model is used to extract multi-dimensional features from the fused text feature samples. Based on the extracted convolutional feature samples and text feature samples, the matching result of the text sample pair is predicted to obtain the predicted matching result. Based on the predicted matching result, the matching loss of the pre-defined text matching model is determined, and based on the matching loss, the pre-defined text matching model is converged to obtain the text matching model. Specifically, it can be as follows:
[0081] (1) Obtain at least one text sample pair and concatenate the text samples in the text sample pair to obtain the concatenated text sample.
[0082] The method for obtaining at least one text sample pair can be similar to the method for obtaining at least one text pair to be matched, as detailed above, and will not be repeated here.
[0083] After obtaining at least one text sample pair, the text samples in the text sample pair can be concatenated to obtain the concatenated text sample. The method of concatenating the text samples in the text sample pair is similar to the method of concatenating the text to be matched in the text pair to be matched, as described above, and will not be repeated here.
[0084] (2) Use a preset text matching model to extract features from the spliced text samples to obtain text feature samples of the spliced text samples and fused text feature samples of the text sample pairs.
[0085] For example, a pre-defined text matching model can be used to extract features from the concatenated text sample, obtaining text word feature samples of each text word sample in the concatenated text sample and text feature samples of the concatenated text sample. Each text word feature sample is then fused with the text feature samples to obtain the fused text feature samples of the text sample pair.
[0086] The method of using a preset text matching model to extract features from the concatenated text sample is similar to the method of using a text matching model to extract features from the concatenated text, as detailed above, and will not be repeated here.
[0087] After extracting features from the concatenated text samples using a pre-defined text matching model, each extracted text word feature sample can be fused with the text feature sample to obtain the fused text feature sample of the text sample pair. The method of fusing each text word feature sample with the text feature sample is similar to the method of fusing each text word feature with the text feature sample, as described above, and will not be repeated here.
[0088] (3) Using a convolution kernel of at least one size in the preset text matching model, multi-dimensional feature extraction is performed on the fused text feature samples, and based on the extracted convolution feature samples and text feature samples, the matching result of the text sample pairs is predicted to obtain the predicted matching result.
[0089] The predicted matching result can be understood as the matching result of text samples in a text sample pair predicted by the preset text matching model. That is, the predicted matching result can be used to indicate whether the text samples in the text sample pair match. The preset matching result can indicate whether the text samples match through matching parameters. For example, it can be 0 or 1, that is, 0 indicates that the text samples do not match and 1 indicates that the text samples match, or 0 indicates that the text samples match and 1 indicates that the text samples do not match, or it can also indicate whether the text samples match through other parameters, and so on.
[0090] The method of using a convolutional kernel of at least one size in the preset text matching model to perform multi-dimensional feature extraction on the fused text feature samples is similar to the method of using a convolutional kernel of at least one size to perform multi-dimensional feature extraction on the fused text features, as described above, and will not be repeated here.
[0091] After extracting multi-dimensional features from the fused text feature samples using a convolutional kernel of at least one size in a pre-defined text matching model, the matching result of text sample pairs can be predicted based on the extracted convolutional feature samples and text feature samples. There are several ways to predict the matching result of text sample pairs based on the extracted convolutional feature samples and text feature samples. For example, the convolutional feature samples and text feature samples can be concatenated to obtain matching feature samples for the text sample pairs. Based on these matching feature samples, the text sample pairs can be classified for matching to obtain the predicted matching result.
[0092] The method of concatenating convolutional features and text samples is similar to the method of concatenating target convolutional features and text features, as detailed below, and will not be repeated here.
[0093] After concatenating the convolutional feature samples and the text feature samples, the text sample pairs can be matched and classified based on the concatenated matching feature samples, thus obtaining the predicted matching results of the text sample pairs. The method of matching and classifying text sample pairs based on matching feature samples is similar to the method of matching and classifying text pairs to be matched based on matching features, as detailed below, and will not be repeated here.
[0094] (4) Based on the predicted matching results, determine the matching loss of the preset text matching model, and converge the preset text matching model based on the matching loss to obtain the text matching model.
[0095] The matching loss indicates the difference between the predicted matching result of the pre-defined text matching model and the actual matching result of the text sample. There are several ways to determine the matching loss of the pre-defined text matching model based on the predicted matching result, as follows:
[0096] For example, the labeled matching loss parameters of each text sample pair can be obtained. Based on the predicted matching results and the labeled matching parameters, the initial matching loss of the text sample pair can be determined. The initial matching losses can be fused together, and the fused matching loss can be inverted to obtain the matching loss of the preset text matching model.
[0097] The labeled matching parameters indicate the actual matching result of the text sample pair. For example, they can be 0 or 1, where 0 represents no match and 1 represents a match, or other values or parameters indicating different matching results, and so on. Based on the predicted matching result and the labeled matching parameters, there are several ways to determine the initial matching loss of the text sample pair. For example, the logarithm of the predicted matching result can be taken to obtain the matching loss parameter, which can then be fused with the labeled matching parameters to obtain the initial matching loss of the text sample pair.
[0098] After determining the initial matching loss of the text sample pair based on the predicted matching result and the labeled matching loss, the initial matching loss can be fused and the fused matching loss can be inverted to obtain the matching loss of the preset text matching model, as shown in formula (3), specifically as follows:
[0099]
[0100] Where, loss cls For matching loss, n is the number of samples in the text sample pairs (the number of training data), and y is... i To label the matching parameters, a i To predict the matching results.
[0101] After determining the matching loss of the preset text matching model based on the predicted matching results, the preset text matching model can be converged based on the matching loss to obtain the text matching model. There are several ways to converge the preset text matching model based on the matching loss. For example, the model parameters of the preset text matching model can be updated based on the matching loss to obtain the updated text matching model. The updated text matching model is then used as the preset text matching model, and the step of obtaining at least one text sample pair is repeated until the preset text matching model converges, thus obtaining the trained text matching model.
[0102] 105. Based on the target convolutional features and text features, determine the matching result of the text pairs to be matched.
[0103] The matching result indicates whether the texts in a pair of texts to be matched match. There are several ways to determine the matching result of a pair of texts based on target convolutional features and text features, as follows:
[0104] For example, the target convolutional features and text features can be concatenated to obtain the matching features of the text pair to be matched. Based on the matching features, the text to be matched can be classified to obtain the matching result of the text pair to be matched.
[0105] There are several ways to concatenate the target convolutional features and text features. For example, the current feature dimension can be identified in the text features, and the target convolutional features can be adjusted based on the current feature dimension to obtain the adjusted convolutional features. The adjusted convolutional features can then be concatenated with the text features to obtain the matching features of the text pair to be matched.
[0106] The current feature dimension can be understood as indicating the current feature dimension of the target convolutional feature. The adjusted convolutional feature is aligned with the feature dimension of the text feature. There are several ways to adjust the target convolutional feature based on the current feature dimension. For example, based on the current feature dimension, the corresponding dimension parameters of the target convolutional feature can be determined. These dimension parameters can include feature mapping parameters and dimension bias parameters. Based on the feature mapping parameters, the target convolutional feature is feature-mapped, and based on the dimension bias parameters, the mapped convolutional feature is adjusted to obtain candidate convolutional features. Activating the candidate convolutional features yields the adjusted convolutional feature.
[0107] After adjusting the target convolutional features based on the current feature dimensions, the adjusted convolutional features can be concatenated with the text features to obtain the matching features of the text pair to be matched. There are several ways to concatenate the adjusted convolutional features with the text features. For example, the text features can be directly added to the adjusted convolutional features to obtain the matching features of the text pair to be matched, as shown in formula (4). Specifically, it can be as follows:
[0108] Fi = CLS + tanh(w*fusion+b) (4)
[0109] Where Fi is the adjusted convolutional feature, CLS is the text feature, tanh is the activation function, w is the feature mapping parameter, fusion is the target convolutional feature, and b is the dimension bias parameter.
[0110] After concatenating the target convolutional features and text features, the matching features can be used to classify the text pairs to be matched, thereby obtaining the matching results of the text pairs to be matched. There are various ways to classify the text pairs to be matched based on the matching features. For example, a classification network can be used to classify the text pairs to be matched based on the matching features, thereby obtaining the matching results of the text pairs to be matched, as shown in formula (5). Specifically, it can be as follows:
[0111] ai = Classifyer(Fi) (5)
[0112] Where ai represents the matching result of the text pair to be matched, and can take the value 0 or 1, that is, 0 indicates unsuccessful matching and 1 indicates successful matching, or 0 indicates successful matching and 1 indicates unsuccessful matching, or it can take other values or parameters that indicate different matching results, and so on. Fi represents the matching feature, and Classifyer represents the classification network, which can be the classification network in the text matching model, or a pre-trained classification network, and so on.
[0113] Taking BERT as an example, the feature extraction network of the text matching model in this scheme is used to match the text to be matched in the text pair. The overall structure of the text matching model can be as follows: Figure 5 As shown, the entire model can be divided into three parts: two encoders encode the text to be matched on both sides, a convolutional fusion module fuses the features of the two sides to obtain the target convolutional features, and finally a classifier determines the matching result of the text pairs based on the target convolutional features and the text features of the concatenated text.
[0114] This scheme encodes text information from both sides using a deep model based on the BERT network, and uses a mechanism to obtain fused information from both the BERT network and convolutional networks for matching. The modeling approach of constructing the matching module based on convolutional networks enhances the interaction between the two sides' information. The convolutional kernels in the convolutional network can extract implicit relationships between texts from multiple dimensions, and the size of the convolutional kernels can effectively improve the coarse-grained interaction of information between the two sides. Larger convolutional kernels mean a larger receptive field, thus capturing coarser-grained information, while smaller convolutional kernels have the opposite effect. Furthermore, by introducing the BERT network for basic encoding, the scheme combines the advantages of multi-dimensional information extraction by convolutional kernels with the fusion vector CLS (text features) of the BERT network. Finally, at the start of matching, the two test texts are concatenated and preprocessed, and unified encoding and semantic space alignment are performed using a shared BERT network, eliminating the need for separate encoding and alignment using two towers, thereby improving the accuracy and efficiency of text matching.
[0115] As can be seen from the above, in this embodiment, after obtaining at least one text pair to be matched and concatenating the texts to be matched in the text pair to obtain the concatenated text, semantic features are extracted from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text. Each text word feature is then fused with the text features to obtain the fused text features. Then, a convolutional kernel of at least one size is used to extract multi-dimensional features from the fused text features to obtain the target convolutional features. Based on the target convolutional features and the fused text features, the matching result of the text pair to be matched is determined. Since this scheme can perform concatenation preprocessing on both sides of the text, and then perform unified encoding and semantic space alignment, the encoding parameters are reduced. In addition, the implicit associations between texts are extracted from multiple dimensions through the convolutional kernel, and the convolutional kernels of different sizes can effectively improve the interaction between the coarse and fine granular information of both sides, thereby strengthening the interaction between the information of both sides. Therefore, the accuracy and efficiency of text matching can be improved.
[0116] Based on the method described in the above embodiments, the following examples will provide further detailed explanations.
[0117] In this embodiment, the text matching device will be specifically integrated into an electronic device, with the electronic device serving as the server and the feature extraction network in the text matching model being the BERT network, as an example for illustration.
[0118] (I) Training of the pre-set text matching model
[0119] The preset text matching model may include a BERT network and a convolutional network, wherein the convolutional network includes a convolutional kernel of at least one size.
[0120] (1) The server obtains at least one text sample pair and concatenates the text samples in the text sample pair to obtain the concatenated text sample.
[0121] (2) The server uses a preset text matching model to extract features from the spliced text samples to obtain text feature samples of the spliced text samples and fused text feature samples of the text sample pairs.
[0122] For example, the server can use a preset text matching model to extract features from the concatenated text sample, obtain the text word feature sample of each text word sample in the concatenated text sample and the text feature sample of the concatenated text sample, and then fuse each text word feature sample with the text feature sample to obtain the fused text feature sample of the text sample pair.
[0123] (3) The server uses a convolution kernel of at least one size in the preset text matching model to perform multi-dimensional feature extraction on the fused text feature samples, and predicts the matching result of the text sample pairs based on the extracted convolution feature samples and text feature samples, and obtains the predicted matching result.
[0124] For example, the server can use a convolutional kernel of at least one size from a pre-defined text matching model to extract multi-dimensional features from the fused text feature samples. The convolutional feature samples and the text feature samples are then concatenated to obtain matching feature samples for the text sample pairs. Based on these matching feature samples, the text sample pairs are classified to obtain the predicted matching results.
[0125] (4) The server determines the matching loss of the preset text matching model based on the predicted matching results, and converges the preset text matching model based on the matching loss to obtain the text matching model.
[0126] For example, the server can obtain the labeled matching loss parameters for each text sample pair, take the logarithm of the predicted matching result to obtain the matching loss parameters, and fuse the matching loss parameters with the labeled matching parameters to obtain the initial matching loss for the text sample pair. The initial matching losses are then fused together, and the fused matching losses are inverted to obtain the matching loss of the preset text matching model.
[0127] The server can update the model parameters of the preset text matching model based on the matching loss to obtain the updated text matching model. The updated text matching model is then used as the preset text matching model, and the server returns to execute the step of obtaining at least one text sample pair until the preset text matching model converges, thus obtaining the trained text matching model.
[0128] like Figure 6 As shown, a text matching method has the following specific process:
[0129] 201. The server obtains at least one text pair to be matched.
[0130] For example, the server can directly receive at least one text pair to be matched uploaded by the terminal or client, or it can receive at least one query text, filter out candidate texts corresponding to each query text from the candidate text set, and use the query text and candidate texts as texts to be matched, thereby obtaining at least one matching text pair. Alternatively, it can filter out at least one original text pair from the original text set and use the original text pair as text pairs to be matched. Or, it can receive a text matching request, which carries the storage address of at least one text pair to be matched, and obtain at least one text pair to be matched based on the storage address, and so on.
[0131] 202. The server concatenates the text to be matched in the text pair to obtain the concatenated text.
[0132] For example, the server can use concatenation characters to concatenate the beginning and end of two texts to be matched, thus obtaining the concatenated text, as shown in formula (1). Alternatively, the texts to be matched in the text pair can be directly concatenated end to end, thus obtaining the concatenated text.
[0133] 203. The server extracts semantic features from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text.
[0134] For example, the server can segment the concatenated text to obtain at least one text word and acquire the text attribute information of the text word in the concatenated text. The BERT network, which uses a text matching model, encodes the text words and the concatenated text based on the text attribute information, obtaining the text word features of each text word and the text features of the concatenated text.
[0135] 204. The server fuses each text word feature with the text feature to obtain the fused text feature.
[0136] For example, the server can directly concatenate each text word feature with the text feature, or it can obtain the concatenation characters and connect the text word features with the text feature through the concatenation characters to obtain the concatenated text feature corresponding to each text word.
[0137] The server can identify the position of each text word in the concatenated text, obtain the text word position, sort the concatenated text features based on the text position, obtain the sorted result, and combine the concatenated text features according to the sorted result to obtain the concatenated text feature matrix. The combined concatenated text feature matrix is used as the fused text feature.
[0138] 205. The server uses a convolutional kernel of at least one size in the convolutional network of the text matching model to perform multi-dimensional feature extraction on the fused text features, and obtains the convolutional features corresponding to each convolutional kernel.
[0139] For example, the server can obtain the size of each convolutional kernel in the convolutional network of the text matching model, determine the receptive field of the convolutional kernel in the fused text features based on the size of the convolutional kernel, and perform convolution operation on the fused text features according to the receptive field to obtain the convolutional features corresponding to each convolutional kernel.
[0140] 206. The server performs pooling on the convolutional features and concatenates the pooled convolutional features to obtain the target convolutional features.
[0141] For example, the server can perform max pooling on the convolutional features to obtain pooled convolutional features, and then concatenate the pooled convolutional features to obtain the target convolutional features.
[0142] 207. The server can concatenate the target convolutional features and text features to obtain the matching features of the text pair to be matched.
[0143] For example, the server can identify the current feature dimension in the text features, and based on the current feature dimension, determine the dimension parameter corresponding to the target convolutional feature. This dimension parameter may include feature mapping parameters and dimension bias parameters. According to the feature mapping parameters, the target convolutional feature is feature mapped, and based on the dimension bias parameters, the mapped convolutional feature is adjusted to obtain candidate convolutional features. The candidate convolutional features are then activated to obtain the adjusted convolutional features. The text features are added to the adjusted convolutional features to obtain the matching features of the text pair to be matched, as shown in formula (4).
[0144] 208. Based on matching features, the server performs matching classification on the text to be matched and obtains the matching results of the text pairs to be matched.
[0145] For example, the server can use a classification network to classify the text pairs to be matched based on matching features, thereby obtaining the matching results of the text pairs to be matched, as shown in formula (5).
[0146] As can be seen from the above, in this embodiment, the server obtains at least one text pair to be matched, concatenates the texts to be matched in the text pair to obtain the concatenated text, extracts semantic features from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text, fuses each text word feature with the text features to obtain the fused text features, and then uses a convolution kernel of at least one size to extract multi-dimensional features from the fused text features to obtain the target convolution features. Based on the target convolution features and the fused text features, the matching result of the text pair to be matched is determined. Since this scheme can perform concatenation preprocessing on both sides of the text, and then perform unified encoding and semantic space alignment, the encoding parameters are reduced. In addition, the implicit associations between texts are extracted from multiple dimensions through the convolution kernel, and the convolution kernels of different sizes can effectively improve the interaction between the coarse and fine granular information of both sides, thereby strengthening the interaction between the information of both sides. Therefore, the accuracy and efficiency of text matching can be improved.
[0147] To better implement the above methods, this application also provides a text matching device, which can be integrated into an electronic device, such as a server or terminal. The terminal may include a tablet computer, a laptop computer, and / or a personal computer.
[0148] For example, such as Figure 7 As shown, the text matching device may include an acquisition unit 301, a first extraction unit 302, a fusion unit 303, a second extraction unit 304, and a determination unit 305, as follows:
[0149] (1) Obtain unit 301;
[0150] The acquisition unit 301 is used to acquire at least one text pair to be matched and to concatenate the text to be matched in the text pair to obtain the concatenated text.
[0151] For example, the acquisition unit 301 can be used to acquire at least one pair of texts to be matched, and to concatenate the beginning and end of the two texts to be matched using concatenation characters to obtain the concatenated text.
[0152] (2) First extraction unit 302;
[0153] The first extraction unit 302 is used to extract semantic features from the spliced text, and obtain the text word features of each text word in the spliced text and the text features of the spliced text.
[0154] For example, the first extraction unit 302 can be used to segment the concatenated text to obtain at least one text word, and obtain the text attribute information of the text word in the concatenated text. Based on the text attribute information, feature extraction is performed on the concatenated text to obtain the text word features of the text word and the text features of the concatenated text.
[0155] (3) Fusion unit 303;
[0156] The fusion unit 303 is used to fuse each text word feature with the text feature to obtain the fused text feature.
[0157] For example, the fusion unit 303 can be used to concatenate each text word feature with the text feature to obtain the concatenated text feature corresponding to each text word, combine the concatenated text features to obtain the concatenated text feature matrix, and use the concatenated text feature matrix as the fused text feature.
[0158] (4) Second extraction unit 304;
[0159] The second extraction unit 304 is used to extract multi-dimensional features from the fused text features using a convolution kernel of at least one size to obtain the target convolution features.
[0160] For example, the second extraction unit 304 can be used to obtain the size of each convolutional kernel in the convolutional network of the text matching model, determine the receptive field of the convolutional kernel in the fused text features based on the size of the convolutional kernel, perform convolution operation on the fused text features according to the receptive field to obtain the convolutional features corresponding to each convolutional kernel, perform pooling processing on the convolutional features, and concatenate the pooled convolutional features to obtain the target convolutional features.
[0161] (5) Determine unit 305;
[0162] The determination unit 305 is used to determine the matching result of the text pair to be matched based on the target convolutional features and text features.
[0163] For example, the determining unit 305 can be used to identify the current feature dimension in the text features, determine the dimension parameter corresponding to the target convolutional feature based on the current feature dimension, the dimension parameter may include feature mapping parameters and dimension bias parameters, perform feature mapping on the target convolutional feature according to the feature mapping parameters, and adjust the mapped convolutional feature based on the dimension bias parameters to obtain candidate convolutional features, activate the candidate convolutional features to obtain adjusted convolutional features, concatenate the adjusted convolutional features with the text features to obtain the matching features of the text pair to be matched, and perform matching classification on the text pair to be matched based on the matching features to obtain the matching result of the text pair to be matched.
[0164] Optionally, in some embodiments, the text matching device may further include a training unit 306, such as Figure 8 As shown, the specific details are as follows:
[0165] Training unit 306 is used to train a preset text matching model.
[0166] For example, training unit 306 can be used to acquire at least one text sample pair, concatenate the text samples in the text sample pair to obtain a concatenated text sample, use a preset text matching model to extract features from the concatenated text sample to obtain text feature samples of the concatenated text sample and fused text feature samples of the text sample pair, use a convolutional kernel of at least one size in the preset text matching model to extract multi-dimensional features from the fused text feature samples, and predict the matching result of the text sample pair based on the extracted convolutional feature samples and text feature samples to obtain the predicted matching result, determine the matching loss of the preset text matching model based on the predicted matching result, and converge the preset text matching model based on the matching loss to obtain the text matching model.
[0167] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.
[0168] As can be seen from the above, in this embodiment, the acquisition unit 301 acquires at least one text pair to be matched, and concatenates the texts to be matched in the text pair to obtain the concatenated text. Then, the first extraction unit 302 extracts semantic features from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text. The fusion unit 303 fuses each text word feature with the text features to obtain the fused text features. Then, the second extraction unit 304 uses a convolution kernel of at least one size to perform multi-dimensional feature extraction on the fused text features to obtain the target convolution features. The determination unit 305 determines the matching result of the text pair to be matched based on the target convolution features and the fused text features. Since this scheme can perform concatenation preprocessing on both sides of the text, and then perform unified encoding and semantic space alignment, the encoding parameters are reduced. In addition, the implicit associations between texts are extracted from multiple dimensions through the convolution kernel, and the convolution kernels of different sizes can effectively improve the interaction between the coarse and fine granular information on both sides, thereby strengthening the interaction between the information on both sides. Therefore, the accuracy and efficiency of text matching can be improved.
[0169] This application also provides an electronic device, such as... Figure 9 As shown, it illustrates a structural schematic diagram of the electronic device involved in the embodiments of this application, specifically:
[0170] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will understand that... Figure 9 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0171] The processor 401 is the control center of the electronic device, connecting various parts of the device via various interfaces and lines. It executes software programs and / or modules stored in the memory 402, and calls data stored in the memory 402, to perform various functions and process data. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 401.
[0172] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0173] The electronic device also includes a power supply 403 that supplies power to the various components. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 403 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0174] The electronic device may also include an input unit 404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0175] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 runs the applications stored in the memory 402 to realize various functions, as follows:
[0176] At least one text pair to be matched is obtained, and the texts to be matched in the text pair are concatenated to obtain the concatenated text. Semantic features are extracted from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text. Each text word feature is fused with the text features to obtain the fused text features. A convolution kernel of at least one size is used to extract multi-dimensional features from the fused text features to obtain the target convolution features. Based on the target convolution features and the fused text features, the matching result of the text pair to be matched is determined.
[0177] For example, an electronic device can acquire at least one pair of texts to be matched, and concatenate the beginning and end of the two texts using concatenation characters to obtain the concatenated text. The concatenated text is then segmented to obtain at least one text word, and its text attribute information within the concatenated text is acquired. Based on this text attribute information, feature extraction is performed on the concatenated text to obtain the text word features and the text features of the concatenated text. Each text word feature is concatenated with the text features to obtain the concatenated text features corresponding to each text word. These concatenated text features are then combined to obtain the concatenated text feature matrix, which is used as the fused text features. The size of each convolutional kernel in the convolutional network of the text matching model is obtained. Based on the kernel size, the receptive field of the convolutional kernel in the fused text features is determined. Convolution operations are performed on the fused text features according to the receptive field to obtain the convolutional features corresponding to each convolutional kernel. The convolutional features are then pooled, and the pooled convolutional features are concatenated to obtain the target convolutional features. The current feature dimension is identified in the text features. Based on the current feature dimension, the dimension parameter corresponding to the target convolutional feature is determined. This dimension parameter may include feature mapping parameters and dimension bias parameters. According to the feature mapping parameters, the target convolutional feature is feature mapped. Based on the dimension bias parameters, the mapped convolutional feature is adjusted to obtain candidate convolutional features. The candidate convolutional features are activated to obtain adjusted convolutional features. The adjusted convolutional features are concatenated with the text features to obtain the matching features of the text pair to be matched. Based on the matching features, the text to be matched is classified to obtain the matching result of the text pair to be matched.
[0178] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0179] As can be seen from the above, in this embodiment, after obtaining at least one text pair to be matched and concatenating the texts to be matched in the text pair to obtain the concatenated text, semantic features are extracted from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text. Each text word feature is then fused with the text features to obtain the fused text features. Then, a convolutional kernel of at least one size is used to extract multi-dimensional features from the fused text features to obtain the target convolutional features. Based on the target convolutional features and the fused text features, the matching result of the text pair to be matched is determined. Since this scheme can perform concatenation preprocessing on both sides of the text, and then perform unified encoding and semantic space alignment, the encoding parameters are reduced. In addition, the implicit associations between texts are extracted from multiple dimensions through the convolutional kernel, and the convolutional kernels of different sizes can effectively improve the interaction between the coarse and fine granular information of both sides, thereby strengthening the interaction between the information of both sides. Therefore, the accuracy and efficiency of text matching can be improved.
[0180] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0181] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the text matching methods provided in embodiments of this application. For example, the instructions can execute the following steps:
[0182] At least one text pair to be matched is obtained, and the texts to be matched in the text pair are concatenated to obtain the concatenated text. Semantic features are extracted from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text. Each text word feature is fused with the text features to obtain the fused text features. A convolution kernel of at least one size is used to extract multi-dimensional features from the fused text features to obtain the target convolution features. Based on the target convolution features and the fused text features, the matching result of the text pair to be matched is determined.
[0183] For example, at least one pair of texts to be matched is obtained. The two pairs are concatenated using a concatenation character to obtain the concatenated text. The concatenated text is then segmented to obtain at least one text word. The text attribute information of this text word within the concatenated text is obtained. Based on this text attribute information, feature extraction is performed on the concatenated text to obtain the text word features and the text features of the concatenated text. Each text word feature is concatenated with the text features to obtain the concatenated text features corresponding to each text word. These concatenated text features are then combined to obtain the concatenated text feature matrix, which is used as the fused text features. The size of each convolutional kernel in the convolutional network of the text matching model is obtained. Based on the kernel size, the receptive field of the convolutional kernel in the fused text features is determined. Convolution operations are performed on the fused text features according to the receptive field to obtain the convolutional features corresponding to each convolutional kernel. The convolutional features are then pooled, and the pooled convolutional features are concatenated to obtain the target convolutional features. The current feature dimension is identified in the text features. Based on the current feature dimension, the dimension parameter corresponding to the target convolutional feature is determined. This dimension parameter may include feature mapping parameters and dimension bias parameters. According to the feature mapping parameters, the target convolutional feature is feature mapped. Based on the dimension bias parameters, the mapped convolutional feature is adjusted to obtain candidate convolutional features. The candidate convolutional features are activated to obtain adjusted convolutional features. The adjusted convolutional features are concatenated with the text features to obtain the matching features of the text pair to be matched. Based on the matching features, the text to be matched is classified to obtain the matching result of the text pair to be matched.
[0184] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0185] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0186] Since the instructions stored in the computer-readable storage medium can execute the steps of any of the text matching methods provided in the embodiments of this application, the beneficial effects that any of the text matching methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0187] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the methods provided in the various alternative implementations of the text matching or text similarity aspects described above.
[0188] The foregoing has provided a detailed description of a text matching method and related equipment provided in the embodiments of this application. The related equipment may include a text matching device, an electronic device, a computer program product, and a computer-readable storage medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A text matching method, characterized in that, include: Obtain at least one pair of texts to be matched, and concatenate the texts to be matched in the pair to obtain the concatenated text; Semantic features are extracted from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text. Each of the aforementioned text word features is fused with the aforementioned text features to obtain the fused text features; Using a convolution kernel of at least one size, multi-dimensional feature extraction is performed on the fused text features to obtain the target convolutional features; Based on the target convolutional features and the text features, the matching result of the text pair to be matched is determined.
2. The text matching method according to claim 1, characterized in that, The step of using a convolutional kernel of at least one size to extract multi-dimensional features from the fused text features to obtain target convolutional features includes: Using a convolutional network of at least one size in the text matching model, multi-dimensional feature extraction is performed on the fused text features to obtain the convolutional features corresponding to each convolutional kernel; The convolutional features are pooled, and the pooled convolutional features are concatenated to obtain the target convolutional features.
3. The text matching method according to claim 2, characterized in that, The convolutional network employing the text matching model uses at least one convolutional kernel of a certain size to perform multi-dimensional feature extraction on the fused text features, obtaining the convolutional features corresponding to each convolutional kernel, including: Obtain the size of each convolutional kernel in the convolutional network of the text matching model; Based on the size of the convolution kernel, the receptive field of the convolution kernel in the fused text features is determined; Based on the receptive field, a convolution operation is performed on the fused text features to obtain the convolutional features corresponding to each convolution kernel.
4. The text matching method according to claim 2, characterized in that, Before extracting multi-dimensional features from the fused text features using at least one convolutional kernel of a certain size in the convolutional network employing the text matching model, to obtain the convolutional features corresponding to each convolutional kernel, the process further includes: Obtain at least one text sample pair, and concatenate the text samples in the text sample pair to obtain the concatenated text sample; A preset text matching model is used to extract features from the spliced text sample to obtain text feature samples of the spliced text sample and fused text feature samples of the text sample pairs; Using a convolutional kernel of at least one size in the preset text matching model, multi-dimensional feature extraction is performed on the fused text feature samples, and based on the extracted convolutional feature samples and the text feature samples, the matching result of the text sample pair is predicted to obtain the predicted matching result; Based on the predicted matching results, the matching loss of the preset text matching model is determined, and based on the matching loss, the preset text matching model is converged to obtain the text matching model.
5. The text matching method according to claim 4, characterized in that, The predicted matching result includes predicted matching parameters, which indicate the predicted matching result of the text sample. Determining the matching loss of the preset text matching model based on the predicted matching result includes: Obtain the annotation matching parameters for each text sample pair, wherein the annotation matching parameters indicate the actual matching result of the text sample pair; Based on the predicted matching results and the labeled matching parameters, the initial matching loss of the text sample pair is determined; The initial matching loss is fused, and the fused matching loss is inverted to obtain the matching loss of the preset text matching model.
6. The text matching method according to claim 1, characterized in that, The step of determining the matching result of the text pair to be matched based on the target convolutional features and the text features includes: The target convolutional features and the text features are concatenated to obtain the matching features of the text pair to be matched; Based on the matching features, the text pairs to be matched are classified to obtain the matching results of the text pairs to be matched.
7. The text matching method according to claim 6, characterized in that, The step of concatenating the target convolutional features and the text features to obtain the matching features of the text pair to be matched includes: Identify the current feature dimension from the text features; Based on the current feature dimension, the target convolutional feature is adjusted to obtain the adjusted convolutional feature, which is aligned with the feature dimension of the text feature. The adjusted convolutional features are concatenated with the text features to obtain the matching features of the text pair to be matched.
8. The text matching method according to claim 7, characterized in that, The step of adjusting the target convolutional features based on the current feature dimension to obtain adjusted convolutional features includes: Based on the current feature dimension, determine the dimension parameters corresponding to the target convolutional feature, wherein the dimension parameters include feature mapping parameters and dimension bias parameters; Based on the feature mapping parameters, feature mapping is performed on the target convolutional features, and based on the dimension bias parameters, the mapped convolutional features are adjusted to obtain candidate convolutional features; Feature activation is performed on the candidate convolutional features to obtain the adjusted convolutional features.
9. The text matching method according to claim 1, characterized in that, The step of fusing each of the text word features with the text features to obtain the fused text features includes: Each of the text word features is concatenated with the text feature to obtain the concatenated text feature corresponding to each text word; The concatenated text features are combined to obtain a concatenated text feature matrix, which is then used as the fused text features.
10. The text matching method according to claim 9, characterized in that, The step of combining the concatenated text features to obtain a concatenated text feature matrix includes: The position of each text word is identified in the concatenated text to obtain the text position of the text word; Based on the text position, the features of the concatenated text are sorted to obtain a sorting result; Based on the sorting results, the concatenated text features are combined to obtain a concatenated text feature matrix.
11. The text matching method according to claim 1, characterized in that, The step of extracting semantic features from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text includes: The concatenated text is segmented to obtain at least one text word, and the text attribute information of the text word in the concatenated text is obtained. Based on the text attribute information, feature extraction is performed on the concatenated text to obtain the text word features of the text words and the text features of the concatenated text.
12. A text matching device, characterized in that, include: The acquisition unit is used to acquire at least one pair of texts to be matched, and to concatenate the texts to be matched in the pair of texts to be matched to obtain the concatenated text; The first extraction unit is used to extract semantic features from the concatenated text to obtain the text word features of each text word in the concatenated text and the text features of the concatenated text. The fusion unit is used to fuse each of the text word features with the text features respectively to obtain the fused text features; The second extraction unit is used to extract multi-dimensional features from the fused text features using a convolution kernel of at least one size to obtain the target convolution features. The determining unit is used to determine the matching result of the text pair to be matched based on the target convolutional features and the text features.
13. An electronic device, characterized in that, It includes a processor and a memory, the memory storing an application program, and the processor running the application program within the memory to perform the steps of the text matching method according to any one of claims 1 to 11.
14. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the steps of the text matching method according to any one of claims 1 to 11.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the text matching method according to any one of claims 1 to 11.