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

By employing a contrastive learning-based deep text matching method, and utilizing the BERT model and a self-supervised mechanism to train the text matching model, the limitations of lexical-level matching are overcome, thereby improving the accuracy and robustness of text matching.

CN114036283BActive Publication Date: 2026-03-27阳光保险集团股份有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing text matching technologies mainly rely on word-level matching, which leads to inaccurate results and cannot effectively solve semantic-level matching problems.

Method used

A deep text matching method based on contrastive learning is adopted. The BERT model is used for encoding, and positive and negative examples are constructed by utilizing the self-supervised mechanism of contrastive learning and two Dropout calculations. The cosine similarity loss is calculated and combined with the cross-entropy loss for model training to alleviate overfitting and improve the robustness of the model.

Benefits of technology

It improves the accuracy of text matching, reduces overfitting, enhances the consistency of model output under different exit mechanisms, and improves matching performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114036283B_ABST
    Figure CN114036283B_ABST
Patent Text Reader

Abstract

The application provides a text matching method, device and equipment and readable storage medium. The method comprises the following steps: obtaining a to-be-matched text and a candidate text set; inputting the to-be-matched text into a matching model to obtain a processing result; and determining a target text matched with the to-be-matched text from the candidate text set according to the processing result, wherein the matching model is obtained by training a basic model according to output results of twice inputting training samples into the basic model, and wherein the output result corresponding to one-time input of one sample into the basic model comprises a punch vector corresponding to the one sample and a similarity between two texts in the one sample. The accuracy of text matching can be improved by the method.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of text relationship matching, and in particular, to a text matching method, device, equipment and readable storage medium. BACKGROUND

[0002] At present, most of the commonly used text matching mainly discriminates semantic logic degree, semantic relationship reasoning, question and answer, such as semantic relevance of search recommendation, question-question, question-answer matching in intelligent question answering, entity linking in knowledge graph, etc. The algorithm used in text matching mainly solves the matching problem based on the lexical level.

[0003] The above-mentioned matching algorithm based on lexical coincidence has great limitations, and the result matched in the process of text similarity matching is not accurate.

[0004] Therefore, how to improve the accuracy of text matching has become a technical problem to be solved. SUMMARY

[0005] The purpose of the embodiment of the present application is to provide a text matching method, which can improve the accuracy of text matching through the technical scheme of the embodiment of the present application.

[0006] In a first aspect, the embodiment of the present application provides a text matching method, comprising: obtaining a to-be-matched text and a candidate text set; inputting the to-be-matched text into a matching model to obtain a processing result; and determining a target text matched with the to-be-matched text from the candidate text set according to the processing result, wherein the matching model is obtained by training a base model according to output results of twice inputting a training sample into the base model, and wherein the output result corresponding to one input of the base model includes a punch vector corresponding to the one sample and a similarity between two texts in the one sample.

[0007] In the above process, the to-be-matched text can be input into the model to match the target text, and the target text can be found from the candidate text set based on the output result of the model. Since the matching model in the embodiment of the present application is obtained by training the vector and the similarity obtained by twice inputting the sample into the model, the phenomenon of model overfitting can be effectively alleviated. Therefore, the embodiment of the present application can improve the accuracy of text matching.

[0008] Optionally, when the processing result is the similarity between the to-be-matched text and each candidate text in the candidate set, inputting the to-be-matched text into the matching model comprises:

[0009] inputting the to-be-matched text and each candidate text in the candidate set into the matching model;

[0010] determining the target text matching the text to be matched from the candidate text set according to the processing result, comprising:

[0011] ranking the values of the similarity of the text to be matched and each candidate text in the candidate set;

[0012] determining the candidate text corresponding to the maximum value of the similarity as the target text.

[0013] In the above process, the text to be matched and the candidate text set can be directly input into the model, and the candidate text corresponding to the maximum similarity can be directly found out by the similarity of the text to be matched and each candidate text. At this time, the candidate text is the target text. This method is faster and more effective.

[0014] Optionally, the processing result is a vector of the text to be matched, and the target text matching the text to be matched is determined from the candidate text set according to the processing result, comprising:

[0015] calculating the cosine similarity of the vector of the text to be matched and the vector of each candidate text in the candidate set to obtain M cosine similarities, M being a positive integer greater than or equal to 2;

[0016] determining the candidate text corresponding to the maximum value of the cosine similarity in the M cosine similarities as the target text.

[0017] In the above process, the text to be matched can be input into the model alone, and the cosine similarity of the vector of the text to be matched and the vector of each candidate text can be calculated. The greater the value of the similarity, the greater the similarity of the corresponding candidate text and the text to be matched, and thus the target text can be more easily found out.

[0018] Optionally, before obtaining the text to be matched and the candidate text set, the method further comprises:

[0019] obtaining the text in the system log;

[0020] manually labeling similar texts for the text;

[0021] splicing each two similar texts in the manually labeled similar texts using a template prepared in advance to form a training sample;

[0022] inputting the training sample into the basic model twice to obtain an output result, and training the basic model according to the output result to obtain a matching model, wherein the output result corresponding to one input of the basic model includes a punch vector corresponding to one sample and the similarity of the two texts in the sample.

[0023] In the above process, through the training of the model, especially the training method of inputting the sample twice into the basic model, the effect of overfitting can be reduced in the text matching process.

[0024] Optionally, after inputting each sample twice into the basic model and training the existing basic model using the optimization algorithm of the training model, the method further comprises:

[0025] inputting the verification sample in the verification set twice into the matching model to obtain two vectors of the verification sample;

[0026] calculating the cosine similarity according to the two vectors of the verification sample;

[0027] verifying the matching model according to the value of the cosine similarity;

[0028] or

[0029] inputting the verification sample in the verification set into the matching model to obtain the similarity of the two texts in the verification sample;

[0030] verifying the matching model according to the similarity of the two texts in the sample.

[0031] In the above process, through the verification of the verification set, it can be verified whether the model training is good or not. If it is found that the model meets the standard after multiple verifications, it means that the model can be used. If it is found that the verification result of the model does not meet the standard, the model will be trained using the sample until the model training meets the standard.

[0032] Optionally, in the process of verifying the model by the verification set, the matching model is verified according to the value of the cosine similarity, comprising:

[0033] comparing the value of the cosine similarity with a threshold to obtain a comparison result;

[0034] verifying the matching model according to the comparison result.

[0035] In the above process, by comparing the value of the cosine similarity with the threshold, it can be compared whether the model training meets the standard.

[0036] Optionally, before obtaining the to-be-matched text and the candidate text set, the method further comprises:

[0037] screening the similar texts of the to-be-matched text in the knowledge base using the text similarity algorithm in the server to obtain the candidate text set.

[0038] In the above process, the similarity algorithm is used to find similar texts from the knowledge base to the text to be matched, and the set of candidate texts is pre-selected, so that the set of candidate texts can be directly put into the model, the steps are simple, and the matching process is more efficient.

[0039] In a second aspect, the embodiments of the present application provide a text matching device, comprising:

[0040] An acquisition module is configured to acquire a text to be matched and a set of candidate texts.

[0041] An input module is configured to input the text to be matched into a matching model to obtain a processing result.

[0042] An output module is configured to determine a target text matched with the text to be matched from the set of candidate texts according to the processing result, wherein the matching model is obtained by training a basic model according to output results of twice inputting training samples into the basic model, and wherein the output result corresponding to one time inputting one sample into the basic model includes a punch vector corresponding to the one sample and a similarity between two texts in the one sample.

[0043] Optionally, the input module is specifically configured to:

[0044] input the text to be matched and each candidate text in the set of candidate texts into the matching model.

[0045] The output module is specifically configured to:

[0046] sort values of the similarity of the text to be matched and each candidate text in the set of candidate texts.

[0047] determine the candidate text corresponding to the maximum value of the similarity as the target text.

[0048] Optionally, the output module is specifically configured to:

[0049] the processing result is a vector of the text to be matched, and the vector of the text to be matched and the vector of each candidate text in the set of candidate texts are calculated for cosine similarity to obtain M cosine similarities, M being a positive integer greater than or equal to 2.

[0050] determine the candidate text corresponding to the maximum value of the cosine similarity in the M cosine similarities as the target text.

[0051] Optionally, the device further comprises:

[0052] A training module is configured to, before acquiring the text to be matched and the set of candidate texts:

[0053] acquire texts in system logs.

[0054] The text is manually annotated with similar texts;

[0055] Each of the manually annotated similar texts is spliced using a template prepared in advance to form a training sample;

[0056] The output result is obtained after the training sample is input into the basic model twice, and the matching model is obtained after the basic model is trained according to the output result, wherein the output result corresponding to one sample input into the basic model once includes a punch vector corresponding to the one sample and a similarity between two texts in the one sample.

[0057] Optionally, the device further comprises:

[0058] The verification module is configured to, after the input of each sample into the basic model twice and the training of the existing basic model using the optimization algorithm of the training model:

[0059] The verification sample in the verification set is input into the matching model twice to obtain two vectors of the verification sample;

[0060] The cosine similarity is calculated according to the two vectors of the verification sample;

[0061] The matching model is verified according to the value of the cosine similarity;

[0062] Or

[0063] The verification sample in the verification set is input into the matching model to obtain the similarity between two texts in the verification sample;

[0064] The matching model is verified according to the similarity between the two texts in the sample.

[0065] Optionally, the verification module is specifically configured to:

[0066] The value of the cosine similarity is compared with a threshold value to obtain a comparison result;

[0067] The matching model is verified according to the comparison result.

[0068] Optionally, the device further comprises:

[0069] The screening module is configured to, before the obtaining of the to-be-matched text and the candidate text set, screen similar texts in a knowledge base to the to-be-matched text using a text similarity algorithm in a server to obtain the candidate text set.

[0070] In a third aspect, an electronic device is provided, which includes a processor and a memory. The memory stores computer readable instructions which, when executed by the processor, perform the steps of the method according to the first aspect.

[0071] In a fourth aspect, a readable storage medium is provided, which stores a computer program. The computer program, when executed by a processor, performs the steps of the method according to the first aspect.

[0072] Other features and advantages of the present application will be further described in the following description with reference to the drawings, and will be apparent to those skilled in the art from the following description and the embodiments of the present application. The aims and other advantages of the present application can be achieved and obtained by the structure particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF DRAWINGS

[0073] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be considered as limiting the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.

[0074] Figure 1 A flow chart of a text matching method provided by an embodiment of the present application;

[0075] Figure 2 A schematic block diagram of a text matching device provided by an embodiment of the present application;

[0076] Figure 3 A structural schematic diagram of a text matching device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0077] The technical solutions of the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.

[0078] It should be noted that the numerals and letters of the logic represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. Meanwhile, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.

[0079] The present application is applied to the scene of text matching, and the specific scene is that an input text is input into a text matching model, and similar texts to the text are found out through the text.

[0080] But in the current text matching technology has BoW (information search), TF-IDF (information retrieval and mining), BM25 (similarity), Jaccord (similarity and difference between samples), SimHash (massive data processing) algorithms, such as BM25 algorithm calculates the matching score between the two by the coverage of the query word on the web page, the higher the score, the better the matching degree of the web page with the query, mainly solving the matching problem at the lexical level. The matching algorithm based on lexical overlap has great limitations, including: lexical limitations: for example, "taxi" and "taxi" are not similar in words, but they are the same kind of transportation; "apple" means different things in different contexts, or fruit or company; structural limitations: "machine learning" and "learning machine" have completely overlapping words, but express different meanings; knowledge limitations: for example, "Qin Shi Huang plays mobile phone" is correct in terms of word and sentence structure, but it is wrong in terms of knowledge. This shows that for the text matching task, it cannot stop at the level of literal matching, and more semantic level matching is needed.

[0081] Therefore, the present application proposes a deep text matching method based on contrast learning, which applies contrast learning to the training process of the deep text matching model in the supervised learning category. Specifically, for each sample (text pair) in the Batch, the BERT model is used for encoding, and the output encoding vector is calculated twice by Dropout mechanism. The two vectors obtained by stacking the fully connected layer are used to construct the positive example in the contrast learning. One of the two vectors is randomly sampled and combined with the vector output by the other samples in the Batch to construct the negative example. The cosine similarity loss is calculated, and the cross-entropy loss is calculated combined with the artificial labeling label of whether the text pair is similar. A multi-objective training task is constructed, and the model is trained by back propagation and gradient descent method. This method uses the self-supervised mechanism of contrast learning to train the deep text matching model with less sample size. The two Dropout mechanisms construct positive examples for data augmentation, which not only alleviates the overfitting phenomenon of deep models, but also strengthens the robustness of the model to the Dropout mechanism, so that the outputs of the model under different Dropout mechanisms are basically consistent, solving the inconsistency problem of the Dropout mechanism in training and prediction, and improving the model effect.

[0082] The following will be described in detail Figure 1 The text matching method of the embodiment of the present application is described in detail.

[0083] Please refer to Figure 1 , Figure 1 The flowchart of the text matching method provided by the embodiment of the present application is shown in Figure 1 The text matching method includes:

[0084] 110: obtaining the text to be matched and the candidate text set.

[0085] Through the obtained matching text and the candidate text set, subsequent direct input model or combination after input model can be facilitated.

[0086] The matching text is an input text, and the candidate text is a text compared with the input text in similarity.

[0087] Optionally, before obtaining the matching text and the candidate text set, Figure 1 The method can further include:

[0088] Obtaining the text in the system log;

[0089] Artificially annotating the similar text of the text;

[0090] Splicing each two similar texts in the artificially annotated similar text using a prepared template to form a training sample;

[0091] Obtaining an output result after inputting the training sample twice into the basic model, and obtaining a matching model after training the basic model according to the output result, wherein the output result corresponding to one sample input into the basic model once includes a punch vector corresponding to the sample and a similarity between two texts in the sample.

[0092] Through the training of the model, especially the training method of inputting the sample twice into the basic model, the effect of overfitting can be slowed down in the process of text matching.

[0093] The basic model can be a BERT model or other available models, and the punch vector can be calculated by the two-time exit mechanism in the training process, for example: each punch vector can have 300-dimensional values, and after the calculation of the exit mechanism, part of the values can be removed, such as 30-dimensional values, and the remaining 270-dimensional values can form a new vector, and the 30-dimensional values are randomly selected, so the vector after each calculation of the exit mechanism is different, but we can adjust the model parameters to make the two or more vectors the same, so that the robustness of the model is stronger.

[0094] Optionally, after inputting each sample twice into the basic model and training the existing basic model using the optimization algorithm of the training model, Figure 1 The method can further include:

[0095] Inputting the verification sample in the verification set twice into the matching model to obtain two vectors of the verification sample;

[0096] Calculating the cosine similarity according to the two vectors of the verification sample;

[0097] verify the matching model according to the value of the cosine similarity;

[0098] or

[0099] input the verification sample in the verification set into the matching model to obtain the similarity of the two texts in the verification sample;

[0100] verify the matching model according to the similarity of the two texts in the sample.

[0101] Through the verification of the verification set, it can be verified whether the model training is good or not. If it is found that the model meets the standard after multiple verifications, it means that the model can be used. If it is found that the verification result of the model does not meet the standard, the sample will be used to continue training the model until the model training meets the standard.

[0102] The cosine similarity can be used to calculate the similarity of two vectors, and then judge the similarity of two samples.

[0103] Optionally, in the process of verifying the model by the verification set, the matching model is verified according to the value of the cosine similarity, comprising:

[0104] compare the value of the cosine similarity with a threshold value to obtain a comparison result;

[0105] verify the matching model according to the comparison result.

[0106] By comparing the value of the cosine similarity with the threshold value, it can be compared whether the model training meets the standard.

[0107] A certain range value can be set, for example: when there are 100 samples for model verification, it can be set that the results obtained after more than 95 samples pass through the model are all in line with the standard, so the model can be considered to meet the standard, and the threshold value can also be set to 0.95. When the final similar result is greater than 0.95, the model can be considered to meet the standard.

[0108] Optionally, before obtaining the to-be-matched text and the candidate text set, Figure 1 The method shown can also include:

[0109] The similar texts in the knowledge base to the to-be-matched text are filtered by using the text similarity algorithm in the server to obtain the candidate text set.

[0110] After the similar texts in the knowledge base to the to-be-matched text are found by using the similarity algorithm, the candidate text set is pre-collected, which is convenient for subsequently directly putting the candidate text set into the model, the step is simple, and the matching process is more efficient.

[0111] In the process of searching for similar texts, partial search can also be performed, reducing the range of text quantity in the text matching process, and further reducing the time resources of matching.

[0112] 120: input the text to be matched into the matching model to obtain a processing result.

[0113] It should be understood that in the embodiments of the present application, the processing result can include various cases, for example:

[0114] Case 1: the processing result is the similarity of the text to be matched and each candidate text in the candidate set.

[0115] Case 2: the processing result is the vector of the text to be matched.

[0116] 130: determine the target text matched with the text to be matched from the candidate text set according to the processing result.

[0117] Therefore, in the embodiments of the present application, the text to be matched can be input into the model to match the target text, and the target text can be found from the candidate text set based on the output result of the model. Since the matching model in the embodiments of the present application is trained by the vectors and similarity obtained by twice inputting the sample into the model, the phenomenon of model overfitting can be effectively alleviated, and therefore the accuracy of text matching can be improved.

[0118] Specifically, for different cases of processing results, the present application determines the target text in different ways, for example, for case 1, when the processing result is the similarity of the text to be matched and each candidate text in the candidate set, the text to be matched is input into the matching model, which includes:

[0119] input the text to be matched and each candidate text in the candidate set into the matching model;

[0120] determine the target text matched with the text to be matched from the candidate text set according to the processing result, which includes:

[0121] sort the values of the similarity of the text to be matched and each candidate text in the candidate set;

[0122] determine the candidate text corresponding to the maximum value of the similarity as the target text.

[0123] The text to be matched and the candidate text set can be directly input into the model, and the candidate text corresponding to the maximum similarity can be directly found by the similarity of the text to be matched and each candidate text, at this time the candidate text is the target text, and this method is more efficient.

[0124] For scenario 2 above, optionally, the processing result is a vector of the text to be matched, and the target text matching the text to be matched is determined from the candidate text set based on the processing result, including:

[0125] The cosine similarity between the vector of the text to be matched and the vector of each candidate text in the candidate set is calculated to obtain M cosine similarity scores, where M is a positive integer greater than or equal to 2.

[0126] The candidate text corresponding to the largest cosine similarity value among the M cosine similarities is determined as the target text.

[0127] The text to be matched can be input into the model individually. By calculating the cosine similarity between the vector of the text to be matched and the vector of each candidate text, the larger the similarity value, the greater the similarity between the corresponding candidate text and the text to be matched, and thus the easier it is to find the target text.

[0128] These vectors can be obtained in advance, obtained by pre-inputting into the model, or obtained from a third party. For example, the third-party device may obtain these vectors in advance by inputting samples into the module, and then the execution body of the method of this application obtains them from the third party. The vectors of the candidate texts can be obtained when executing the text matching method of this application. That is, before determining the target text that matches the text to be matched from the candidate text set according to the processing result, the method further includes inputting each candidate text set into the matching model to obtain the vector of each candidate text.

[0129] The previous text passed Figure 1 The text matching method is described below, combined with Figures 2-3 A device that describes text matching.

[0130] Please refer to Figure 2 This is a schematic block diagram of a text matching device 200 provided in an embodiment of this application. The device 200 may be a module, program segment, or code on an electronic device. This device 200 is related to the above... Figure 1 The method implementation corresponds to this and can be executed. Figure 1 The various steps involved in the method embodiments and the specific functions of the device 200 can be found in the following description. To avoid repetition, detailed descriptions are omitted here.

[0131] Optionally, the device 200 includes:

[0132] Module 210 is used to obtain the text to be matched and the candidate text set;

[0133] Input module 220 is used to input the text to be matched into the matching model and obtain the processing result;

[0134] The output module 230 is configured to determine a target text matched with the text to be matched from the candidate text set according to the processing result, wherein the matching model is obtained by training the basic model according to output results obtained by inputting the training sample twice into the basic model, and the output result corresponding to inputting one sample into the basic model once includes a punch vector corresponding to the one sample and a similarity between two texts in the one sample.

[0135] Optionally, the input module is specifically configured to:

[0136] input the text to be matched and each candidate text in the candidate set into the matching model;

[0137] The output module is specifically configured to:

[0138] sort values of the similarities between the text to be matched and each candidate text in the candidate set;

[0139] determine the candidate text corresponding to the maximum value of the similarity as the target text.

[0140] Optionally, the output module is specifically configured to:

[0141] the processing result is a vector of the text to be matched, and the vector of the text to be matched and a vector of each candidate text in the candidate set are calculated by cosine similarity to obtain M cosine similarities, M is a positive integer greater than or equal to 2;

[0142] determine the candidate text corresponding to the maximum value of the M cosine similarities as the target text.

[0143] Optionally, the device further comprises:

[0144] The training module is configured to, before the text to be matched and the candidate text set are obtained:

[0145] obtain texts in a system log;

[0146] manually label similar texts from the texts;

[0147] splice each two similar texts in the manually labeled similar texts by using a template prepared in advance to form a training sample;

[0148] obtain output results by inputting the training sample twice into a basic model, and obtain the matching model by training the basic model according to the output results, wherein the output result corresponding to inputting one sample into the basic model once includes a punch vector corresponding to the one sample and a similarity between two texts in the one sample.

[0149] Optionally, the device further comprises:

[0150] a verification module, configured to input each sample twice into the input base model, and train the existing base model by using an optimization algorithm of the trained model, so as to obtain a verification sample in a verification set, and input the verification sample twice into the matching model to obtain two vectors of the verification sample;

[0151] a verification module, configured to input each sample twice into the input base model, and train the existing base model by using an optimization algorithm of the trained model, so as to obtain a verification sample in a verification set, and input the verification sample twice into the matching model to obtain two vectors of the verification sample;

[0152] calculate a cosine similarity according to the two vectors of the verification sample;

[0153] verify the matching model according to the value of the cosine similarity;

[0154] or

[0155] input the verification sample in the verification set into the matching model to obtain a similarity between two texts in the verification sample;

[0156] verify the matching model according to the similarity between the two texts in the sample.

[0157] Optionally, the verification module is specifically configured to:

[0158] compare the value of the cosine similarity with a threshold value to obtain a comparison result;

[0159] verify the matching model according to the comparison result.

[0160] Optionally, the device further comprises:

[0161] a screening module, configured to, before the obtaining of the to-be-matched text and the candidate text set, screen similar texts in a knowledge base to the to-be-matched text by using a text similarity algorithm in a server to obtain the candidate text set.

[0162] Please refer to Figure 3 A structure diagram of a text matching device provided in an embodiment of the present application, which can include a processor 310 and a memory 320. Optionally, the device can further include a communication interface 330 and a communication bus 340. The device corresponds to the above-mentioned Figure 1 method embodiments, and can execute Figure 1 the steps involved in the method embodiments. The specific functions of the device can be referred to the description below.

[0163] Specifically, the memory 320 is configured to store computer readable instructions.

[0164] The processor 310 is configured to process the instructions stored in the memory 320, and execute Figure 1 the steps of the method embodiments 110 to 130.

[0165] The communication interface 330 is configured to communicate signaling or data with other node devices. For example, the communication interface 330 is configured to communicate with a server or a terminal. The embodiments of the present application are not limited to the node devices described above.

[0166] The communication bus 340 is configured to realize direct connection communication among the components described above.

[0167] In the embodiments of the present application, the communication interface 330 of the device is configured to communicate signaling or data with other node devices. The memory 320 can be a high-speed RAM memory, or a non-volatile memory, for example, at least one disk memory. The memory 320 can also be at least one storage device located away from the processor described above. The memory 320 stores computer readable instructions, when the computer readable instructions are executed by the processor 310, the electronic device executes the method process described above. Figure 1 The processor 310 can be used in the device 200, and is configured to execute the functions in the embodiments of the present application. For example, the processor 310 described above can be a general processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and the embodiments of the present application are not limited thereto.

[0168] The embodiments of the present application also provide a readable storage medium, when the computer program is executed by the processor, the method process executed by the electronic device in the method embodiments as described above is executed. Figure 1 The embodiments of the present application also provide a readable storage medium, when the computer program is executed by the processor, the method process executed by the electronic device in the method embodiments as described above is executed.

[0169] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the method described above, and will not be described in detail here.

[0170] To sum up, the application provides a text matching method, device, equipment and readable storage medium, the method comprises the following steps: obtaining a to-be-matched text and a candidate text set; inputting the to-be-matched text into a matching model to obtain a processing result; and determining a target text matched with the to-be-matched text from the candidate text set according to the processing result, wherein the matching model is obtained by training a basic model according to output results of twice inputting training samples into the basic model, and the output result of once inputting one sample into the basic model comprises a punch vector corresponding to the one sample and a similarity between two texts in the one sample. The method can improve the accuracy of text matching.

[0171] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can also be implemented by other manners. The apparatus embodiments described above are only illustrative, for example, the flowcharts and block diagrams in the drawings show the possible implementation architecture, function and operation of the apparatus, method and computer program product according to the embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, program segment or part of code containing one or more executable instructions for implementing the specified logic function. It should also be noted that in some alternative implementation manners, the functions annotated in the blocks can also occur in different order from that annotated in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for executing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0172] In addition, each functional module in the embodiments of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0173] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the parts of the prior art that make contributions or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0174] The above merely provides an example of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that the logical labels and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0175] The above merely provides an example of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that the logical labels and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0176] It should be noted that, in this document, the terms such as first and second are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the processes, methods, articles or devices including a series of elements not only include those elements, but also include other elements not explicitly listed or inherent to such processes, methods, articles or devices. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.

Claims

1. A method of text matching, characterized by, The method comprises: obtaining a to-be-matched text and a candidate text set; inputting the to-be-matched text into a matching model to obtain a processing result; determining a target text matched with the to-be-matched text from the candidate text set according to the processing result, wherein the matching model is obtained by training a basic model according to output results of twice inputting training samples into the basic model, wherein the output result corresponding to one sample inputting the basic model once comprises a punch vector corresponding to the one sample and a similarity between two texts in the one sample, and the punch vector is obtained by calculating a twice exit mechanism in a training process of the training sample; before the obtaining of the to-be-matched text and the candidate text set, the method further comprises: obtaining a text in a system log; manually labeling similar texts of the text; splicing each two similar texts in the manually labeled similar texts by using a prepared template to form a training sample; obtaining output results of twice inputting the training sample into a basic model, and obtaining the matching model by training the basic model according to the output results; twice inputting a verification sample in a verification set into the matching model to obtain two vectors of the verification sample; calculating a cosine similarity according to the two vectors of the verification sample; verifying the matching model according to a value of the cosine similarity; or inputting the verification sample in the verification set into the matching model to obtain a similarity between two texts in the verification sample; and verifying the matching model according to the similarity between the two texts in the sample.

2. The method of claim 1, wherein, The processing result is a similarity between the to-be-matched text and each candidate text in the candidate text set, and the inputting of the to-be-matched text into the matching model comprises: inputting the to-be-matched text and each candidate text in the candidate text set into the matching model; The determining of the target text matched with the to-be-matched text from the candidate text set according to the processing result comprises: sorting values of the similarity between the to-be-matched text and each candidate text in the candidate text set; determining a candidate text corresponding to a maximum value of the similarity as the target text.

3. The method of claim 1, wherein the processing result is a vector of the to-be-matched text, and the determining of the target text matched with the to-be-matched text from the candidate text set according to the processing result comprises: performing cosine similarity calculation on the vector of the to-be-matched text and a vector of each candidate text in the candidate text set to obtain M cosine similarities, M being a positive integer greater than or equal to 2; determining a candidate text corresponding to a maximum value of the M cosine similarities as the target text. The verifying of the matching model according to the value of the cosine similarity comprises:

4. The method of claim 1, wherein, comparing the value of the cosine similarity with a threshold value to obtain a comparison result; verifying the matching model according to the comparison result. Before the obtaining of the to-be-matched text and the candidate text set, the method further comprises:

5. The method according to any one of claims 1 to 4, characterized in that, ​ Filtering similar texts in the knowledge base to the text to be matched by using a text similarity algorithm in the server to obtain the candidate text set.

6. An apparatus for text matching, the apparatus comprising: The method comprises the steps of: An acquisition module is configured to acquire a text to be matched and a candidate text set; An input module is configured to input the text to be matched into a matching model to obtain a processing result; An output module is configured to determine a target text matched with the text to be matched from the candidate text set according to the processing result, wherein the matching model is obtained by training a basic model according to output results of twice inputting training samples into the basic model, wherein the output result corresponding to one sample inputting the basic model once comprises a punch vector corresponding to the one sample and a similarity between two texts in the one sample, and the punch vector is obtained by calculating twice exit mechanisms in a training process of the training sample. Before the acquisition module acquires the text to be matched and the candidate text set, the method further comprises the steps of: acquiring a text in a system log; manually labeling similar texts of the text; splicing each two similar texts in the manually labeled similar texts by using a template prepared in advance to form a training sample; obtaining output results by twice inputting the training sample into a basic model, and obtaining the matching model by training the basic model according to the output results; obtaining two vectors of a verification sample in a verification set by twice inputting the verification sample into the matching model; calculating a cosine similarity according to the two vectors of the verification sample; verifying the matching model according to a value of the cosine similarity; or inputting the verification sample in the verification set into the matching model to obtain a similarity between two texts in the verification sample; and verifying the matching model according to the similarity between the two texts in the sample.

7. An apparatus for text matching, the apparatus comprising: The method comprises the steps of: A memory and a processor, wherein the memory stores computer readable instructions, and when the computer readable instructions are executed by the processor, the steps in the method according to any one of claims 1 to 5 are executed.

8. A computer-readable storage medium, characterized in that, The computer program, when executed on a computer, causes the computer to execute the method according to any one of claims 1 to 5. ​

Citation Information

Patent Citations

  • Text matching method and device, storage medium and computer equipment

    CN113420128A