Text matching model training method, device and equipment

By performing noise enhancement processing and fine-tuning of sample sets corresponding to semantic scenes on the AI ​​model, combined with the correlation prompt text, the robustness and generalization of the text matching model are improved, and the text matching model in the existing technology is solved in a variety of ways. The problem of insufficient prediction ability in semantic scenarios.

CN119250227APending Publication Date: 2025-01-03ZHONGKE DINGFU BEIJING TECH DEV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411301417.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

The existing text matching model fine-tuning process based on AI large model cannot take into account both robustness and generalization. Although noise enhancement processing improves robustness, it leads to poor generalization, especially in text matching in multiple semantic scenarios. Poor prediction ability.

Method used

By obtaining multiple sample sets that have been processed through noise enhancement and corresponding to multiple semantic scenarios, we determine the prompt text that has correlation between the samples in each sample set, and combine it into the second sample to fine-tune the pretrained model to improve The robustness and generalization of text matching models.

Benefits of technology

It realizes better generalization and robustness of text matching models in multiple semantic scenarios, improves the accuracy of text matching prediction, and solves the problem that both robustness and generalization in the prior art are difficult to take into account.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119250227A_ABST
    Figure CN119250227A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of large model training, in particular to a text matching model training method, device and equipment, and the method comprises the steps: obtaining a plurality of first sample sets subjected to noise enhancement processing; determining a first text of each first sample in each first sample set; combining the first sample and the corresponding first text into a second sample; performing fine tuning on the pre-training model through a plurality of second samples to obtain a text matching model; in conclusion, the robustness of the text matching model can be improved by using the first sample set subjected to noise enhancement processing; according to the method and the device, the generalization of the text matching model can be improved by using the plurality of first sample sets corresponding to the plurality of semantic scenes and determining the first text with relevance for the samples in the plurality of first sample sets; therefore, the training method of the text matching model provided by the invention gives consideration to the robustness and generalization of the text matching model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of large model training technology, and in particular to a training method, device and equipment for a text matching model. Background Art

[0002] In the prior art, a text matching model is usually used to perform text matching tasks. The text matching model is obtained by sequentially pre-training and fine-tuning an AI (Artificial Intelligence) large model.

[0003] In order to improve the robustness, in the process of fine-tuning the pre-trained model after pre-training, the samples in the sample set can be subjected to noise enhancement processing, so as to improve the robustness of the fine-tuned text matching model; in actual implementation, although this processing can indeed improve the robustness of the text matching model, it causes the generalization of the text matching model to deteriorate when performing text execution tasks in different semantic scenarios, and ultimately leads to the poor accuracy of the text matching prediction results obtained by the text matching model.

[0004] In summary, the existing fine-tuning process of text matching models based on large AI models has the problem of being unable to balance robustness and generalization. Summary of the invention

[0005] In view of this, the purpose of this application is to provide a training method, device and equipment for a text matching model to solve the problem that the existing fine-tuning process of the text matching model based on the large AI model cannot take into account both robustness and generalization.

[0006] In a first aspect, the present application provides a method for training a text matching model, the method comprising:

[0007] Acquire a plurality of first sample sets that have undergone noise enhancement processing;

[0008] Wherein, the plurality of the first sample sets correspond one to one to the plurality of semantic scenes;

[0009] Determine the first text of each first sample in each of the first sample sets;

[0010] The first text is a prompt text for guiding the pre-trained model to predict the text matching relationship between at least two input texts included in each of the first samples; the first texts of the first samples in different first sample sets are associated with each other;

[0011] combining the first sample and the corresponding first text into a second sample;

[0012] The pre-trained model is fine-tuned using a plurality of the second samples to obtain a text matching model.

[0013] In a second aspect, the present application provides a training device for a text matching model, the device comprising: a sample acquisition module, a text determination module and a training module;

[0014] The sample acquisition module is used to acquire a plurality of first sample sets that have been subjected to noise enhancement processing;

[0015] Wherein, the plurality of the first sample sets correspond one to one to the plurality of semantic scenes;

[0016] The text determination module is used to determine the first text of each first sample in each first sample set;

[0017] The first text is a prompt text for guiding the pre-trained model to predict the text matching relationship between at least two input texts included in each of the first samples; the first texts of the first samples in different first sample sets are associated with each other;

[0018] The training module is used to combine the first sample and the corresponding first text into a second sample; and is also used to fine-tune the pre-training model through a plurality of the second samples to obtain a text matching model.

[0019] In a third aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory is used to store a software program, and the processor runs or executes the software program stored in the memory so that the electronic device implements the above-mentioned text matching model training method.

[0020] Beneficial effects:

[0021] The present application provides a training method, device and equipment for a text matching model, the method comprising: obtaining a plurality of first sample sets after noise enhancement processing; wherein the plurality of first sample sets correspond one-to-one to a plurality of semantic scenes; determining a first text of each first sample in each first sample set; wherein the first text is a prompt text for guiding a pre-trained model to predict a text matching relationship between at least two input texts included in each first sample; the first texts of the first samples in different first sample sets are associated with each other; combining the first sample and the corresponding first text into a second sample; and fine-tuning the pre-trained model through the plurality of second samples to obtain a text matching model;

[0022] In summary, the present application can improve the robustness of the text matching model by using a first sample set that has been subjected to noise enhancement processing; the present application can improve the generalization of the text matching model by using multiple first sample sets corresponding to multiple semantic scenes and determining a first text with relevance for samples in the multiple first sample sets. Therefore, the training method of the text matching model provided by the present application takes into account both robustness and generalization. Therefore, the present application can solve the problem that the existing fine-tuning process of the text matching model based on the large AI model cannot take into account both robustness and generalization. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0024] Figure 1 A flowchart of a method for training a text matching model provided in this application;

[0025] Figure 2 A logical schematic diagram for determining a first sample set in a training method for a text matching model provided in the present application;

[0026] Figure 3 A logical schematic diagram of determining a first text of a first sample in a training method of a text matching model provided in the present application;

[0027] Figure 4 A schematic diagram of the structure of a training device for a text matching model provided in this application. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.

[0029] When faced with the massive amount of information in today's society or the massive amount of text in the target field, it is often necessary to find information or text that matches the preset information or text in the massive amount of information or text; for example, when faced with the massive amount of cases in the legal field, the staff needs to match the case content that matches the current case in the massive amount of historical cases according to the needs;

[0030] For example, the case content of the current case has specific features such as "physical conflict". The staff needs to match the target case with the above specific features from a large number of historical cases. In actual implementation, the records of historical cases in many cases do not clearly record the text content of "physical conflict", resulting in the existing search engines being unable to accurately match the target case from a large number of historical cases.

[0031] For further example, the case content of the current case is as follows:

[0032] "In a quiet residential area, Mr. Zhang recently experienced a property infringement. When he returned home, he found his home in a mess, drawers were turned upside down, and valuable jewelry and cash were missing. Mr. Zhang realized that this was clearly a burglary.

[0033] Mr. Zhang immediately called the police and described the situation at home in detail. The police rushed to the scene to investigate and collect relevant evidence. According to preliminary investigation, the thief may have entered Mr. Zhang's home by picking the lock.

[0034] This property infringement incident caused great distress and loss to Mr. Zhang. Not only did he lose his valuables, but he also felt that his home had lost its sense of security. This incident also reminded community residents to strengthen their safety awareness and be careful to prevent similar crimes. "

[0035] In the current case mentioned above, there is no clear text content about "physical conflict", so the existing search engine cannot perform the text matching task to retrieve the current case. Therefore, it is necessary to train an AI model with deep understanding and integration capabilities of text content to obtain a text matching model that can perform text matching tasks. In the process of obtaining the text matching model, the AI ​​model needs to be pre-trained and fine-tuned in sequence.

[0036] In the existing technical solution of fine-tuning a pre-trained AI large model to obtain a text matching model, the robustness of the fine-tuned text matching model can be enhanced by performing noise enhancement processing on the samples in the sample set. However, in actual implementation, although the noise enhancement processing can indeed improve the robustness of the text matching model, it causes the generalization of the fine-tuned text matching model to deteriorate. In particular, when faced with a variety of semantic scenarios, the prediction ability of the text matching model will become worse, ultimately resulting in the poor accuracy of the text matching prediction results obtained by the text matching model when performing text matching tasks.

[0037] In order to solve the above technical problems, the present application proposes a training scheme for a text matching model, which is used to fine-tune the pre-trained model by applying multiple sample sets corresponding to different semantic scenarios and constructing associated prompt texts for multiple sample sets on the basis of applying a sample set that has been subjected to noise enhancement processing to the fine-tuning process, so as to improve the generalization of the fine-tuned text matching model.

[0038] The prompt text is a text used to guide the pre-trained model to predict the text matching relationship between at least two input texts included in each sample. For example, the prompt text may be in the form of:

[0039] “Case:

[0040] Time of the incident:

[0041] Type of crime scene:

[0042] When the prompt text and the sample are input into the pre-trained model together, the pre-trained model can predict whether the text contents of at least two input texts in the sample match in terms of "cause of case", "time of incident" and "type of crime scene" based on the features such as "cause of case", "time of incident" and "type of crime scene" in the prompt text.

[0043] The input text is text whose text content needs to determine a text matching relationship with the text content of other input texts.

[0044] The training scheme of the text matching model proposed in this application is now further explained in conjunction with the drawings in the specification.

[0045] First, this application proposes a training method for a text matching model, such as Figure 1 As shown, Figure 1 A flowchart of a method for training a text matching model provided in this application, the method comprising:

[0046] S110: Acquire multiple first sample sets that have undergone noise enhancement processing;

[0047] Among them, the multiple first sample sets correspond one-to-one to the multiple semantic scenes.

[0048] Specifically, the purpose of noise enhancement processing is to improve the robustness of the fine-tuned text matching model when performing text matching tasks; multiple first sample sets need to be obtained and the obtained multiple first sample sets also correspond one-to-one to multiple semantic scenes. This is to improve the fine-tuned text matching model's ability to recognize the text content of at least two input texts in text matching tasks under multiple semantic scenes, and its ability to predict the text matching relationship between at least two input texts, so as to improve the generalization of the fine-tuned text matching model when performing text matching tasks.

[0049] The semantic scene can be understood as the subject matter in the target field. For example, when the target field is the legal field, multiple semantic scenes can be family conflicts, property infringement, etc. The specific determination of the semantic scene, the division and scope of the semantic scene can be determined according to actual needs, and this application does not make specific limitations on this.

[0050] In one implementation, S110 includes: Step (1) to Step (5), the details of which are as follows:

[0051] Step (1): obtaining a plurality of original sample sets corresponding one-to-one to a plurality of semantic scenes;

[0052] Specifically, each original sample includes at least two input texts.

[0053] Step (2): determining the characteristic information of each original sample in each original sample set;

[0054] The feature information indicates whether the original sample contains non-critical features, where non-critical features are features contained in the input text that affect the text matching prediction results of the pre-trained model in non-semantic aspects.

[0055] Specifically, in the process of fine-tuning the pre-trained model, non-critical features in at least two input texts included in the original sample will affect the text matching prediction results of the pre-trained model on the text matching relationship between at least two input texts, but the impact of the non-critical features is not due to the semantic relationship between them and the context, but may be due to their being named entities (personal names, organization names, place names, and all other entities identified by names).

[0056] For example, when two input texts have the same name features but do not have a text matching relationship in terms of text content, the pre-trained model is likely to make an incorrect prediction about the text matching relationship between the two input texts based on the name features, and believe that the text matching relationship between the two input texts is a match.

[0057] It should be emphasized that the determination of non-critical features does not need to be limited to the scope of named entities. In actual operations, the corresponding non-critical features can be determined based on the actual application of specific target fields and specific subject content within the target fields.

[0058] In practical applications, as long as it is determined that any one of at least two input texts included in the original sample contains a non-critical feature, the original sample is considered to contain a non-critical feature.

[0059] In one implementation, step (2) includes: step (2.1) to step (2.3), the details of which are as follows:

[0060] Step (2.1): Determine the average text length of each original sample set based on the length of the input text included in all original samples in each original sample set and the number of original samples included in each original sample set.

[0061] Specifically, the length of the input text refers to the number of characters included in the input text.

[0062] The average text length of each original sample set = the length of the input text included in all original samples in each original sample set and / the number of original samples included in each original sample set.

[0063] Step (2.2): The original samples in each original sample set whose input text length is greater than the corresponding average text length are determined as original samples containing non-critical features.

[0064] Specifically, for an original sample, when the length of the input text included in it is greater than the average length of the text in the original sample set in which it is located, it is considered that the original sample contains non-critical features.

[0065] Step (2.3): The original samples whose input text length is less than or equal to the corresponding average text length in each original sample set are determined as original samples that do not contain non-critical features.

[0066] Specifically, for an original sample, when the length of the input text included in it is less than or equal to the average length of the text in the original sample set in which it is located, it can be considered that the original sample does not contain non-critical features.

[0067] Step (3): Divide each original sample set into a plurality of original sample subsets to obtain a plurality of groups of original sample subsets that correspond one-to-one to the plurality of original sample sets.

[0068] Specifically, Figure 2 As shown, Figure 2 A logical schematic diagram for determining a first sample set in the training method of the text matching model provided in the present application, Figure 2 In the figure, the original sample set A represents any original sample set, the original sample subset A1, the original sample subset A2, ..., the original sample subset An represent n original sample subsets obtained by dividing the original sample set A, the A group of original sample subsets represents a combination of multiple original sample subsets, and the first sample set B represents the first sample set determined according to the original sample set A.

[0069] In one implementation, step (3) includes: step (3.1) to step (3.2), the details of which are as follows:

[0070] Step (3.1): Convert at least two input texts included in each original sample into embedding vectors;

[0071] Specifically, in an embodiment of the present application, the embedding vector corresponding to the input text is determined by the Sentence-BERT model.

[0072] Step (3.2): Cluster the embedding vectors of all original samples in each original sample set to obtain multiple clusters; each cluster corresponds to a set of original sample subsets.

[0073] Specifically, in actual implementation, the k-means clustering method is used to perform clustering processing on the embedding vectors of all original samples in each original sample set.

[0074] Step (4): determining the number of feature samples included in each original sample subset in each group of original sample subsets according to the feature information;

[0075] Among them, the feature sample is the original sample containing non-critical features.

[0076] Specifically, for a group of original sample subsets corresponding to each cluster, the number of original samples containing non-critical features in each original sample subset of each group of original sample subsets is determined according to the feature information determined in the above steps.

[0077] In one implementation, step (4) includes: step (4.1) to step (4.2), the details of which are as follows:

[0078] Step (4.1): randomly sample a first preset number of embedding vectors in each cluster and determine the original samples corresponding to the first preset number of embedding vectors obtained by sampling.

[0079] Step (4.2): Determine the number of characteristic samples in the first preset number of original samples corresponding to each cluster according to the characteristic information.

[0080] Specifically, the fine-tuning process for the pre-trained model usually requires a huge number of samples, so even determining the number of original samples containing non-critical features in each original sample subset is a large workload. Therefore, in order to improve efficiency, the number of feature samples corresponding to the first preset number of embedding vectors randomly sampled in each cluster can be determined instead of determining the number of feature samples in each group of original sample subsets corresponding to each cluster; wherein the first preset number can be determined according to actual needs. In the embodiment of the present application, the first preset number is set to 50.

[0081] Step (5): Determine the original sample subset that includes the largest number of feature samples in each group of original sample subsets as the first sample set.

[0082] Specifically, the original sample subset corresponding to the cluster with the largest number of characteristic samples among the corresponding first preset number of original samples is determined as the first sample set corresponding to the group of original sample subsets, such as Figure 2 As shown, according to the number of feature samples in the first preset number of original samples in the original sample set, the original sample subset with the strongest noise is screened out from the original sample subset A1, the original sample subset A2, ..., the original sample subset An, and the original sample subset with the strongest noise is determined as the first sample set B, which is equivalent to performing "noise enhancement processing" on the original sample set to obtain the first sample set B; the first sample set B can be used to fine-tune the pre-trained model.

[0083] In one implementation, the method provided in the embodiment of the present application further includes: Step (6) to Step (7), the details of which are as follows:

[0084] Step (6): Based on the feature information, determine multiple original samples that do not contain non-critical features in each original sample set.

[0085] Specifically, according to the feature information, a second preset number of non-feature samples are selected from each original sample set; wherein the non-feature samples are original samples that do not contain non-critical features.

[0086] Step (7): Based on a plurality of original samples in each original sample set that do not contain non-critical features, a verification sample set for verifying the prediction performance of the text matching model is determined.

[0087] Specifically, in each original sample set, a third preset number of original samples corresponding to a third preset number of embedding vectors whose Euclidean distances to the embedding vectors corresponding to the non-feature samples are the closest are determined as the verification sample set.

[0088] The second preset quantity and the third preset quantity can be determined according to actual needs;

[0089] In an embodiment of the present application, the ratio between the second preset number and the third preset number is the same as the ratio between the number of first samples included in the first sample set corresponding to the same semantic scene and the number of original samples included in the verification sample set.

[0090] S120: Determine the first text of each first sample in each first sample set;

[0091] The first text is a prompt text that guides the pre-trained model to predict the text matching relationship between at least two input texts included in each first sample; and the first texts of the first samples in different first sample sets are correlated with each other.

[0092] Specifically, in order to further improve the ability of the fine-tuned text matching model to recognize the text content of at least two input texts in text matching tasks in multiple semantic scenarios, and the ability to predict the text matching relationship between at least two input texts, the present application constructs an associated first text for the first samples in different first sample sets to further improve the generalization of the fine-tuned text matching model.

[0093] In one implementation, S120 includes: Step (8) to Step (10), the details of which are as follows:

[0094] Step (8): Select a current first sample set from all first sample sets, and determine the remaining first sample sets after removing the current first sample set from all first sample sets as remaining first sample sets.

[0095] Specifically, the method of selecting the current first sample set can be determined according to actual needs, and this application does not make specific limitations on this; in actual operation, a current semantic scene can be selected based on the connection and difference between multiple semantic scenes, so that the semantics between the current semantic scene and the remaining semantic scenes are closer; the first sample set corresponding to the current semantic scene is the current first sample set.

[0096] The remaining first sample sets are first sample sets remaining after the current first sample set is removed from all the first sample sets.

[0097] Step (9): determining the first set text of the current first sample set and the label of each first sample in the current first sample set;

[0098] The first set text of the current first sample set is the first text of all first samples in the current first sample set.

[0099] Specifically, in the current first sample set, all first samples in the current first sample set use the first set sample as their first text.

[0100] The label is used to indicate the text matching relationship of the first sample, which can be "match" or "no match".

[0101] Step (10): Determine the first text of each remaining first sample in the remaining first sample set according to the semantic scenario and the first set text of the current first sample set.

[0102] Specifically, Figure 3 As shown, Figure 3 A logical schematic diagram for determining a first text of a first sample in a training method for a text matching model provided in the present application, wherein Figure 3 In the formula, the current first sample set Bi indicates that the i-th first sample set is selected from the p first sample sets as the current first sample set; the remaining first sample B1m indicates the m-th remaining first sample in the remaining first sample set B1, and the first text b1m is the first text corresponding to the remaining first sample B1m; the remaining first sample Bpq indicates the q-th remaining first sample in the remaining first sample set Bp, and the first text bpq indicates the first text of the remaining first sample Bpq. Figure 3 It can be seen that, since the first texts of all the first samples in the remaining first sample set are determined based on the first set text, the first set text is associated with the first texts of all the remaining first samples.

[0103] In one implementation, step (10) includes steps (10.1) to (10.3), the details of which are as follows:

[0104] Step (10.1): Decompose the current first sample set into k first sample subsets; wherein k is a positive integer.

[0105] Step (10.2): According to the first set text and the k first sample subsets, determine the k combination texts to be screened corresponding to each remaining first sample;

[0106] Among them, the combined text to be screened includes: a first sample, a derived text, a label to be screened and a text to be screened; the derived text is a prompt text that guides the pre-trained model to predict the text matching relationship between at least two input texts included in the remaining first sample; the label to be screened is a label indicating the text matching relationship of the remaining first sample; and the text to be screened is a text that explains the text matching relationship indicated by the label to be screened.

[0107] Specifically, in an embodiment of the present application, the labels of the remaining first samples in the remaining first sample set are not manually annotated one by one, but are automatically determined together with the first text and the second text; wherein the second text is an explanatory text that explains the text matching relationship indicated by the label of the first text; for example, the second text may be in the form of "Since the two input texts do not correspond in the reasons for the incident, the text matching relationship between the two input texts is mismatched."

[0108] In actual operation, the label of each remaining first sample in the remaining first sample set is determined among k labels to be screened, the first text of each remaining first sample is determined among k derived texts, and the second text of each remaining first sample is determined among k texts to be screened.

[0109] In one implementation, step (10.2) includes: step (10.2.1) to step (10.2.4), the details of which are as follows:

[0110] Step (10.2.1): Determine k derivative texts based on the first set text and k first sample subsets.

[0111] Specifically, in actual operation, based on APE (Automatic Prompt Engineer), k derived texts are determined according to the first set text and k first sample subsets. Both the derived text and the first text are prompt texts that guide the pre-trained model to predict the text matching relationship between at least two input texts included in each first sample.

[0112] Among them, APE refers to using LLM (Large Language Model) as the inference model, ① according to the first set of text requirements, LLM generates a set of candidate prompt text prompts; ② calculate the score of each instruction under LLM to guide the selection process, first evaluate all first sample subsets to filter out a part of the first sample subsets, and then evaluate on the entire current first sample set to select the best prompt. The evaluation score can be selected using accuracy, f1-score, etc.; ③ using the iterative Monte Carlo search method, at each step, evaluate all prompts, filter out prompts with low evaluation scores, and use the filtered prompts to iterate repeatedly to obtain k derivative texts.

[0113] Step (10.2.2): Based on the k derived texts, all remaining first samples in the remaining first sample set are labeled so that each remaining first sample has k labels to be screened.

[0114] Specifically, in actual operation, the Qwen large model can be used to label all the remaining first samples in the remaining first sample set according to the k derivative texts, so that each remaining first sample in the remaining first sample set has k labels to be screened.

[0115] Step (10.2.3): According to the k to-be-screened labels of each remaining first sample, determine the k to-be-screened texts of each remaining first sample.

[0116] Specifically, in actual operation, the Qwen large model can be used to determine the text to be filtered corresponding to each label to be filtered according to the text matching relationship indicated by the k labels to be filtered.

[0117] Step (10.2.4): Combine each remaining first sample with the k derivative texts, the k labels to be screened, and the k texts to be screened into k combined texts to be screened;

[0118] Among them, the derivative text in the combined text to be filtered, the label to be filtered and the text to be filtered have a corresponding relationship.

[0119] Step (10.3): Screen the k combination texts to be screened corresponding to each remaining first sample to obtain the target combination text corresponding to each remaining first sample.

[0120] Specifically, after k combination texts to be screened are determined, a target combination text needs to be determined from the k combination texts to be screened based on a self-consistency principle.

[0121] In actual operation, in the calculation process based on the principle of self-consistency, ① a set of manually written thought chains are used to explain the derivative texts of all the remaining first samples in the remaining first sample set; ② a set of candidate outputs are sampled to generate a set of diverse candidate reasoning paths. The top-k sampling method can be used; ② the first text is selected for each remaining first sample in the remaining first sample set by marginalizing the sampling paths to summarize the answers; wherein marginalization processing refers to merging the results of multiple reasoning paths to obtain the final reasoning result. This can avoid separate calculation and evaluation of each path, thereby reducing the complexity of the calculation.

[0122] When the first text of each corresponding remaining first sample is determined, the to-be-screened combined text where the first text is located is determined as the target combined text of the remaining first sample.

[0123] In practical applications, since the step of determining the target combined text provided in the embodiment of the present application can be used to automatically determine the first text and label of the remaining first sample, compared with the prior art, the present application also has the advantage of saving manpower investment and further improving the fine-tuning efficiency of the text matching model.

[0124] S130: Combine the first sample and the corresponding first text into a second sample.

[0125] Specifically, when multiple first samples in multiple first sample sets are accompanied by associated first texts to fine-tune the pre-trained model, the generalization of the text matching model can be improved.

[0126] In one implementation, S130 includes: Step (11) to Step (12), the details of which are as follows:

[0127] Step (11): Determine the target combined text of each remaining first sample as the second sample corresponding to the remaining first sample.

[0128] Specifically, when a second sample including a first sample, a first text, a second text and a label is used for training, since the second text in the second sample can explain the text matching relationship indicated by the label, the training method of the text matching model provided in the embodiment of the present application can not only improve the generalization on the basis of improving the robustness of the fine-tuned text matching model, but also can further improve the robustness, so that the fine-tuned text matching model has the best prediction ability for the text matching relationship.

[0129] Step (12): Combine the first sample in the current first sample set with the first set text, the second text and the label into a second sample.

[0130] The second text of the first sample in the current first sample set is determined according to its label, which may be specifically performed with reference to step (10.2.3).

[0131] S140: Fine-tune the pre-trained model using multiple second samples to obtain a text matching model.

[0132] Specifically, in practical applications, the number of first samples included in the first sample set corresponding to different semantic scenes can be adjusted according to actual needs, and this application does not make any specific limitation on this.

[0133] In an embodiment of the present application, the pre-trained model may be a Llama 3 model.

[0134] In summary, firstly, the present application can improve the robustness of the text matching model by using a first sample set that has been subjected to noise enhancement processing; secondly, the present application can improve the generalization of the text matching model by using multiple first sample sets corresponding to multiple semantic scenes and determining a first text with relevance for the samples in the multiple first sample sets; in addition, the present application further improves the robustness of the text matching model by using a second text to interpret the text matching relationship indicated by the label, so the training method of the text matching model provided by the present application takes into account both robustness and generalization.

[0135] Second, this application proposes a training device for a text matching model, such as Figure 4 As shown, Figure 4 A schematic diagram of the structure of a training device for a text matching model provided in the present application, the device comprising: a sample acquisition module 210, a text determination module 220 and a training module 230;

[0136] The sample acquisition module 210 is used to acquire a plurality of first sample sets that have undergone noise enhancement processing;

[0137] Wherein, the plurality of first sample sets correspond one to one to the plurality of semantic scenes;

[0138] The text determination module 220 is used to determine the first text of each first sample in each first sample set; wherein the first text is a prompt text for guiding the pre-trained model to predict the text matching relationship between at least two input texts included in each first sample; and the first texts of the first samples in different first sample sets are correlated with each other;

[0139] The training module 230 is used to combine the first sample and the corresponding first text into a second sample; and is also used to fine-tune the pre-training model through multiple second samples to obtain a text matching model.

[0140] In one implementation, the sample acquisition module is further used to acquire a plurality of original sample sets corresponding one-to-one to a plurality of semantic scenes;

[0141] The sample acquisition module is further used to determine feature information of each original sample in each original sample set; wherein the feature information indicates whether the original sample contains non-critical features, and the non-critical features are features contained in the input text that affect the text matching prediction results of the pre-trained model in non-semantic aspects;

[0142] The sample acquisition module is further used to divide each original sample set into multiple original sample subsets to obtain multiple groups of original sample subsets that correspond one to one with the multiple original sample sets;

[0143] The sample acquisition module is further used to determine the number of characteristic samples included in each original sample subset in each group of original sample subsets according to the characteristic information;

[0144] Among them, the feature sample is the original sample containing non-critical features;

[0145] The sample acquisition module is further used to determine the original sample subset including the largest number of characteristic samples in each group of original sample subsets as the first sample set.

[0146] In one implementation, the sample acquisition module is further used to determine the average text length of each original sample set according to the length of the input text included in all original samples in each original sample set and the number of original samples included in each original sample set;

[0147] The sample acquisition module is further used to determine the original samples whose input text length in each original sample set is greater than the corresponding average text length as the original samples containing non-critical features;

[0148] The sample acquisition module is also used to determine the original samples whose length of the input text is less than or equal to the corresponding average length of the text as samples that do not contain non-critical features.

[0149] In one implementation, the sample acquisition module is further used to determine, in each original sample set, a plurality of original samples that do not contain non-critical features according to the feature information;

[0150] The sample acquisition module is also used to determine a verification sample set for verifying the prediction performance of the text matching model based on multiple original samples that do not contain non-critical features in each original sample set.

[0151] In one implementation, the text determination module is further configured to select a current first sample set from among all first sample sets, and determine a plurality of first sample sets remaining after excluding the current first sample set from among all first sample sets as remaining first sample sets;

[0152] The text determination module is further used to determine the first set text of the current first sample set and the label of each first sample in the current first sample set;

[0153] The first set text of the current first sample set is the first text of all first samples in the current first sample set;

[0154] The text determination module is further used to determine the first text of each remaining first sample in the remaining first sample set according to the semantic scene and the first set text of the current first sample set.

[0155] In one implementation, the text determination module is further used to decompose the current first sample set into k first sample subsets; wherein k is a positive integer;

[0156] The text determination module is further used to determine k combined texts to be screened corresponding to each remaining first sample according to the first set of texts and the k first sample subsets;

[0157] The combined text to be screened includes: a first sample, a derived text, a label to be screened, and a text to be screened; the derived text is a prompt text for guiding the pre-trained model to predict the text matching relationship between at least two input texts included in the remaining first sample; the label to be screened is a label indicating the text matching relationship of the remaining first sample; and the text to be screened is a text explaining the text matching relationship indicated by the label to be screened;

[0158] The text determination module is further used to screen the k to-be-screened combined texts corresponding to each remaining first sample to obtain a target combined text corresponding to each remaining first sample.

[0159] In one implementation, the text determination module is further used to determine k derivative texts based on the first set of texts and the k first sample subsets;

[0160] The text determination module is further used to label all remaining first samples in the remaining first sample set according to the k derived texts, so that each remaining first sample has k labels to be screened;

[0161] The text determination module is further used to determine the k to-be-screened texts of each remaining first sample according to the k to-be-screened labels of each remaining first sample;

[0162] The text determination module is further used to combine each remaining first sample with the k derivative texts, the k labels to be screened and the k texts to be screened into k combined texts to be screened;

[0163] Among them, the derivative text in the combined text to be filtered, the label to be filtered and the text to be filtered have a corresponding relationship.

[0164] In one implementation, the training module is further used to determine the target combined text of each remaining first sample as a second sample corresponding to the remaining first sample.

[0165] Third, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, steps S110 to S140 provided in the above embodiment are implemented.

[0166] Fourth, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, steps S110 to S140 of the above embodiment are executed.

[0167] Fifth, the computer program product provided in the present application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method in the previous method embodiment. The specific implementation can refer to steps S110 to S140 of the method embodiment, which will not be repeated here.

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

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

[0170] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0171] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM) random access memory (RAM), disk or optical disk, and other media that can store program codes.

[0172] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0173] The above description is only an embodiment 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 may have various modifications and variations. 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.

Claims

1. A method for training a text matching model, characterized in that: The method comprises: Acquire a plurality of first sample sets that have undergone noise enhancement processing; Wherein, the plurality of the first sample sets correspond one to one to the plurality of semantic scenes; Determine the first text of each first sample in each of the first sample sets; The first text is a prompt text for guiding the pre-trained model to predict the text matching relationship between at least two input texts included in each of the first samples; the first texts of the first samples in different first sample sets are associated with each other; combining the first sample and the corresponding first text into a second sample; The pre-trained model is fine-tuned using a plurality of the second samples to obtain a text matching model.

2. The method according to claim 1, characterized in that The step of obtaining a plurality of first sample sets that have undergone noise enhancement processing comprises: Acquire a plurality of original sample sets corresponding one-to-one to a plurality of the semantic scenes; Determine feature information of each original sample in each of the original sample sets; The feature information indicates whether the original sample contains non-critical features, where the non-critical features are features contained in the input text that affect the text matching prediction results of the pre-training model in non-semantic aspects; Dividing each of the original sample sets into a plurality of original sample subsets to obtain a plurality of groups of original sample subsets in one-to-one correspondence with the plurality of the original sample sets; Determine, according to the characteristic information, the number of characteristic samples included in each of the original sample subsets in each group of the original sample subsets; Wherein, the feature sample is the original sample containing the non-critical feature; The original sample subset including the largest number of the feature samples in each group of the original sample subsets is determined as the first sample set.

3. The method according to claim 2, characterized in that The determining the characteristic information of each original sample in each original sample set includes: Determine the average text length of each original sample set according to the length of the input text included in all the original samples in each original sample set and the number of the original samples included in each original sample set; Determine the original sample in each original sample set whose input text length is greater than the corresponding average text length as the original sample containing the non-critical feature; The original samples in each of the original sample sets whose length of the input text is less than or equal to the corresponding average length of the text are determined as original samples that do not contain the non-critical features.

4. The method according to claim 2, characterized in that: The method further comprises: According to the feature information, determining a plurality of original samples that do not contain non-critical features in each of the original sample sets; A verification sample set for verifying the prediction performance of the text matching model is determined according to a plurality of original samples that do not contain non-critical features in each of the original sample sets.

5. The method according to claim 2, characterized in that: The determining the first text of each first sample in each first sample set comprises: Selecting a current first sample set from all the first sample sets, and determining a plurality of first sample sets remaining after excluding the current first sample set from all the first sample sets as remaining first sample sets; Determine a first set text of the current first sample set and a label of each of the first samples in the current first sample set; The first set text of the current first sample set is the first text of all the first samples in the current first sample set; According to the semantic scenario and the first set text of the current first sample set, a first text of each remaining first sample in the remaining first sample set is determined.

6. The method according to claim 5, characterized in that The determining, according to the semantic scene and the first set text of the current first sample set, the first text of each remaining first sample in the remaining first sample set comprises: Decomposing the current first sample set into k first sample subsets; wherein k is a positive integer; Determine, according to the first set of texts and the k first sample subsets, k to-be-screened combined texts corresponding to each of the remaining first samples; The combined text to be screened includes: the first sample, derived text, a label to be screened and a text to be screened; the derived text is a prompt text for guiding the pre-trained model to predict the text matching relationship between at least two input texts included in the remaining first sample; the label to be screened is a label indicating the text matching relationship of the remaining first sample; and the text to be screened is a text explaining the text matching relationship indicated by the label to be screened. The k to-be-screened combined texts corresponding to each of the remaining first samples are screened to obtain a target combined text corresponding to each of the remaining first samples.

7. The method according to claim 6, characterized in that The step of determining, based on the first set of texts and the k first sample subsets, k combined texts to be screened corresponding to each of the remaining first samples comprises: Determine k of the derived texts according to the first set of texts and k of the first sample subsets; According to the k derived texts, all the remaining first samples in the remaining first sample set are labeled so that each of the remaining first samples has k labels to be screened; Determine k to-be-screened texts of each of the remaining first samples according to the k to-be-screened labels of each of the remaining first samples; Combining each of the remaining first samples with the k derivative texts, the k labels to be screened, and the k texts to be screened into k combined texts to be screened; There is a corresponding relationship between the derived text in the combined text to be screened, the label to be screened and the text to be screened.

8. The method according to claim 6, characterized in that The combining the first sample and the corresponding first text into a second sample includes: The target combined text of each of the remaining first samples is determined as the second sample corresponding to the remaining first sample.

9. A text matching model training device, characterized in that: The device comprises: a sample acquisition module, a text determination module and a training module; The sample acquisition module is used to acquire a plurality of first sample sets that have been subjected to noise enhancement processing; Wherein, the plurality of the first sample sets correspond one to one to the plurality of semantic scenes; The text determination module is used to determine the first text of each first sample in each first sample set; The first text is a prompt text for guiding the pre-trained model to predict the text matching relationship between at least two input texts included in each of the first samples; the first texts of the first samples in different first sample sets are associated with each other; The training module is used to combine the first sample and the corresponding first text into a second sample; and is also used to fine-tune the pre-training model through a plurality of the second samples to obtain a text matching model.

10. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory is used to store software programs, and the processor runs or executes the software programs stored in the memory so that the electronic device implements the training method of the text matching model as described in any one of claims 1 to 8.