A text matching method, device, terminal equipment and storage medium

By introducing a difference calculation layer in the bilateral multi-view matching model, calculating text matching vectors and difference vectors, the problem of inaccurate text matching in the prior art is solved, and more accurate text matching results are achieved.

CN115062125BActive Publication Date: 2025-04-18UBTECH ROBOTICS CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210588177.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-27
Publication Date
2025-04-18
Estimated Expiration
2042-05-27

AI Technical Summary

Technical Problem

In the existing text matching technology, it is difficult to accurately determine whether two texts match through keyword matching, because the meaning of the same keyword in the two texts may be different.

Method used

The bilateral multi-view matching model is adopted to calculate the matching vectors of two texts through the text matching layer, and the difference calculation layer calculates the difference vectors of the matching vectors, and outputs the matching results based on these vectors.

Benefits of technology

The accuracy of text matching is improved, and the text similarity is characterized by difference vectors, making the matching result more reliable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115062125B_ABST
    Figure CN115062125B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of text processing technology, and provides a text matching method, apparatus, terminal device and storage medium, the method comprising: calculating a first matching vector of an input first text relative to an input second text, and a second matching vector of the second text relative to the first text through a text matching layer in a bilateral multi-view matching model, calculating a difference vector between the first matching vector and the second matching vector through a difference calculation layer in a bilateral multi-view matching model, and obtaining a matching result of the first text and the second text based on the first matching vector, the second matching vector and the difference vector through a result output layer in a bilateral multi-view matching model. The present application adds a difference vector when determining the matching result, and the difference vector can represent the similarity between the first text and the second text, so that the obtained matching result can be more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of text processing technology, and in particular, relates to a text matching method, apparatus, terminal device and storage medium. Background Art

[0002] With the development of information technology, text matching technology is being used more and more widely. For example, text matching technology has long been widely used in paper retrieval.

[0003] At present, when performing text matching, it is necessary to find the keywords of each text and then determine whether the keywords included in the two texts are the same. If the keywords included in the two texts are the same, the two texts match; if the keywords included in the two texts are different, the two texts do not match. However, the meaning of the same keyword in the two texts may be different. Even if the keywords of the two files are the same, the meanings expressed by the two texts are different. Therefore, using keywords to determine whether two texts match is inaccurate. Summary of the invention

[0004] The embodiments of the present application provide a text matching method, apparatus, terminal device and storage medium, which can solve the current problem of inaccurate text matching.

[0005] In a first aspect, an embodiment of the present application provides a text matching method, which is applied to a bilateral multi-view matching model including a text matching layer, a difference calculation layer, and a result output layer, and the method includes:

[0006] Calculate, by the text matching layer, a first matching vector of the input first text relative to the input second text, and a second matching vector of the second text relative to the first text;

[0007] Calculate a difference vector between the first matching vector and the second matching vector by the difference calculation layer;

[0008] A matching result between the first text and the second text is obtained through a result output layer based on the first matching vector, the second matching vector and the difference vector.

[0009] In a second aspect, an embodiment of the present application provides a text matching device, including: a bilateral multi-view matching model, wherein the bilateral multi-view matching model includes a text matching layer, a difference calculation layer, and a result output layer;

[0010] The text matching layer is used to calculate a first matching vector of an input first text relative to an input second text, and a second matching vector of the second text relative to the first text;

[0011] The difference calculation layer is used to calculate a difference vector between the first matching vector and the second matching vector;

[0012] The result output layer is used to obtain the matching result of the first text and the second text based on the first matching vector, the second matching vector and the difference vector.

[0013] In a third aspect, an embodiment of the present application provides a terminal device, comprising: 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 in any one of the first aspects above is implemented.

[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the text matching method described in any one of the first aspects above is implemented.

[0015] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the text matching method described in any one of the above-mentioned first aspects.

[0016] Compared with the prior art, the first aspect of the present application has the following beneficial effects: the present application calculates the first matching vector of the input first text relative to the input second text and the second matching vector of the second text relative to the first text through the text matching layer in the bilateral multi-view matching model, calculates the difference vector between the first matching vector and the second matching vector through the difference calculation layer in the bilateral multi-view matching model, and obtains the matching result of the first text and the second text based on the first matching vector, the second matching vector and the difference vector through the result output layer in the bilateral multi-view matching model. Compared with the existing bilateral multi-view matching model, the present application sets a difference calculation layer in the bilateral multi-view matching model, calculates the difference vector between the first matching vector and the second matching vector through the difference calculation layer, and finally determines the matching result based on the difference vector, the first matching vector and the second matching vector. Compared with the use of the first matching vector and the second matching vector in the bilateral multi-view matching model in the prior art to determine the matching result, the present application adds a difference vector when determining the matching result, and the difference vector can characterize the similarity between the first text and the second text, so that the obtained matching result is more accurate.

[0017] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0019] Figure 1 It is a structural diagram of a bilateral multi-view matching model in the prior art provided by an embodiment of the present application;

[0020] Figure 2 This is a schematic diagram of an application scenario of a text matching method provided in an embodiment of the present application;

[0021] Figure 3 is a flowchart of a text matching method provided in an embodiment of the present application;

[0022] Figure 4 is a flow chart of a vector matching method provided in an embodiment of the present application;

[0023] Figure 5 It is a flowchart of a method for determining a word vector provided in an embodiment of the present application;

[0024] Figure 6 is a flowchart of a method for determining a difference vector provided in an embodiment of the present application;

[0025] Figure 7 is a flowchart of a method for determining a matching result provided in an embodiment of the present application;

[0026] Figure 8 is a structural diagram of a bilateral multi-view matching model in the present application provided in an embodiment of the present application;

[0027] Fig. 9 It is a structural diagram of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0028] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0029] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0030] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.

[0031] Text matching is a broad concept. As long as the relationship between two texts is studied, it can be regarded as a text matching problem. Text matching usually plays a core supporting role in some application systems in the form of text similarity calculation or text relevance calculation, such as search engines, intelligent question answering, knowledge retrieval, information flow recommendation and other systems.

[0032] Currently, the bilateral multi-perspective matching model (BiMPM) is often used for text matching.

[0033] The BiMPM model currently used consists of 5 layers, such as Figure 1 As shown. The first layer is the word representation layer, the second layer is the context representation layer, the third layer is the matching layer, the fourth layer is the aggregation layer, and the fifth layer is the prediction layer. The first to fifth layers are connected in sequence. The first layer is used to receive two texts to be matched, which are recorded as the first text and the second text in this application. The context representation layer converts the first text and the second text into vectors. The matching layer is used to perform similarity matching on the first text and the second text. The aggregation layer is used for dimensionality reduction processing. The fifth layer outputs the matching result.

[0034] Figure 2 Schematic diagram of an application scenario of the text matching method provided in an embodiment of the present application, the above text matching method can be used to determine whether two texts match. Among them, the text storage device 10 is used to store the first text and the second text. The electronic device 20 is used to receive the first text and the second text sent by the text storage device 10, and use its own bilateral multi-view matching model to process the first text and the second text to obtain the matching result of the first text and the second text.

[0035] The following combination Figure 2 The text matching method of the embodiment of the present application is described in detail, and the method can be implemented in the electronic device 20. The electronic device 20 includes a BiMPM model. The BiMPM model used in the present application includes a text matching layer, a difference calculation layer and a result output layer.

[0036] Figure 3A schematic flow chart of the text matching method provided by the present application is shown, referring to Figure 3 , the method is described in detail as follows:

[0037] S101 : Calculate, by the text matching layer, a first matching vector of an input first text relative to an input second text, and a second matching vector of the second text relative to the first text.

[0038] In this embodiment, a text refers to a written language expression, and from a literary perspective, it is usually a sentence or a combination of multiple sentences with complete and systematic meanings. A text can be a sentence, a paragraph, or a chapter.

[0039] The first text may be a sentence, a paragraph or a chapter. The second text may be a sentence, a paragraph or a chapter. For ease of description, this application uses the first text as a sentence and the second text as a sentence for illustration, and the first text is denoted as P and the second text is denoted as Q.

[0040] In this embodiment, a first matching vector of the first text relative to the second text is obtained by performing similarity matching (P->Q) using each piece of information in the first text and each piece of information in the second text. A second matching vector of the second text relative to the first text is obtained by performing similarity matching (Q->P) using each piece of information in the second text and each piece of information in the first text.

[0041] S102: Calculate a difference vector between the first matching vector and the second matching vector by using the difference calculation layer.

[0042] In this embodiment, the first matching vector and the second matching vector are subtracted bit by bit to obtain a difference value, and the absolute value of the difference value constitutes an absolute value vector.

[0043] For example, if the first matching vector includes [A, B, C] and the second matching vector includes [D, E, F], the absolute value of the difference between A and D is calculated to obtain a first difference. The absolute value of the difference between B and E is calculated to obtain a second difference. The absolute value of the difference between C and D is calculated to obtain a third difference. The first difference, the second difference, and the third difference constitute a difference vector.

[0044] S103: Obtain a matching result between the first text and the second text based on the first matching vector, the second matching vector and the difference vector through a result output layer.

[0045] In this embodiment, the matching result may be a matching degree, based on which it is determined whether the first text and the second text match. The matching result may also be words or characters, such as "yes" or "no".

[0046] In an embodiment of the present application, a first matching vector of an input first text relative to an input second text and a second matching vector of the second text relative to the first text are calculated by a text matching layer in a bilateral multi-view matching model, a difference vector between the first matching vector and the second matching vector is calculated by a difference calculation layer in a bilateral multi-view matching model, and a matching result of the first text and the second text is obtained based on the first matching vector, the second matching vector and the difference vector by a result output layer in a bilateral multi-view matching model. Compared with the existing bilateral multi-view matching model, the present application sets a difference calculation layer in the bilateral multi-view matching model, calculates a difference vector between the first matching vector and the second matching vector by the difference calculation layer, and finally determines a matching result based on the difference vector, the first matching vector and the second matching vector. Compared with the prior art in which the first matching vector and the second matching vector are used to determine the matching result in the bilateral multi-view matching model, the present application adds a difference vector when determining the matching result, and the difference vector can characterize the similarity between the first text and the second text, so that the obtained matching result can be more accurate.

[0047] In a possible implementation, the text matching layer includes a word vector layer and a matching layer. The word vector layer includes a word representation layer and a context representation layer. The result output layer includes an aggregation layer and a prediction layer.

[0048] In addition, the difference calculation layer can be in the aggregation layer. The difference calculation layer can also be in the matching layer.

[0049] like Figure 4 As shown, in a possible implementation manner, the implementation process of step S101 may include:

[0050] S1011, receiving the first text and the second text through the word vector layer.

[0051] Specifically, the first text and the second text are received through the word representation layer.

[0052] S1012: Determine a first word vector of the first text and a second word vector of the second text through the word vector layer.

[0053] like Figure 5 Specifically, the implementation process of step S1012 may include:

[0054] S201, determining a third word vector of the first text and a fourth word vector of the second text through the word representation layer, the third word vector includes a word vector of each word in the first text, and the fourth word vector includes a word vector of each word in the second text.

[0055] In this embodiment, the purpose of the word representation layer is to represent each word in the first text with a third word vector (D-dimensional vector), and to represent each word in the second text with a fourth word vector.

[0056] The word representation layer includes a pre-trained language model. The third word vector is obtained through the pre-trained language model in the word representation layer; and the fourth word vector is obtained through the pre-trained language model in the word representation layer.

[0057] Pre-training belongs to the category of transfer learning. When training existing neural networks, it is generally based on the Back Propagation (BP) algorithm, which first randomly initializes the parameters in the network, and then uses optimization algorithms such as Stochastic Gradient Descent (SGD) to continuously optimize the model parameters. The idea of ​​pre-training is that the model parameters are no longer randomly initialized, but are pre-trained through some tasks to obtain a set of model parameters, and then use this set of parameters to initialize the model before training.

[0058] The pre-trained language model is based on large-scale text and pre-trained to obtain a general language representation. Through fine-tuning, the learned knowledge is transferred to different downstream tasks. The pre-trained language model can be BERT (Bidirectional Encoder Representation from Transformers), Albert (A Lite BERT) and other models.

[0059] Specifically, the first text is input into the pre-trained language model to obtain a word vector for each word in the first text. The word vector for each word in the first text constitutes a third word vector for the first text.

[0060] The second text is input into the pre-trained language model to obtain a word vector for each word in the second text. The word vector for each word in the second text constitutes a fourth word vector for the second text. Compared with the existing use of pre-trained word vectors and long short-term memory networks (LSTM) to obtain word vectors for text, the use of pre-trained language models in this application to obtain word vectors can better represent the semantics of the text.

[0061] S202, the context representation layer performs context embedding coding processing on the data corresponding to each time step in the third word vector through a first bidirectional long short-term memory network to obtain the first word vector, where the first word vector includes a first forward vector and a first backward vector.

[0062] S203, the context representation layer performs context embedding coding processing on the data corresponding to each time step in the fourth word vector through the first bidirectional long short-term memory network to obtain the second word vector, where the second word vector includes a second forward vector and a second backward vector.

[0063] In this embodiment, each word in the first text may be a time step, and each word in the second text may be a time step.

[0064] In this embodiment, the context representation layer aims to incorporate context information into the representation of each time step of the third word vector and the fourth word vector. Specifically, a bidirectional long short-term memory network is used for context embedding.

[0065] The basic idea of ​​the bidirectional long short-term memory network is that each input sequence passes through a recurrent neural network once in the forward and reverse directions. This bidirectional structure provides complete past and future context information to each node in the input sequence of the output layer.

[0066] Contextual embedding assigns a representation to each word based on its context, thereby capturing word usage across different contexts and encoding knowledge transferred across languages. Although the third word vector of the first text and the fourth word vector of the second text are obtained at the word representation layer, the third and fourth word vectors do not take into account the contextual meaning of the word, that is, the meaning of the context surrounding the word. For example, if the same word has different meanings in two texts, the third and fourth word vectors do not take into account the contextual meaning of the word, so the same word is given the same vector representation, making the third and fourth word vectors inaccurate. For the above reasons, the data corresponding to each time step in the third and fourth word vectors is processed with contextual embedding, and the first and second word vectors obtained can more accurately represent the meaning of each word.

[0067] Specifically, the data corresponding to each time step in the third word vector is processed by context embedding coding to obtain the processed data corresponding to each time step, and the processed data corresponding to all time steps constitute the first word vector. The forward vector obtained by the context embedding coding of the data corresponding to each time step in the third word vector constitutes the first forward vector. The backward vector obtained by the context embedding coding of the data corresponding to each time step in the third word vector constitutes the first backward vector.

[0068] The data corresponding to each time step in the fourth word vector is subjected to context embedding coding processing to obtain processed data corresponding to each time step, and the processed data corresponding to all time steps constitute the second word vector. The forward vector obtained by the data corresponding to each time step in the fourth word vector after the context embedding coding processing constitutes the second forward vector. The backward vector obtained by the data corresponding to each time step in the fourth word vector after the context embedding coding processing constitutes the second backward vector.

[0069] Specifically, the data p corresponding to each time step in the third word vector i , we can use the formula Perform context embedding encoding processing, where For p i The forward vector of For p i The backward vector of M is the number of time steps in the third word vector. Form the first forward vector, all Form the first backward vector.

[0070] The data q corresponding to each time step in the fourth word vector j , we can use the formula Perform context embedding encoding processing, where Q j The forward vector of Q j The backward vector of , N is the number of time steps in the fourth word vector. All the fourth word vectors are obtained Form the second forward vector, all Form the second backward vector.

[0071] S1013: Perform similarity matching on the data corresponding to each time step in the first word vector and the data corresponding to each time step in the second word vector through the matching layer to obtain a first matching vector.

[0072] In this embodiment, the similarity between the data corresponding to each time step in the first word vector and the data corresponding to each time step in the second word vector is calculated to obtain a first matching vector.

[0073] Specifically, the matching layer performs similarity matching on the data corresponding to each time step in the first forward vector and the data corresponding to each time step in the second forward vector to obtain a first vector;

[0074] The matching layer performs similarity matching on the data corresponding to each time step in the first forward vector and the data corresponding to each time step in the second backward vector to obtain a second vector;

[0075] The matching layer performs similarity matching on the data corresponding to each time step in the first backward vector and the data corresponding to each time step in the second forward vector to obtain a third vector;

[0076] The matching layer performs similarity matching on the data corresponding to each time step in the first backward vector and the data corresponding to each time step in the second backward vector to obtain a fourth vector;

[0077] The matching layer concatenates the first vector, the second vector, the third vector, and the fourth vector to obtain the first matching vector.

[0078] For example, if the first word vector includes [a, b, c] and the second word vector includes [d, e, f], a and d are matched by similarity to obtain the first value; a and e are matched by similarity to obtain the second value; a and f are matched by similarity to obtain the third value; b and d are matched by similarity to obtain the fourth value; b and e are matched by similarity to obtain the fifth value; b and f are matched by similarity to obtain the sixth value; c and d are matched by similarity to obtain the seventh value; c and e are matched by similarity to obtain the eighth value; c and f are matched by similarity to obtain the ninth value. The first value, the second value, the third value, the fourth value, the fifth value, the sixth value, the seventh value, the eighth value and the ninth value constitute the first matching vector.

[0079] S1014: Perform similarity matching on the data corresponding to each time step in the second word vector and the data corresponding to each time step in the first word vector through the matching layer to obtain a second matching vector.

[0080] Specifically, the matching layer performs similarity matching on the data corresponding to each time step in the second forward vector and the data corresponding to each time step in the first forward vector to obtain a fifth vector;

[0081] The matching layer performs similarity matching on the data corresponding to each time step in the second forward vector and the data corresponding to each time step in the first backward vector to obtain a sixth vector;

[0082] The matching layer performs similarity matching on the data corresponding to each time step in the second backward vector and the data corresponding to each time step in the first forward vector to obtain a seventh vector;

[0083] The matching layer performs similarity matching on the data corresponding to each time step in the second backward vector and the data corresponding to each time step in the first backward vector to obtain an eighth vector;

[0084] The matching layer concatenates the fifth vector, the sixth vector, the seventh vector, and the eighth vector to obtain the first matching vector.

[0085] like Figure 6 As shown, in a possible implementation manner, the implementation process of step S102 may include:

[0086] S1021: The difference calculation layer converts the first matching vector into a binary vector to obtain a converted first matching vector.

[0087] S1022: The difference calculation layer converts the second matching vector into a binary vector to obtain a converted second matching vector.

[0088] S1023: The difference calculation layer performs bitwise difference calculation on the converted first matching vector and the converted second matching vector to obtain the difference vector.

[0089] In this embodiment, the absolute value after bitwise difference is used to form a difference vector. The difference vector reflects the similarity information between the first matching vector and the second matching vector. If the first text and the second text are exactly the same, then the first word vector and the second word vector are the same. The difference vector is 0. Therefore, the greater the similarity between the first text and the second text, the smaller the vector after bitwise difference is.

[0090] In the embodiment of the present application, the first matching vector and the second matching vector are converted into binary data and the binary data is processed to improve the data processing speed. The first matching vector after conversion and the second matching vector after conversion are subjected to bitwise difference to further compare the similarity of the first text and the second text.

[0091] like Figure 7 As shown, in a possible implementation manner, the implementation process of step S103 may include:

[0092] S1031: The aggregation layer performs dimensionality reduction processing on the first matching vector, the second matching vector, and the difference vector respectively to obtain a first matching vector after dimensionality reduction processing, a second matching vector after dimensionality reduction processing, and a difference vector after dimensionality reduction processing.

[0093] In this embodiment, the aggregation layer includes a second bidirectional long short-term memory network. The first matching vector, the second matching vector and the difference vector are respectively aggregated into three vectors of preset lengths by using the second bidirectional long short-term memory network, so as to improve the speed of data processing in subsequent processing.

[0094] S1032: The aggregation layer concatenates the first matching vector after the dimensionality reduction processing, the second matching vector after the dimensionality reduction processing, and the difference vector after the dimensionality reduction processing to obtain a third matching vector.

[0095] S1033: The prediction layer obtains a matching result of the first text and the second text based on the third matching vector.

[0096] In this embodiment, the prediction layer includes two fully connected layers. The two fully connected layers process the third matching vector to obtain a processed third matching vector. Softmax classification is performed on the processed third matching vector to obtain a matching result.

[0097] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0098] Corresponding to the text matching method described in the above embodiment, the text matching device provided in the embodiment of the present application includes a bilateral multi-view matching model, and the bilateral multi-view matching model includes a text matching layer, a difference calculation layer and a result output layer. Figure 8 A structural block diagram of a bilateral multi-view matching model is shown. For ease of explanation, only the parts related to the embodiments of the present application are shown.

[0099] Reference Figure 8 The model 300 may include: a text matching layer 310 , a difference calculation layer 320 , and a result output layer 330 .

[0100] The text matching layer 310 is used to calculate a first matching vector of an input first text relative to an input second text, and a second matching vector of the second text relative to the first text;

[0101] A difference calculation layer 320, configured to calculate a difference vector between the first matching vector and the second matching vector;

[0102] The result output layer 330 is used to obtain the matching result of the first text and the second text based on the first matching vector, the second matching vector and the difference vector.

[0103] In a possible implementation, the text matching layer includes a word vector layer and a matching layer;

[0104] The word vector layer is used to receive the first text and the second text;

[0105] The word vector layer is further used to determine a first word vector of the first text and a second word vector of the second text;

[0106] The matching layer is used to perform similarity matching on the data corresponding to each time step in the first word vector and the data corresponding to each time step in the second word vector to obtain a first matching vector;

[0107] The matching layer is further used to perform similarity matching on the data corresponding to each time step in the second word vector with the data corresponding to each time step in the first word vector to obtain a second matching vector.

[0108] In a possible implementation, the word vector layer includes a word representation layer and a context representation layer;

[0109] The word representation layer is used to determine a third word vector of the first text and a fourth word vector of the second text, wherein the third word vector includes a word vector of each word in the first text, and the fourth word vector includes a word vector of each word in the second text;

[0110] The context representation layer is used to perform context embedding coding processing on the data corresponding to each time step in the third word vector through a first bidirectional long short-term memory network to obtain the first word vector, where the first word vector includes a first forward vector and a first backward vector;

[0111] The context representation layer is also used to perform context embedding encoding processing on the data corresponding to each time step in the fourth word vector through the first bidirectional long short-term memory network to obtain the second word vector, where the second word vector includes a second forward vector and a second backward vector.

[0112] In a possible implementation, the word representation layer includes a pre-trained language model;

[0113] The word representation layer is used to obtain the third word vector through the pre-trained language model;

[0114] The word representation layer is also used to obtain the fourth word vector through the pre-trained language model.

[0115] In a possible implementation, the difference calculation layer 320 may be specifically used for:

[0116] Convert the first matching vector into a binary vector to obtain a converted first matching vector;

[0117] Convert the second matching vector into a binary vector to obtain a converted second matching vector;

[0118] The converted first matching vector and the converted second matching vector are subjected to bitwise difference to obtain the difference vector.

[0119] In a possible implementation, the result output layer includes an aggregation layer and a prediction layer;

[0120] The aggregation layer is used to perform dimensionality reduction processing on the first matching vector, the second matching vector and the difference vector respectively to obtain the first matching vector after dimensionality reduction processing, the second matching vector after dimensionality reduction processing and the difference vector after dimensionality reduction processing;

[0121] The aggregation layer is further used to concatenate the first matching vector after the dimensionality reduction processing, the second matching vector after the dimensionality reduction processing, and the difference vector after the dimensionality reduction processing to obtain a third matching vector;

[0122] The prediction layer is used to obtain a matching result between the first text and the second text based on the third matching vector.

[0123] In a possible implementation, the matching layer is further used for:

[0124] Performing similarity matching on the data corresponding to each time step in the first forward vector and the data corresponding to each time step in the second forward vector to obtain a first vector;

[0125] Performing similarity matching on the data corresponding to each time step in the first forward vector and the data corresponding to each time step in the second backward vector to obtain a second vector;

[0126] Performing similarity matching on the data corresponding to each time step in the first backward vector and the data corresponding to each time step in the second forward vector to obtain a third vector;

[0127] Performing similarity matching on the data corresponding to each time step in the first backward vector and the data corresponding to each time step in the second backward vector to obtain a fourth vector;

[0128] The first vector, the second vector, the third vector and the fourth vector are concatenated to obtain the first matching vector.

[0129] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0130] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0131] The present application also provides a terminal device, see Fig. 9 The terminal device 400 may include: at least one processor 410, a memory 420, and a computer program stored in the memory 420 and executable on the at least one processor 410. When the processor 410 executes the computer program, the steps in any of the above-mentioned method embodiments are implemented, for example Figure 3 Steps S101 to S103 in the illustrated embodiment. Alternatively, when the processor 410 executes the computer program, the functions of each module / unit in the above-mentioned device embodiments are implemented, for example Figure 8 The functions of modules 310 to 330 are shown.

[0132] Exemplarily, the computer program may be divided into one or more modules / units, one or more modules / units are stored in the memory 420, and executed by the processor 410 to complete the present application. The one or more modules / units may be a series of computer program segments capable of completing specific functions, and the program segments are used to describe the execution process of the computer program in the terminal device 400.

[0133] Those skilled in the art will understand that Fig. 9 It is only an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components, such as input and output devices, network access devices, buses, etc.

[0134] The processor 410 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0135] The memory 420 may be an internal storage unit of the terminal device, or an external storage device of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. The memory 420 is used to store the computer program and other programs and data required by the terminal device. The memory 420 may also be used to temporarily store data that has been output or is to be output.

[0136] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0137] The text matching method provided in the embodiment of the present application can be applied to terminal devices such as computers, tablet computers, laptop computers, netbooks, personal digital assistants (PDAs), etc. The embodiment of the present application does not impose any restrictions on the specific type of terminal devices.

[0138] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0139] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0140] In the embodiments provided in the present application, it should be understood that the disclosed terminal equipment, devices and methods can be implemented in other ways. For example, the terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0141] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0142] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0143] If the integrated unit is implemented in the form of 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 present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by one or more processors, the steps of each of the above-mentioned method embodiments can be implemented.

[0144] If the integrated unit is implemented in the form of 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 present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by one or more processors, the steps of each of the above-mentioned method embodiments can be implemented.

[0145] Similarly, as a computer program product, when the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0146] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer readable media do not include electric carrier signals and telecommunication signals.

[0147] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A text matching method, characterized in that: Applied to a bilateral multi-view matching model including a text matching layer, a difference calculation layer and a result output layer, wherein the result output layer includes an aggregation layer and a prediction layer, the method includes: Calculate, by the text matching layer, a first matching vector of the input first text relative to the input second text, and a second matching vector of the second text relative to the first text; The difference calculation layer converts the first matching vector into a binary vector to obtain a converted first matching vector; The difference calculation layer converts the second matching vector into a binary vector to obtain a converted second matching vector; The difference calculation layer performs bitwise difference calculation on the converted first matching vector and the converted second matching vector to obtain a difference vector between the first matching vector and the second matching vector; The aggregation layer performs dimensionality reduction processing on the first matching vector, the second matching vector and the difference vector respectively to obtain the first matching vector after dimensionality reduction processing, the second matching vector after dimensionality reduction processing and the difference vector after dimensionality reduction processing; The aggregation layer concatenates the first matching vector after the dimensionality reduction processing, the second matching vector after the dimensionality reduction processing, and the difference vector after the dimensionality reduction processing to obtain a third matching vector; The prediction layer obtains a matching result of the first text and the second text based on the third matching vector.

2. The text matching method according to claim 1, characterized in that: The text matching layer includes a word vector layer and a matching layer, and the first matching vector of the input first text relative to the input second text and the second matching vector of the second text relative to the first text are calculated by the text matching layer, including: Receiving the first text and the second text through the word vector layer; Determine a first word vector for the first text and a second word vector for the second text by the word vector layer; By using the matching layer, the data corresponding to each time step in the first word vector are respectively matched with the data corresponding to each time step in the second word vector to obtain a first matching vector; The matching layer performs similarity matching on the data corresponding to each time step in the second word vector and the data corresponding to each time step in the first word vector to obtain a second matching vector.

3. The text matching method according to claim 2, characterized in that: The word vector layer includes a word representation layer and a context representation layer, and determining the first word vector of the first text and the second word vector of the second text through the word vector layer includes: Determine a third word vector of the first text and a fourth word vector of the second text through the word representation layer, wherein the third word vector includes a word vector of each word in the first text, and the fourth word vector includes a word vector of each word in the second text; The context representation layer performs context embedding encoding processing on the data corresponding to each time step in the third word vector through a first bidirectional long short-term memory network to obtain the first word vector, where the first word vector includes a first forward vector and a first backward vector; The context representation layer performs context embedding encoding processing on the data corresponding to each time step in the fourth word vector through the first bidirectional long short-term memory network to obtain the second word vector, which includes a second forward vector and a second backward vector.

4. The text matching method according to claim 3, characterized in that: The word representation layer includes a pre-trained language model, and determining the third word vector of the first text and the fourth word vector of the second text through the word representation layer includes: Obtaining the third word vector through the pre-trained language model in the word representation layer; The fourth word vector is obtained through the pre-trained language model in the word representation layer.

5. The text matching method according to claim 3, characterized in that: The method of performing similarity matching on the data corresponding to each time step in the first word vector and the data corresponding to each time step in the second word vector by the matching layer to obtain a first matching vector includes: The matching layer performs similarity matching on the data corresponding to each time step in the first forward vector and the data corresponding to each time step in the second forward vector to obtain a first vector; The matching layer performs similarity matching on the data corresponding to each time step in the first forward vector and the data corresponding to each time step in the second backward vector to obtain a second vector; The matching layer performs similarity matching on the data corresponding to each time step in the first backward vector and the data corresponding to each time step in the second forward vector to obtain a third vector; The matching layer performs similarity matching on the data corresponding to each time step in the first backward vector and the data corresponding to each time step in the second backward vector to obtain a fourth vector; The matching layer concatenates the first vector, the second vector, the third vector, and the fourth vector to obtain the first matching vector.

6. A text matching device, characterized in that: include: A bilateral multi-view matching model, wherein the bilateral multi-view matching model comprises a text matching layer, a difference calculation layer and a result output layer, wherein the result output layer comprises an aggregation layer and a prediction layer; The text matching layer is used to calculate a first matching vector of an input first text relative to an input second text, and a second matching vector of the second text relative to the first text; The difference calculation layer is used to convert the first matching vector into a binary vector to obtain a converted first matching vector; convert the second matching vector into a binary vector to obtain a converted second matching vector; perform bitwise difference calculation on the converted first matching vector and the converted second matching vector to obtain a difference vector between the first matching vector and the second matching vector; The aggregation layer is used to perform dimensionality reduction processing on the first matching vector, the second matching vector and the difference vector respectively to obtain the first matching vector after dimensionality reduction processing, the second matching vector after dimensionality reduction processing and the difference vector after dimensionality reduction processing; The aggregation layer is further used to concatenate the first matching vector after the dimensionality reduction processing, the second matching vector after the dimensionality reduction processing, and the difference vector after the dimensionality reduction processing to obtain a third matching vector; The prediction layer is used to obtain a matching result between the first text and the second text based on the third matching vector.

7. A terminal device, 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, the text matching method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text matching method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Similarity determination method and device, network training method and device, search method and device and storage medium

    CN111091010A

  • Text similarity calculation system and method based on multi-keyword pair matching, and storage medium

    CN112232053A