A similar sentence pair judgment method, system and storage medium

By using the combination of Focal Loss function and Bert algorithm in the Robert network, the problem of sample imbalance and insufficient semantic representation ability in similar sentence pair judgment is solved, achieving high accuracy of similar sentence pair judgment, and improving the performance of intelligent dialogue systems. User experience and data quality.

CN112257409BActive Publication Date: 2024-08-30JIANGSU SECURITIES
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011069334.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-30
Publication Date
2024-08-30
Estimated Expiration
2040-09-30

AI Technical Summary

Technical Problem

The existing technology has problems of word segmentation accuracy dependence and insufficient semantic representation ability when judging similar sentence pairs. In particular, it is difficult to solve the problem of sample imbalance of similar sentence pairs of different categories, which affects the accuracy and model generalization ability.

Method used

Use Robert network combined with Bert algorithm to convert sentence pairs into semantic representation space through Encoder, replace the Cross Entropy Loss function with the Focal Loss function, adjust the learning rate and warm-up update steps, and use the dynamic mask method and FULL-SENTENCES training corpus to ensure accurate classification of similar sentence pairs.

Benefits of technology

It effectively eliminates the problem of sample imbalance of similar sentence pairs, improves the accuracy of judgment, improves the user experience and data entry quality of the intelligent dialogue system, and ensures the accurate classification and intelligent application of similar sentence pairs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112257409B
    Figure CN112257409B
Patent Text Reader

Abstract

The present invention discloses a similar sentence pair judgment method, system and storage medium, the method comprising the following steps: step 1: according to the actual use scenario and according to the intention conflict and the question similarity, the data set is sorted into multiple groups of sentence pairs; step 2: using the encoder connected to the Robert network to convert the multiple groups of sentence pairs in step 1 into the corresponding semantic representation space, and obtain semantically consistent Embedding result samples; step 3: inputting the Embedding result samples processed in step 2 into the Robert network for training, and replacing the Cross Entropy Loss function of the Robert network with the Focal Loss function to eliminate the problem of unbalanced samples of similar sentence pairs of different categories; step 4: repeating step 3 for training optimization until the convergence condition is met, so as to accurately classify the Embedding result samples into similar sentence pairs and non-similar sentence pairs. The present invention can ensure the accuracy of similar sentence pair judgment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a similar sentence pair judgment method, system and storage medium, and belongs to the technical field of natural language processing. Background Art

[0002] Currently, there are two commonly used methods for judging similar sentence pairs: judging similar sentence pairs based on word-level and judging similar sentence pairs based on sentence-level.

[0003] Judging similar sentence pairs based on word-level is to segment the sentences and calculate the similarity of the words contained in the two compared sentences respectively. It mainly involves two core issues: one is the problem of calculating the similarity of words, and the other is the problem of weighted fusion of the similarities of multiple words. However, there are certain limitations, mainly including two points. The first is the large maintenance workload. If the method of sentence segmentation is adopted, the accuracy of judging similar sentence pairs depends on the accuracy of word segmentation and the comprehensiveness of the previous synonym maintenance; the second is the lack of semantic representation ability.

[0004] Judging similar sentence pairs based on Sentence-level adopts sentence modeling method to judge similar sentence pairs. Its core idea is to use vector space model to vectorize sentences. There are usually two ways of vector representation. One is to represent sentences based on word-vector combination, and the other is to represent sentences based on sentence-vector. However, it is difficult to solve the technical problem of sample imbalance of similar sentence pairs of different categories. Summary of the invention

[0005] The purpose of the present invention is to overcome the deficiencies in the prior art and to provide a similar sentence pair judgment method, system and storage medium, which can ensure the accuracy of similar sentence pair judgment.

[0006] To achieve the above object, the present invention is implemented by adopting the following technical solutions:

[0007] In a first aspect, the present invention provides a method for determining similar sentence pairs, the method comprising the following steps:

[0008] Step 1: Organize the dataset into multiple sentence pairs based on actual usage scenarios, intent conflicts, and question similarity;

[0009] Step 2: Use the Encoder connected to the Robert network to convert the multiple sentence pairs in step 1 into the corresponding semantic representation space to obtain semantically consistent Embedding result samples;

[0010] Step 3: Input the Embedding result samples processed in step 2 into the Robert network for training, and replace the Cross Entropy Loss function of the Robert network with the Focal Loss function to eliminate the imbalance problem of samples of similar sentences of different categories;

[0011] Step 4: Repeat step 3 for training optimization until the convergence condition is met, so as to accurately classify the Embedding result samples into similar sentence pairs and non-similar sentence pairs.

[0012] In combination with the first aspect, further, the Robert network is based on the Bert algorithm.

[0013] Combined with the first aspect, the Robert network further adjusted the peak value of the learning rate and the number of warm-up update steps, changed β2=0.999 in Adam to β2=0.98, did not truncate the sequence, used the full-length sequence, and used DGX-1each with 8*32GB NVIDIA V100 GPUs interconnected by Infiniband processors.

[0014] Combined with the first aspect, further, the Robert network uses 160G training corpus, uses the dynamic mask method, uses FULL-SENTENCES without NSP Loss, and uses batch size = 16 / 32 / 64 / 128.

[0015] In combination with the first aspect, further, the convergence condition is that the accuracy of judging similar sentence pairs reaches a certain threshold.

[0016] In a second aspect, the present invention provides a similar sentence pair determination system, the system comprising:

[0017] Classification module: used to organize the data set into multiple sentence pairs according to the actual usage scenarios, intent conflicts and question similarity;

[0018] Conversion module: used to use the Encoder connected to the Robert network to convert multiple sentence pairs into corresponding semantic representation spaces to obtain semantically consistent Embedding result samples;

[0019] Input module: used to input the embedding result samples into the Robert network for training, and replace the Cross Entropy Loss function of the Robert network with the Focal Loss function to eliminate the imbalance problem of similar sentences of different categories;

[0020] Optimization module: used to repeat the training of the input module for optimization until the convergence condition is met, so as to accurately classify the Embedding result samples into similar sentence pairs and non-similar sentence pairs.

[0021] In a third aspect, the present invention provides a similar sentence pair determination system, including a processor and a storage medium;

[0022] The storage medium is used to store instructions;

[0023] The processor is used to operate according to the instruction to execute the steps of any of the aforementioned determination methods.

[0024] In a fourth aspect, a computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any of the aforementioned determination methods.

[0025] Compared with the prior art, the present invention has the following beneficial effects:

[0026] The present invention eliminates the imbalance problem of similar sentence pairs of different categories through the training of Robert network and the Focal Loss function, and can quickly identify one or more categories of similar sentence pair samples with a smaller proportion, so as to accurately classify the embedding result samples into similar sentence pairs and non-similar sentence pairs, thereby ensuring the accuracy of similar sentence pair judgment;

[0027] By adding a semantic representation space, the user experience of the intelligent dialogue system is improved, which is conducive to the further intelligence of the intelligent dialogue system. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 is a principle block diagram of a similar sentence pair determination method provided by an embodiment of the present invention;

[0029] Figure 2 It is a specific application implementation flow chart of the similar sentence pair determination method provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0030] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.

[0031] In the embodiment of the present invention, the number of samples of similar sentence pairs that constitute a complete sentence is relatively small, while the number of samples of other similar sentence pairs is relatively large, which causes an imbalance in samples of similar sentence pairs of different categories and has a certain impact on the generalization ability of the machine learning model. Therefore, the Cross Entropy Loss function of the Robert network is replaced by a Focal Loss function for processing the problem of imbalanced samples of similar sentence pairs of different categories, thereby increasing the weight of samples of similar sentence pairs that constitute a complete sentence.

[0032] The Focal Loss function is a modification based on the cross entropy loss function. First, let’s review the binary cross entropy loss:

[0033]

[0034] y' is the prediction result of the traditional two-classification problem, and its value is between 0 and 1.

[0035] For normal cross entropy, the greater the output probability for positive samples, the smaller the loss; for normal cross entropy, the smaller the output probability for negative samples, the smaller the loss. At this time, the optimization speed of the cross entropy loss function in the iterative process of a large number of simple samples will be relatively slow and may not be optimized to the optimal value. Therefore, the Focal Loss function is optimized as follows:

[0036]

[0037] Among them, γ>0 reduces the loss of other similar sentence pairs, making similar sentence pairs that constitute a complete sentence more concerned; adding a balance factor α is used to balance the uneven proportion of positive and negative samples. For example, α is 0.25, that is, the proportion of positive samples is smaller than that of negative samples. This is because negative samples are simple and easy to distinguish.

[0038] Although adding only α can balance the uneven ratio of positive and negative samples, it cannot solve the problem of simple and difficult samples. γ adjusts the rate at which the weight of simple samples decreases. When γ is 0, the Focal Loss function is the cross entropy loss function. When γ increases, the influence of the balance factor α also increases.

[0039] like Figure 1 As shown, an embodiment of the present invention provides a method for determining similar sentence pairs, the method comprising the following steps:

[0040] Step 1: According to the actual usage scenario and in accordance with the conflict of intent and question similarity, the data set is sorted into multiple groups of sentence pairs. In this embodiment, there are 3 groups, each of which consists of sent1 and sent2. At the same time, a label is set to indicate whether the sent1 and sent2 sentences in the group constitute a similar sentence pair.

[0041] Among them, label=1 indicates that sent1 and sent2 form a similar sentence pair, and label=0 indicates that sent1 and sent2 do not form a similar sentence pair;

[0042] Step 2: Use the Encoder connected to the Robert network to convert the multiple sentence pairs in step 1 into the corresponding semantic representation space to obtain semantically consistent Embedding result samples;

[0043] Step 3: Input the Embedding result samples processed in step 2 into the Robert network for training, thereby effectively solving the data noise problem that is easily generated in the process of corpus collection for the intelligent dialogue system; and replace the Cross Entropy Loss function of the Robert network with the Focal Loss function to eliminate the imbalance problem of similar sentence pairs of different categories. The Robert network is based on the Bert algorithm; the Robert network adjusts the peak value of the learning rate and the number of warm-up update steps, changes β2=0.999 in Adam to β2=0.98, does not truncate the sequence, uses the full-length sequence, uses DGX-1each with 8*32GB NVIDIA V100 GPUs interconnected by Infiniband processor, uses 160G training corpus, while the original Bert algorithm uses 16G training corpus, uses a dynamic mask method, while the original Bert algorithm uses a classic mask method, uses FULL-SENTENCES without NSP Loss, uses batch size=16 / 32 / 64 / 128, and uses a high-level byte-level BPE;

[0044] Step 4: Repeat step 3 for training optimization until the convergence condition is met, so as to accurately classify the Embedding result samples into similar sentence pairs and non-similar sentence pairs. The convergence condition is that the accuracy of similar sentence pair judgment reaches a certain threshold.

[0045] The embodiment of the present invention eliminates the imbalance problem of similar sentence pairs of different categories through the training of Robert network and the Focal Loss function, and can relatively quickly identify one or more categories of similar sentence pair samples with a smaller proportion, so as to accurately classify the embedding result samples into similar sentence pairs and non-similar sentence pairs, thereby ensuring the accuracy of similar sentence pair judgment;

[0046] Among them, if the sent1 sentence and the sent2 sentence of each group form a similar sentence pair, they are marked by label = 1; if the sent1 sentence and the sent2 sentence of each group do not form a similar sentence pair, they are marked by label = 0;

[0047] By adding a semantic representation space, the user experience of the intelligent dialogue system is improved, which is conducive to the further intelligence of the intelligent dialogue system.

[0048] The embodiment of the present invention ensures the accuracy of similar sentence pair judgment, thereby raising the threshold for subsequent similar sentence pair entry, that is, only similar sentence pairs that meet certain conditions can be entered into the intelligent dialogue system, thereby preventing the intelligent dialogue system from generating too much dirty data.

[0049] like Figure 2 As shown, the specific application of the similar sentence pair determination method provided by the embodiment of the present invention is described as follows:

[0050] The corpus is input into the background of the intelligent dialogue system, and then the intelligent dialogue system performs intent conflict detection on the corpus to ensure that the corpus input into the system is new corpus that has never appeared in the system. If there is no conflict, the new corpus is added to the system. If a conflict occurs, the similar sentence pair judgment method is used to determine whether the conflicting input corpus and the system internal corpus are similar sentence pairs, and then the similar sentence pairs are saved in the intelligent dialogue system, thereby expanding the original similar sentence pairs.

[0051] The embodiment of the present invention further provides a similar sentence pair determination system, the system comprising:

[0052] Classification module: used to organize the data set into multiple sentence pairs according to the actual usage scenarios, intent conflicts and question similarity;

[0053] Conversion module: used to use the Encoder connected to the Robert network to convert multiple sentence pairs into corresponding semantic representation spaces to obtain semantically consistent Embedding result samples;

[0054] Input module: used to input the embedding result samples into the Robert network for training, and replace the Cross Entropy Loss function of the Robert network with the Focal Loss function to eliminate the imbalance problem of similar sentences of different categories;

[0055] Optimization module: used to repeat the training of the input module for optimization until the convergence condition is met, so as to accurately classify the Embedding result samples into similar sentence pairs and non-similar sentence pairs.

[0056] The embodiment of the present invention also provides a similar sentence pair determination system, including a processor and a storage medium;

[0057] The storage medium is used to store instructions;

[0058] The processor is used to operate according to the instructions to execute the steps of the above-mentioned determination method.

[0059] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the above-mentioned determination method are implemented.

[0060] The embodiments of the present invention are applicable to auxiliary discrimination scenarios of manually entering similar sentence pairs in an intelligent dialogue system. In the initial stage of the intelligent dialogue system business, the staff will face a large amount of data entry work, and the quality of data entry directly determines the accuracy of the intelligent dialogue system in answering questions. Only answers with higher accuracy can ensure that the intelligent dialogue system maintains a certain user stickiness in the later application process. It can be seen that the quality of data entry is the basis for ensuring that the intelligent dialogue system is popular with users, and the embodiments of the present invention can ensure the accuracy of similar sentence pair judgment, improve the quality of data entry, and thus improve the accuracy of the intelligent dialogue system in answering questions.

[0061] The embodiments of the present invention can be applied not only to the judgment of similar sentence pairs, but also to the field of text generation. For example, by judging the similarity between the generated corpus and the target corpus, the generation of corpus with too much semantic difference can be avoided. It can also be applied to semantic judgment scenarios including but not limited to sentence merging, as well as solving semantic parsing problems other than dialogue.

[0062] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0063] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A system that specifies the functions of a box or multiple boxes.

[0064] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction system, which is implemented in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0065] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0066] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for determining similar sentence pairs, characterized in that: The method comprises the following steps: Step 1: Organize the dataset into multiple sentence pairs based on actual usage scenarios, intent conflicts, and question similarity; Step 2: Use the Encoder connected to the Robert network to convert the multiple sentence pairs in step 1 into the corresponding semantic representation space to obtain semantically consistent Embedding result samples; Step 3: Input the Embedding result samples processed in step 2 into the Robert network for training, and replace the Cross Entropy Loss function of the Robert network with the Focal Loss function to eliminate the imbalance problem of samples of similar sentences of different categories; Step 4: Repeat step 3 for training optimization until the convergence condition is met, so as to accurately classify the Embedding result samples into similar sentence pairs and non-similar sentence pairs; The Robert network is based on the Bert algorithm; the Robert network adjusts the peak value of the learning rate and the number of warm-up update steps, and changes the peak value of the learning rate and the number of warm-up update steps in Adam. Change to , do not truncate the sequence, use the full-length sequence, and use DGX-1 each with 8*32GB NVIDIA V100 GPUs interconnected by Infiniband processor.

2. The similar sentence pair determination method according to claim 1, characterized in that: Robert network uses 160G training corpus, dynamic mask method, and FULL-SENTENCES Without NSP Loss, use batch size=16 / 32 / 64 / 128.

3. A similar sentence pair judgment system, characterized in that: The system comprises: Classification module: used to organize the data set into multiple sentence pairs according to the actual usage scenarios, intent conflicts and question similarity; Conversion module: used to use the Encoder connected to the Robert network to convert multiple sentence pairs into corresponding semantic representation spaces to obtain semantically consistent Embedding result samples; Input module: used to input the embedding result samples into the Robert network for training, and replace the Cross Entropy Loss function of the Robert network with the Focal Loss function to eliminate the imbalance problem of similar sentences of different categories; Optimization module: used to repeat the training of the input module for optimization until the convergence condition is met, so as to accurately classify the Embedding result samples into similar sentence pairs and non-similar sentence pairs; The Robert network is based on the Bert algorithm; the Robert network adjusts the peak value of the learning rate and the number of warm-up update steps, and changes the peak value of the learning rate and the number of warm-up update steps in Adam. Change to , do not truncate the sequence, use the full-length sequence, and use DGX-1 each with 8*32GB NVIDIA V100 GPUs interconnected by Infiniband processor.

4. A similar sentence pair judgment system, characterized in that: including processor and storage medium; The storage medium is used to store instructions; The processor is configured to operate according to the instructions to execute the steps of the method according to any one of claims 1-2.

5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 2 are implemented.

Citation Information

Patent Citations

  • Question answering system based on multisource heterogeneous data for medical field and implementing method thereof

    CN108108449A

  • Intelligent statement clarification method and system for dialogue system

    CN111199149A