Text matching model training method, text matching method and device

A training sample set is generated through multiple text matching models and robust filtering rules, and combined with data distillation technology, the text matching model is trained, which solves the deviation problem of the text matching model in the existing technology under complex language phenomena and diverse scenarios, and improves to improve matching accuracy and robustness.

CN118643337APending Publication Date: 2024-09-13BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410804389.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-20
Publication Date
2024-09-13

AI Technical Summary

Technical Problem

Existing text matching models have biases in handling complex language phenomena and diverse scenarios, making it difficult to effectively identify subtle differences between query text and candidate text, resulting in insufficient matching accuracy and robustness.

Method used

By inputting initial sample pairs into multiple text matching models, multiple semantic similarities are obtained, a training sample set is generated based on robust filtering rules, and combined with data distillation technology, the target text matching model is trained to enhance its robustness and generalization. ability.

Benefits of technology

It reduces the bias caused by a single model, ensures the diversity and complexity of the training sample set, improves the performance and robustness of the text matching model in various scenarios, and improves the matching accuracy and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118643337A
    Figure CN118643337A
Patent Text Reader

Abstract

The invention provides a text matching model training method, a text matching method and a text matching device, and relates to the field of data processing, in particular to the field of natural language processing and intelligent searching. According to the specific implementation scheme, initial sample pairs are input into a plurality of first text matching models to obtain first semantic similarities of the initial sample pairs output by the first text matching models respectively, and each initial sample pair comprises a query text sample and a candidate text sample; determining candidate sample pairs from the initial sample pairs according to the first semantic similarity; filtering the candidate sample pair based on a preset robustness filtering rule, and generating a training sample set based on the filtered candidate sample pair; and training the second text matching model based on the training sample set to obtain a target text matching model generated after training is completed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing, in particular to the fields of natural language processing and intelligent search, and specifically to a text matching model training method, a text matching method and a device thereof. Background Art

[0002] Text matching, as one of the core technologies of Natural Language Processing (NLP), plays a vital role. From daily search engine applications to professional question-answering systems, text matching technology is used everywhere. Its purpose is to identify and understand the subtle differences in query texts, so as to find the most relevant and valuable content in massive amounts of information. Summary of the invention

[0003] The present invention provides a text matching model training method, a text matching method and a device thereof.

[0004] According to one aspect of the present disclosure, a method for training a text matching model is provided, wherein initial sample pairs are respectively input into a plurality of first text matching models to obtain first semantic similarities of the initial sample pairs output by the plurality of first text matching models, wherein the initial sample pairs include a query text sample and a candidate text sample; candidate sample pairs are determined from the initial sample pairs according to the first semantic similarities; the candidate sample pairs are filtered based on a preset robustness filtering rule, and a training sample set is generated based on the filtered candidate sample pairs; a second text matching model is trained based on the training sample set, and a target text matching model generated after the training is completed is obtained.

[0005] The present application can reduce the deviation caused by a single model by using multiple first text matching models, thereby obtaining candidate sample pairs, and filtering the candidate sample pairs based on preset robustness filtering rules, aiming to ensure the diversity of the training sample set and cover various complex language phenomena, so that the final trained model can better cope with text matching in various scenarios.

[0006] According to another aspect of the present disclosure, a text matching method is provided, including: obtaining a query text input by a user; obtaining a plurality of candidate texts to be matched; inputting the query text and the candidate texts into a trained target text matching model, and obtaining a third similarity between the query text output by the text matching model and each candidate text; determining a target text corresponding to the query text from the candidate texts according to the third similarity; wherein the target text matching model is generated by training using the training method for the text matching model introduced above.

[0007] According to another aspect of the present disclosure, a training device for a text matching model is provided, comprising: an acquisition module, used to input initial sample pairs into multiple first text matching models respectively to obtain first semantic similarities of the initial sample pairs output by the multiple first text matching models respectively, wherein the initial sample pairs include a query text sample and a candidate text sample; a determination module, used to determine the candidate sample pairs from the initial sample pairs according to the first semantic similarities; a filtering module, used to filter the candidate sample pairs based on a preset robustness filtering rule, and generate a training sample set based on the filtered candidate sample pairs; and a training module, used to train the second text matching model based on the training sample set, and obtain a target text matching model generated after the training is completed.

[0008] According to another aspect of the present disclosure, a text matching device is provided, including: a first acquisition module, used to acquire a query text input by a user; a second acquisition module, used to acquire a plurality of candidate texts to be matched; a third acquisition module, used to input the query text and the candidate text into a trained target text matching model, and acquire a third similarity between the query text output by the text matching model and each candidate text; a text determination module, used to determine a target text corresponding to the query text from the candidate texts according to the third similarity; wherein the target text matching model is generated by training using the text matching model training device introduced above.

[0009] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned text matching model training method and text matching method.

[0010] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the above-mentioned text matching model training method and text matching method.

[0011] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements the above-mentioned text matching model training method and text matching method when executed by a processor.

[0012] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0014] Figure 1 It is a schematic diagram of a method for training a text matching model according to an exemplary embodiment of the present disclosure.

[0015] Figure 2 It is an exemplary schematic diagram of inputting each initial sample pair into a plurality of first text matching models respectively according to an exemplary embodiment of the present disclosure.

[0016] Figure 3 It is a schematic diagram of a method for training a text matching model according to an exemplary embodiment of the present disclosure.

[0017] Figure 4 It is a schematic diagram of a method for obtaining a similarity sequence according to an exemplary embodiment of the present disclosure.

[0018] Figure 5 It is a schematic diagram of a method for training a text matching model according to an exemplary embodiment of the present disclosure.

[0019] Figure 6 is a schematic diagram of a text matching method according to an exemplary embodiment of the present disclosure.

[0020] Figure 7 is a schematic diagram of a training device for a text matching model according to an exemplary embodiment of the present disclosure.

[0021] Figure 8 is a schematic diagram of a text matching device according to an exemplary embodiment of the present disclosure.

[0022] Fig. 9 is a schematic diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0024] Figure 1 is a schematic diagram of a text matching model training method shown in this application, such as Figure 1 As shown, the training method of the text matching model includes the following steps:

[0025] S101: Inputting initial sample pairs into a plurality of first text matching models respectively to obtain first semantic similarities of the initial sample pairs outputted by the plurality of first text matching models respectively.

[0026] In this application, a plurality of initial sample pairs are set, and each initial sample pair includes a query text sample and a candidate text sample.

[0027] Preferably, the multiple first text matching models adopt different text matching models, such as a bag of words (BoW) model, a term frequency-inverse document frequency (TF-IDF) model, a pre-trained model based on the Transformer architecture (Bidirectional Encoder Representations from Transformers, BERT), and other models.

[0028] Figure 2 is an exemplary schematic diagram of the present application showing how each initial sample pair is input into a plurality of first text matching models respectively, such as Figure 2 As shown, taking N first text matching models as an example, each initial sample pair is input into the N first text matching models respectively, and the first semantic similarity of each initial sample pair output by the N first text matching models is obtained. It is not difficult to understand that one initial sample pair eventually corresponds to N first semantic similarities.

[0029] S102: Determine candidate sample pairs from the initial sample pairs according to the first semantic similarity.

[0030] In order to find initial sample pairs with more difficult text matching as candidate sample pairs, in the present application, for any initial sample pair, multiple first semantic similarities corresponding to the initial sample pair are compared. If the differences between the multiple first semantic similarities are large, the initial sample pair is used as one of the candidate sample pairs.

[0031] S103, filtering the candidate sample pairs based on a preset robustness filtering rule, and generating a training sample set based on the filtered candidate sample pairs.

[0032] Among them, the robustness filtering rules are set according to various robustness issues in text matching scenarios, which will be introduced in detail below.

[0033] S104: Train the second text matching model based on the training sample set, and obtain a target text matching model generated after the training is completed.

[0034] The second text matching model may be the same as or different from the first text matching model, and this application does not limit this.

[0035] After the training sample set is determined, the second text matching model is trained based on the training sample set, and a target text matching model generated after the training is completed is obtained.

[0036] The embodiment of the present application proposes a method for training a text matching model, by respectively inputting an initial sample pair into multiple first text matching models to obtain a first semantic similarity of the initial sample pairs output by each of the multiple first text matching models, wherein the initial sample pair includes a query text sample and a candidate text sample; determining a candidate sample pair from the initial sample pair according to the first semantic similarity; filtering the candidate sample pairs based on a preset robustness filtering rule, and generating a training sample set based on the filtered candidate sample pairs; training a second text matching model based on the training sample set, and obtaining a target text matching model generated after the training is completed. The present application can reduce the deviation caused by a single model by using multiple first text matching models, thereby obtaining candidate sample pairs, and filtering the candidate sample pairs based on preset robustness filtering rules, aiming to ensure the diversity of the training sample set, covering various complex language phenomena, so that the model finally trained can better cope with text matching in various scenarios.

[0037] Furthermore, in the present application, before training the text matching model, it is necessary to determine the robustness problem category in the text matching scenario; and generate robustness filtering rules corresponding to each robustness problem category according to the robustness problem category. The robustness filtering rules are used to filter out candidate sample pairs that are truly difficult to match according to the robustness problem category, that is, to filter out candidate sample pairs that affect the robustness of the target text matching model finally trained, aiming to ensure the diversity of the training sample set, covering various complex language phenomena, so that the finally trained model can better cope with text matching in various scenarios.

[0038] Exemplarily, the robustness problem categories may include the following categories:

[0039] 1. The main entity escape category.

[0040] Main entity escape refers to whether the text matching model can recognize when the entities contained in the query and the candidate text are different.

[0041] For example: the query is "Beijing weather"; and the candidate text uses "capital" to refer to Beijing. A high-quality text matching model should be able to recognize that "Beijing" and "capital" refer to the same entity.

[0042] 2. Missing word category.

[0043] Word loss means whether the text matching model can identify when important semantic words are lost in the query compared to the candidate text.

[0044] For example: the query is "the best restaurant"; the candidate text uses "restaurant". The former contains the evaluation of "the best". If the text matching model can identify this, it can give a more accurate match during matching.

[0045] 3. Requirement difference category.

[0046] Requirement difference means whether the text matching model can identify when the specific requirements are different although the query and the candidate text entities are the same.

[0047] For example: the query is "Beijing weather forecast", and the candidate text is "Beijing tourist attractions". Although both contain "Beijing", one is asking about the weather and the other is asking about tourist information. The model should be able to distinguish these two different requirements.

[0048] 4. Word order difference category.

[0049] Word order difference means whether the text matching model can identify when the semantic meaning is different due to the different front-back word orders when there are multiple entities in the query and the candidate text.

[0050] For example: the query is "the dog bites the man"; the candidate text is "the man bites the dog". Although both contain the same entities "dog" and "man", due to the different order of the entities, the meaning of the sentence is completely opposite.

[0051] 5. Negative antonym category.

[0052] Negative antonym means whether the text matching model can identify when the query and the candidate text have opposite meanings.

[0053] For example: the query is "don't like to eat apples"; the candidate text is "like to eat apples". Although both mention "apples", due to the negative effect of the word "don't", the meanings of the two sentences are completely opposite.

[0054] Figure 3 It is a schematic diagram of a training method of a text matching model shown in the present application. As Figure 3 shown, the training method of this text matching model includes the following steps:

[0055] S301, input the initial sample pairs into multiple first text matching models respectively to obtain the first semantic similarities of the initial sample pairs output by each of the multiple first text matching models.

[0056] Each initial sample pair includes a query text sample and a candidate text sample.

[0057] Preferably, the multiple first text matching models adopt different text matching models.

[0058] S302: Determine candidate sample pairs from the initial sample pairs according to the first semantic similarity.

[0059] As a feasible method, multiple first semantic similarities corresponding to the initial sample pair are compared to obtain the maximum first semantic similarity and the minimum first semantic similarity corresponding to the initial sample pair; the maximum first semantic similarity and the minimum first semantic similarity corresponding to the initial sample pair are subtracted to obtain the first difference corresponding to the initial sample pair; if the first difference is greater than a first preset threshold, the initial sample pair is used as a candidate sample pair.

[0060] For example, if a total of 5 first text matching models are set, for the initial sample pair A1, the first semantic similarities output by the 5 first text matching models are 0.75, 0.80, 0.90, 0.70, and 0.85, respectively, then the maximum first semantic similarity corresponding to the initial sample pair A1 is 0.90, and the minimum first semantic similarity corresponding to the initial sample pair A1 is 0.70. Then the first difference corresponding to the initial sample pair A1 is 0.90-0.70=0.20, then 0.20 is compared with the preset first preset threshold, and if 0.20 is greater than the first preset threshold, the initial sample pair A1 is used as a candidate sample pair.

[0061] As another achievable method, all initial sample pairs are divided into multiple initial sample pair sets according to the query text sample; the similarity sequence corresponding to the initial sample pair set under each first text matching model is obtained according to the first semantic similarity, wherein the similarity sequence is sorted in descending order according to the first semantic similarity; the sequence number of the initial sample pair in its corresponding similarity sequence is obtained; and the candidate sample pair is determined from the initial sample pairs according to the sequence number of the initial sample pair.

[0062] For ease of understanding, Figure 4 is a schematic diagram of a method for obtaining a similarity sequence shown in the present application, such as Figure 4 As shown, all initial sample pair sets containing query text sample A are grouped together to form initial sample pair set A, and all initial sample pair sets containing query text sample B are grouped together to form initial sample pair set B, and so on, until all initial sample pair sets are obtained.

[0063] It is not difficult to understand that, since the present application sets multiple first text matching models, each first text matching model outputs the first semantic similarity of each initial sample pair in the initial sample pair set. In the present application, for any initial sample pair set, each first text matching model is used as a benchmark to sort according to the first semantic similarity to obtain multiple similarity sequences. For example, if a total of 5 first text matching models are set, the initial sample pair set A corresponds to 5 similarity sequences, the initial sample pair set B corresponds to 5 similarity sequences, and so on, each initial sample pair set corresponds to 5 similarity sequences.

[0064] After obtaining the similarity sequence corresponding to the initial sample pair set, each initial sample pair in the initial sample pair set is serially numbered according to the sequence position of the first semantic similarity. It is not difficult to understand that, if the initial sample pair set A contains the initial sample pair A1, since the initial sample pair set A corresponds to 5 similarity sequences, the initial sample pair A1 also corresponds to 5 sequence numbers accordingly.

[0065] Optionally, after obtaining the sequence number of each initial sample pair, obtain the maximum sequence number and the minimum sequence number of each initial sample pair; perform a difference calculation on the maximum sequence number and the minimum sequence number corresponding to the initial sample pair to obtain a second difference corresponding to the initial sample pair; if the second difference is greater than a second preset threshold, use the initial sample pair as a candidate sample pair.

[0066] Optionally, after obtaining the sequence number of each initial sample pair, obtain the sequence number standard deviation of each initial sample pair; if the sequence number standard deviation is greater than a third preset threshold, the initial sample pair is used as a candidate sample pair.

[0067] The above-mentioned multiple methods for determining candidate sample pairs from initial sample pairs can be selected or combined according to actual conditions and are not limited here. In this way, by using multiple first text matching models, the deviation caused by a single model can be reduced, and sample pairs that are truly difficult to match can be obtained for labeling.

[0068] S303: Filter the candidate sample pairs based on a preset robustness filtering rule to obtain sample pairs to be labeled after filtering.

[0069] S304: label the sample pairs to be labeled to obtain generated labeled sample pairs.

[0070] Optionally, when labeling, each pair of samples to be labeled may be labeled with a positive sample label or a negative sample label.

[0071] Optionally, when labeling, in addition to labeling each pair of samples to be labeled with a positive sample label or a negative sample label, similarity score labeling may also be performed.

[0072] S305: Perform data enhancement on the labeled sample pairs to obtain a generated training sample set.

[0073] By fixing the core words and modifying the non-core words, data enhancement is performed on the labeled sample pairs to obtain a large number of training samples, thereby improving the stability of the target text matching model obtained by the final training.

[0074] S306: Train the second text matching model based on the training sample set, and obtain a target text matching model generated after the training is completed.

[0075] In the process of training the second text matching model based on the training sample set, a training strategy combining the Pai Rwi Se algorithm and the negative example classification optimization algorithm is adopted.

[0076] Among them, the Pai Rwise algorithm refers to training two groups of samples that are difficult to distinguish in the same group, and allowing the model to learn the difference between the positive and negative samples by widening the score gap between the positive and negative samples, thereby enhancing robustness.

[0077] The negative example classification optimization algorithm means that when there are multiple negative samples corresponding to the query text, multiple negative samples are also scored at a more fine-grained level, so that the model can learn the differences between multiple negative samples and enhance robustness.

[0078] In the embodiment of the present application, by using multiple first text matching models, the deviation caused by a single model can be reduced, sample pairs that are truly difficult to match are obtained for annotation, and then the annotated sample pairs are data enhanced to generate a training sample set, thereby reducing the dependence on annotated data, so that the generated target text matching model can learn more diverse data features, so that the generated target text matching model can maintain good performance even when there are slight changes or deviations in the input data, thereby improving the generalization ability and robustness of the generated target text matching model.

[0079] Figure 5 is a schematic diagram of a text matching model training method shown in this application, such as Figure 5 As shown, the training method of the text matching model includes the following steps:

[0080] S501: Inputting initial sample pairs into a plurality of first text matching models respectively to obtain first semantic similarities of the initial sample pairs outputted by the plurality of first text matching models respectively.

[0081] Each initial sample pair includes a query text sample and a candidate text sample.

[0082] S502: Determine candidate sample pairs from the initial sample pairs according to the first semantic similarity.

[0083] S503: Filter the candidate sample pairs based on a preset robustness filtering rule to obtain sample pairs to be labeled after filtering.

[0084] S504: label the sample pairs to be labeled to obtain generated labeled sample pairs.

[0085] S505: Perform data enhancement on the labeled sample pairs to obtain a generated training sample set.

[0086] Regarding the specific implementation of steps S501 to S505, reference may be made to the specific introduction of the relevant parts in the above embodiments, which will not be elaborated here.

[0087] S506, dividing the training sample set to obtain a plurality of training sample subsets obtained after the division.

[0088] Since different matching models have different focuses, such as the Best Matching 25 (BM25) is good at literal matching, and Machine Reading Comprehension (MRC) is good at paragraph-level reading comprehension matching, this application intends to use data distillation to compare and learn the capabilities of different models, and integrate multiple capabilities into the same model, thereby improving the model's ability to capture keywords.

[0089] Based on the above ideas, in this application, the second text matching model to be trained based on the training sample set includes multiple teacher models and one student model.

[0090] Before model training is performed based on the training sample set, the training sample set is first divided to obtain multiple training sample subsets obtained after the division. Each training sample subset corresponds to a teacher model.

[0091] S507, inputting the plurality of training sample subsets into their respective corresponding teacher models to pre-train the teacher models.

[0092] S508, after the pre-training of the teacher model is completed, multiple training sample subsets are respectively input into the corresponding teacher models to obtain the second semantic similarity of each training sample output by the teacher model.

[0093] S509: Train the student model according to the training sample set and the second semantic similarity corresponding to each training sample in the training sample set, and use the trained student model as the target text matching model.

[0094] In an embodiment of the present application, after obtaining the training sample set, the idea of ​​data distillation is introduced. Through data distillation, the student model can absorb knowledge from different teacher models and combine the advantages of different models to improve the performance of the target text matching model finally generated.

[0095] Figure 6 is a schematic diagram of a text matching method shown in this application, such as Figure 6 As shown, the text matching method comprises the following steps:

[0096] S601, obtaining a query text input by a user.

[0097] S602: Acquire multiple candidate texts to be matched.

[0098] S603: Input the query text and the candidate texts into the trained target text matching model, and obtain the third similarity between the query text output by the text matching model and each candidate text.

[0099] The target text matching model is generated by training using the text matching model training method described in the above embodiment.

[0100] S604: Determine a target text corresponding to the query text from the candidate texts according to the third similarity.

[0101] The embodiment of the present application proposes a text matching method, which performs text matching by inputting query text and candidate text into a trained target text matching model. Since the target text matching model has good robustness, the accuracy of text matching can be improved.

[0102] Figure 7 is a schematic diagram of a training device for a text matching model shown in the present application, such as Figure 7 As shown, the text matching model training device 700 includes an acquisition module 701, a determination module 702, a filtering module 703 and a training module 704, wherein:

[0103] The acquisition module 701 is used to input each initial sample pair into multiple first text matching models to obtain the first semantic similarity of the initial sample pairs output by the multiple first text matching models, wherein each initial sample pair includes a query text sample and a candidate text sample.

[0104] The determination module 702 is configured to determine candidate sample pairs from the initial sample pairs according to the first semantic similarity.

[0105] The filtering module 703 is used to filter the candidate sample pairs based on a preset robustness filtering rule, and generate a training sample set based on the filtered candidate sample pairs.

[0106] The training module 704 is used to train the second text matching model based on the training sample set and obtain the target text matching model generated after the training is completed.

[0107] The device can reduce the deviation caused by a single model by using multiple first text matching models, thereby obtaining candidate sample pairs, and filtering the candidate sample pairs based on preset robustness filtering rules, aiming to ensure the diversity of the training sample set and cover various complex language phenomena, so that the finally trained model can better cope with text matching in various scenarios.

[0108] Furthermore, the filtering module 703 is also used to: filter the candidate sample pairs based on the preset robustness filtering rules to obtain the sample pairs to be labeled after filtering; label the sample pairs to be labeled to obtain the generated labeled sample pairs; perform data enhancement on the labeled sample pairs to obtain the generated training sample set.

[0109] Furthermore, the determination module 702 is also used to: compare multiple first semantic similarities corresponding to the initial sample pair to obtain the maximum first semantic similarity and the minimum first semantic similarity corresponding to the initial sample pair; perform difference calculation on the maximum first semantic similarity and the minimum first semantic similarity corresponding to the initial sample pair to obtain the first difference corresponding to the initial sample pair; in response to the first difference being greater than a first preset threshold, use the initial sample pair as a candidate sample pair.

[0110] Furthermore, the determination module 702 is also used to: divide all initial sample pairs into multiple initial sample pair sets according to the query text sample; obtain the similarity sequence corresponding to the initial sample pair set under each first text matching model according to the first semantic similarity, wherein the similarity sequence is sorted in descending order according to the first semantic similarity; obtain the sequence number of each initial sample pair in its corresponding similarity sequence; and determine the candidate sample pair from the initial sample pairs according to the sequence number of each initial sample pair.

[0111] Furthermore, the determination module 702 is also used to: obtain the maximum value and the minimum value of the sequence number of each initial sample pair; perform a difference calculation on the maximum value and the minimum value of the sequence number corresponding to the initial sample pair to obtain a second difference value corresponding to the initial sample pair; in response to the second difference value being greater than a second preset threshold value, use the initial sample pair as a candidate sample pair.

[0112] Furthermore, the determination module 702 is further configured to: obtain a standard deviation of the sequence number of each initial sample pair; and in response to the standard deviation of the sequence number being greater than a third preset threshold, use the initial sample pair as a candidate sample pair.

[0113] Furthermore, the second text matching model includes multiple teacher models and one student model, and the training module 704 is also used to: divide the training sample set to obtain multiple training sample subsets obtained after the division; input the multiple training sample subsets into their corresponding teacher models to pre-train the teacher models; after the pre-training of the teacher model is completed, input the multiple training sample subsets into their corresponding teacher models to obtain the second semantic similarity of each training sample output by the teacher model; train the student model according to the training sample set and the second semantic similarity corresponding to each training sample in the training sample set, and use the trained student model as the target text matching model.

[0114] Furthermore, the text matching model training device 700 also includes a generation module, which is used to: determine the robustness problem category in the text matching scenario; and generate robustness filtering rules corresponding to each robustness problem category according to the robustness problem category.

[0115] Furthermore, the training module 704 adopts a training strategy combining a pairwise algorithm and a negative example classification optimization algorithm during the training of the second text matching model based on the training sample set.

[0116] Figure 8 is a schematic diagram of a text matching device shown in the present application, such as Figure 8 As shown, the text matching device 800 includes a first acquisition module 801, a second acquisition module 802, a third acquisition module 803 and a text determination module 804, wherein:

[0117] The first acquisition module 801 is used to acquire the query text input by the user.

[0118] The second acquisition module 802 is used to acquire multiple candidate texts to be matched.

[0119] The third acquisition module 803 is used to input the query text and the candidate text into the trained target text matching model, and obtain the third similarity between the query text output by the text matching model and each candidate text.

[0120] The text determination module 804 is used to determine the target text corresponding to the query text from the candidate texts according to the third similarity.

[0121] The target text matching model is generated by training using the training device for the text matching model introduced above.

[0122] This device performs text matching by inputting the query text and the candidate text into a trained target text matching model. Since the target text matching model has good robustness, the accuracy of text matching can be improved.

[0123] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards.

[0124] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0125] Fig. 9 A schematic block diagram of an example electronic device 900 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0126] like Fig. 9 As shown, the device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0127] A number of components in the device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0128] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above, such as the training method and text matching method of the text matching model. For example, in some embodiments, the training method and text matching method of the text matching model may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the training method and text matching method of the text matching model described above may be executed. Alternatively, in other embodiments, the computing unit 901 may be configured to execute the text matching model training method and the text matching method in any other appropriate manner (for example, by means of firmware).

[0129] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs, which may be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general programmable processor, which may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0130] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0131] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0132] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0133] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0134] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0135] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0136] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for training a text matching model, wherein: The method comprises: Inputting the initial sample pair into a plurality of first text matching models respectively to obtain the first semantic similarity of the initial sample pair output by each of the plurality of first text matching models, wherein the initial sample pair includes a query text sample and a candidate text sample; Determine a candidate sample pair from the initial sample pairs according to the first semantic similarity; Filtering the candidate sample pairs based on a preset robustness filtering rule, and generating a training sample set based on the filtered candidate sample pairs; The second text matching model is trained based on the training sample set, and a target text matching model generated after the training is completed is obtained.

2. The method according to claim 1, wherein: The filtering of the candidate sample pairs based on a preset robustness filtering rule and generating a training sample set based on the filtered candidate sample pairs includes: Filtering the candidate sample pairs based on a preset robustness filtering rule to obtain sample pairs to be labeled after filtering; Annotating the to-be-annotated sample pairs to obtain generated annotated sample pairs; Data augmentation is performed on the labeled sample pairs to obtain a generated training sample set.

3. The method according to claim 2, wherein: The step of determining a candidate sample pair from the initial sample pair according to the first semantic similarity includes: Comparing a plurality of the first semantic similarities corresponding to the initial sample pair, and obtaining a maximum first semantic similarity value and a minimum first semantic similarity value corresponding to the initial sample pair; Performing a difference calculation on the first maximum semantic similarity value and the first minimum semantic similarity value corresponding to the initial sample pair to obtain a first difference value corresponding to the initial sample pair; In response to the first difference being greater than a first preset threshold, the initial sample pair is used as a candidate sample pair.

4. The method according to claim 2, wherein: The step of determining a candidate sample pair from the initial sample pair according to the first semantic similarity includes: Divide all the initial sample pairs into a plurality of initial sample pair sets according to the query text sample; According to the first semantic similarity, obtain a similarity sequence corresponding to the initial sample pair set under each of the first text matching models, wherein the similarity sequence is sorted in descending order according to the first semantic similarity; Obtaining a sequence number of the initial sample pair in its corresponding similarity sequence; Determine candidate sample pairs from the initial sample pairs according to the sequence numbers of the initial sample pairs.

5. The method according to claim 4, wherein: The step of determining a candidate sample pair from the initial sample pair according to the sequence number of the initial sample pair comprises: Obtaining the maximum value and the minimum value of the sequence number of the initial sample pair; Performing a difference calculation on the maximum value of the sequence number and the minimum value of the sequence number corresponding to the initial sample pair to obtain a second difference value corresponding to the initial sample pair; In response to the second difference being greater than a second preset threshold, the initial sample pair is used as a candidate sample pair.

6. The method according to claim 4, wherein: The step of determining a candidate sample pair from the initial sample pair according to the sequence number of the initial sample pair comprises: Obtaining a standard deviation of the sequence number of the initial sample pair; In response to the standard deviation of the sequence numbers being greater than a third preset threshold, the initial sample pair is used as a candidate sample pair.

7. The method according to any one of claims 1 to 6, wherein: The second text matching model includes a plurality of teacher models and a student model, and the training of the second text matching model based on the training sample set and obtaining a target text matching model generated after the training is completed include: Dividing the training sample set to obtain multiple training sample subsets obtained after the division; Inputting the plurality of training sample subsets into respective corresponding teacher models to pre-train the teacher models; After the pre-training of the teacher model is completed, the plurality of training sample subsets are respectively input into the corresponding teacher models to obtain a second semantic similarity of each training sample output by the teacher model; The student model is trained according to the training sample set and the second semantic similarity corresponding to each training sample in the training sample set, and the trained student model is used as a target text matching model.

8. The method according to claim 1, wherein: The method further comprises: Identify the class of robustness issues in text matching scenarios; The robustness filtering rules corresponding to each of the robustness problem categories are generated respectively according to the robustness problem categories.

9. The method according to claim 7, wherein: The method further comprises: In the process of training the second text matching model based on the training sample set, a training strategy combining a pairwise algorithm and a negative example classification optimization algorithm is adopted.

10. A text matching method, wherein: The method comprises: Get the query text entered by the user; Get multiple candidate texts to be matched; Inputting the query text and the candidate text into a trained target text matching model, and obtaining a third similarity between the query text and each of the candidate texts output by the text matching model; Determining a target text corresponding to the query text from the candidate texts according to the third similarity; The target text matching model is generated by training using the method described in any one of claims 1 to 9.

11. A training device for a text matching model, wherein: The device comprises: An acquisition module, used for inputting the initial sample pair into a plurality of first text matching models respectively to obtain the first semantic similarity of the initial sample pair outputted by the plurality of first text matching models respectively, wherein the initial sample pair comprises a query text sample and a candidate text sample; A determination module, configured to determine a candidate sample pair from the initial sample pair according to the first semantic similarity; A filtering module, used to filter the candidate sample pairs based on a preset robustness filtering rule, and generate a training sample set based on the filtered candidate sample pairs; The training module is used to train the second text matching model based on the training sample set and obtain the target text matching model generated after the training is completed.

12. The device according to claim 11, wherein: The filtering module is also used for: Filtering the candidate sample pairs based on a preset robustness filtering rule to obtain sample pairs to be labeled after filtering; Annotating the to-be-annotated sample pairs to obtain generated annotated sample pairs; Data augmentation is performed on the labeled sample pairs to obtain a generated training sample set.

13. The device according to claim 12, wherein: The determining module is further used for: Comparing a plurality of the first semantic similarities corresponding to the initial sample pair, and obtaining a maximum first semantic similarity value and a minimum first semantic similarity value corresponding to the initial sample pair; Performing a difference calculation on the first maximum semantic similarity value and the first minimum semantic similarity value corresponding to the initial sample pair to obtain a first difference value corresponding to the initial sample pair; In response to the first difference being greater than a first preset threshold, the initial sample pair is used as a candidate sample pair.

14. The device according to claim 12, wherein: The determining module is further used for: Divide all the initial sample pairs into a plurality of initial sample pair sets according to the query text sample; According to the first semantic similarity, obtain a similarity sequence corresponding to the initial sample pair set under each of the first text matching models, wherein the similarity sequence is sorted in descending order according to the first semantic similarity; Obtaining a sequence number of the initial sample pair in its corresponding similarity sequence; Determine candidate sample pairs from the initial sample pairs according to the sequence numbers of the initial sample pairs.

15. The device according to claim 14, wherein: The determining module is further used for: Obtaining the maximum value and the minimum value of the sequence number of the initial sample pair; Performing a difference calculation on the maximum value of the sequence number and the minimum value of the sequence number corresponding to the initial sample pair to obtain a second difference value corresponding to the initial sample pair; In response to the second difference being greater than a second preset threshold, the initial sample pair is used as a candidate sample pair.

16. The device according to claim 14, wherein: The determining module is further used for: Obtaining a standard deviation of the sequence number of each of the initial sample pairs; In response to the standard deviation of the sequence numbers being greater than a third preset threshold, the initial sample pair is used as a candidate sample pair.

17. The device according to any one of claims 11 to 16, wherein: The second text matching model includes multiple teacher models and one student model, and the training module is further used for: Dividing the training sample set to obtain multiple training sample subsets obtained after the division; Inputting the plurality of training sample subsets into respective corresponding teacher models to pre-train the teacher models; After the pre-training of the teacher model is completed, the plurality of training sample subsets are respectively input into the corresponding teacher models to obtain a second semantic similarity of each training sample output by the teacher model; The student model is trained according to the training sample set and the second semantic similarity corresponding to each training sample in the training sample set, and the trained student model is used as a target text matching model.

18. The device according to claim 11, wherein The device further comprises a generating module, wherein the generating module is configured to: Identify the class of robustness issues in text matching scenarios; The robustness filtering rules corresponding to each of the robustness problem categories are generated respectively according to the robustness problem categories.

19. The device according to claim 17, wherein: The training module adopts a training strategy combining a pairwise algorithm and a negative example classification optimization algorithm during the training of the second text matching model based on the training sample set.

20. A text matching device, wherein: The device comprises: A first acquisition module is used to acquire a query text input by a user; A second acquisition module is used to acquire multiple candidate texts to be matched; A third acquisition module, used for inputting the query text and the candidate text into a trained target text matching model, and acquiring a third similarity between the query text and each of the candidate texts output by the text matching model; A text determination module, configured to determine a target text corresponding to the query text from the candidate texts according to the third similarity; Wherein, the target text matching model is generated by training using the device described in any one of claims 11-19.

21. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 9 or claim 10.

22. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 9 or claim 10.

23. A computer program product comprising a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9 or claim 10.