A method and apparatus for intent classification
By optimizing the sentence to be enhanced through keyword extraction, masking processing, and evaluation functions, and training the model by combining word masking prediction and intent classification tasks, the high cost and semantic variation problems caused by manual annotation are solved, and the robustness and accuracy of the intent recognition model are improved.
Patent Information
- Application Number
- CN202210397779.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-15
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2042-04-15
AI Technical Summary
In existing technologies, the training corpus for intent recognition models relies on manual annotation, which leads to high annotation resource costs and can easily cause changes in text semantics, affecting the model's recognition performance.
By extracting keywords, masking, and optimizing the evaluation function, the intent classification model is trained by combining word masking prediction and intent classification tasks. By using labeled and unlabeled sentences, the negative impact of manual labeling is avoided, thus improving the robustness of the model.
Effectively utilizing unlabeled statements reduces labeling resource costs, improves the recognition performance and robustness of the intent classification model, and enhances the model's recognition accuracy.
Smart Images

Figure CN114722153B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more particularly to a method and apparatus for intent classification, a storage medium, and a computer program product. Background Technology
[0002] Intent recognition capability is a reflection of the importance of chatbots. Intent recognition is essentially a multi-classification problem. The text to be recognized is input into the intent recognition model, and the output is a specific intent.
[0003] The accuracy of intent recognition models determines the quality of intent recognition results. Currently, the training data for intent recognition models is mainly obtained by manually annotating collected human-computer dialogue data to obtain a batch of standard training data, and then using the annotated training data to train the intent recognition model.
[0004] Because existing technologies rely too heavily on manual annotation of corpora, the cost of annotation resources is relatively high, and it can easily lead to changes in the semantics of the text, thereby affecting the recognition performance of intent recognition models. Summary of the Invention
[0005] This invention provides a method and apparatus for intent classification, a storage medium, and a computer program product to address the shortcomings of existing technologies where manual annotation leads to high annotation resource costs and easily causes changes in text semantics, affecting the recognition performance of intent recognition models.
[0006] This invention provides a method for intent classification, comprising:
[0007] Extract keywords from the sentences to be enhanced;
[0008] The keywords are masked to obtain the processed statement to be enhanced. The processed statement to be enhanced is then input into the intent classification model to obtain multiple enhanced prediction statements.
[0009] The enhanced prediction statement is evaluated using a first evaluation function, and the enhanced prediction statement with the highest evaluation score is taken as the final enhanced statement; wherein, the first evaluation function is used to evaluate the combined value of semantic similarity and content difference between the statement to be enhanced and the enhanced prediction statement;
[0010] The final enhanced statement is then input into the intent classification model to determine the intent classification corresponding to the final enhanced statement.
[0011] The intent classification model is obtained by performing a training task using initial sample statements, wherein the initial sample statements include labeled statements and unlabeled statements, and the training task includes a word masking prediction task based on the initial sample statements and an intent classification task based on the labeled statements.
[0012] According to the present invention, an intent classification method extracts keywords from the statement to be enhanced, including:
[0013] The sentence to be enhanced is segmented into multiple words;
[0014] Construct a connectivity weight graph between words, determine the weight ranking based on the connectivity weight graph between words, and determine the keywords based on the weight ranking;
[0015] or
[0016] The sentence to be enhanced is input into a pre-trained topic model, which outputs candidate keywords and the article topic corresponding to the sentence to be enhanced.
[0017] The similarity between the article topic and the candidate keywords is determined and sorted. The top n candidate keywords are used as the keywords, where n is an integer greater than 1.
[0018] According to an intent classification method provided by the present invention, the keywords are masked to obtain the processed statement to be enhanced, including:
[0019] Determine the number of character units included in each keyword;
[0020] Set the keyword masking ratio corresponding to different numbers of character units;
[0021] Based on the masking ratio, keywords corresponding to different numbers of word units in the sentence to be enhanced are masked to obtain the processed sentence to be enhanced.
[0022] According to the present invention, an intent classification method is provided, which trains the intent classification model based on a word masking prediction task of the initial sample sentences, including:
[0023] Extract sample keywords from the initial sample statements;
[0024] The initial sample statements are masked by sample keywords to obtain masked sample statements. The masked sample statements are then input into the intent classification model, and the augmented sample statements corresponding to each masked sample statement are output.
[0025] Determine the content difference and semantic similarity between the initial sample statement and the enhanced sample statement;
[0026] The intent classification model is trained based on a preset second evaluation function and the content difference and semantic similarity between the initial sample statement and the enhanced sample statement until the second evaluation function reaches the convergence condition; wherein, the second evaluation function is used to evaluate the comprehensive value of the content difference and semantic similarity between the initial sample statement and the enhanced sample statement.
[0027] According to an intent classification method provided by the present invention, the initial sample statement is subjected to sample keyword masking processing to obtain a masked sample statement, including:
[0028] Determine the number of character units included in each of the sample keywords;
[0029] Set the masking ratio of sample keywords corresponding to different numbers of character units;
[0030] Based on the masking ratio, the sample keywords corresponding to different numbers of word units in the initial sample statement are masked to obtain the masked sample statement.
[0031] According to a method for intent classification provided by the present invention, the intent classification model is trained based on the intent classification task of the labeled statement, including:
[0032] The intent classification model is trained in a supervised manner using the labeled statements and their corresponding intent classification labels through a preset loss function until the loss value of the loss function is less than a preset value.
[0033] According to an intent classification method provided by the present invention, the first evaluation function includes:
[0034] T=Min(J(A1,B1))+Max(Sim(A1,B1))
[0035] Wherein, J(A1,B1) is the content difference between the statement to be enhanced A1 and the enhanced prediction statement B1;
[0036]
[0037] Sim(A1,B1) represents the semantic similarity between the statement to be enhanced, A1, and the predicted enhanced statement, B1.
[0038]
[0039] The present invention also provides an apparatus for intention classification, comprising:
[0040] The extraction module is used to extract keywords from the statements to be enhanced;
[0041] The enhancement prediction module is used to mask the keywords to obtain the processed statement to be enhanced, and input the processed statement to be enhanced into the intent classification model to obtain multiple enhanced prediction statements.
[0042] An evaluation module is used to evaluate the enhanced prediction statement through a first evaluation function, and to take the enhanced prediction statement with the highest evaluation score as the final enhanced statement; wherein, the first evaluation function is used to evaluate the combined value of semantic similarity and content difference between the statement to be enhanced and the enhanced prediction statement;
[0043] The intent classification module is used to input the final enhanced statement back into the intent classification model to determine the intent classification corresponding to the final enhanced statement.
[0044] The intent classification model is obtained by performing a training task using initial sample statements, wherein the initial sample statements include labeled statements and unlabeled statements, and the training task includes a word masking prediction task based on the initial sample statements and an intent classification task based on the labeled statements.
[0045] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the intention classification method as described above.
[0046] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the intent classification method as described above.
[0047] The method and apparatus for intent classification provided by this invention obtain multiple enhanced prediction statements based on the input statement to be enhanced using a trained intent classification model. These enhanced prediction statements are then evaluated using a first evaluation function, and the statement with the highest evaluation score is selected as the final enhanced statement. The final enhanced statement is then input back into the intent classification model to determine the intent classification corresponding to it. The intent classification model is jointly trained by performing a word masking prediction task and an intent classification task. This not only effectively utilizes unlabeled statements in the initial sample statements, avoiding the negative impact of semantic changes caused by manual annotation on the model's training process, but also improves the robustness of the intent classification model, thereby enhancing its recognition performance. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0049] Figure 1 This is one of the flowcharts illustrating the intent classification method provided by the present invention;
[0050] Figure 2 This is the second flowchart illustrating the intent classification method provided by the present invention;
[0051] Figure 3 This is a flowchart illustrating the training method of the intent classification model of the present invention;
[0052] Figure 4 This is the third flowchart illustrating the intent classification method provided by the present invention;
[0053] Figure 5 This is a schematic diagram illustrating the generation of enhanced prediction statements in the method provided by the present invention;
[0054] Figure 6 This is a schematic diagram of the structure of the device for intentional classification provided by the present invention;
[0055] Figure 7 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0057] The following is combined with Figures 1-5 A method for classifying intent according to embodiments of the present invention is described.
[0058] This invention discloses a method for intent classification, see [link to relevant documentation]. Figure 1 ,include:
[0059] 101. Extract keywords from the sentences to be enhanced.
[0060] First, the enhancement tasks mentioned in this embodiment will be explained.
[0061] Text augmentation refers to generating a new text that expresses the same intent but with significant differences in content, based on an input text containing an intent. This allows the intent recognition model to learn these differences and improves the robustness of the intent classification model.
[0062] For example, if the input text is "How is the weather today?", the text enhancement task can generate the enhanced text "How is the weather today?".
[0063] In this embodiment, the statement to be enhanced can be one or more, such as an input article that includes multiple statements.
[0064] There are several methods for extracting keywords, such as:
[0065] In one approach, the sentence to be enhanced is segmented into multiple words; a connectivity weight graph is constructed between the words; a weight ranking is determined based on the connectivity weight graph; and the keywords are determined based on the weight ranking.
[0066] Taking the PageRank method as an example, its principle can be found in the following formula (1):
[0067] PR(A)=(1-d)+d(PR(T1) / C(T1)+……+PR(Tn) / C(Tn)) (1)
[0068] Wherein, PR(A) is the PR value of word A, which in this embodiment can be the ranking value;
[0069] PR(Ti) is the PR value of word Ti; where word Ti is any word associated with word A; and where i = 1 to n.
[0070] C(Ti) is the out-degree of word Ti, that is, the number of edges from word Ti to other words; where i = 1 to n.
[0071] d is the damping coefficient.
[0072] In another approach, the keyword extraction method may include: inputting the statement to be enhanced into a pre-trained topic model, outputting candidate keywords and the article topic corresponding to the statement to be enhanced; determining and sorting the similarity between the article topic and the candidate keywords, and taking the top n candidate keywords as the keywords, where n is an integer greater than 1.
[0073] The final result can be obtained by taking the union of the two methods mentioned above.
[0074] 102. The keywords are masked to obtain the processed statement to be enhanced. The processed statement to be enhanced is then input into the intent classification model to obtain multiple enhanced prediction statements.
[0075] Specifically, see Figure 2 In step 102, the keywords are masked to obtain the processed statement to be enhanced, including:
[0076] 201. Determine the number of character units included in each of the aforementioned keywords.
[0077] 202. Determine the keyword coverage ratio corresponding to different numbers of character units.
[0078] 203. Based on the masking ratio, the keywords corresponding to different numbers of word units in the sentence to be enhanced are masked to obtain the processed sentence to be enhanced.
[0079] In this embodiment, an N-Gram masking task is performed on some keywords. For example, in one approach, the masking ratio of a keyword containing one character unit is determined to be 0.3, the masking ratio of a keyword containing two character units is 0.4, and the masking ratio of a keyword containing three character units is 0.3. Then, all keywords in the text to be enhanced are masked proportionally, i.e., replaced with a mask, to obtain the processed text to be enhanced.
[0080] In this embodiment, the intent classification model is obtained by performing a training task using initial sample statements. The initial sample statements include labeled statements and unlabeled statements. The training task includes a word masking prediction task based on the initial sample statements and an intent classification task based on the labeled statements.
[0081] Taking the BERT model as an example of an intent classification model, the existing BERT model's pre-training task is a random word mask prediction task. This task is relatively simple: randomly selected words are replaced with masks, and the model learns the masked content, thus allowing the BERT model to learn the word vector representations. Because the masks are random, the selected words are scattered, making it difficult to learn the relationships between words effectively, especially the connections between words.
[0082] For example, taking the statement "I am going to work", replacing "am" and "to" with "mask" will generate the statement to be predicted, "I <mask>going <mask>The sentence to be predicted is input into the BERT model, with the goal of outputting "I am going to work", so that the BERT model can identify the relationship between the words in the sentence.
[0083] In this embodiment, during the training of the intent classification model, two training tasks are performed: a word masking prediction task based on the initial sample sentences and an intent classification task based on the labeled sentences, in order to improve the robustness of the intent classification model and thus improve the performance of the model.
[0084] 103. The enhanced prediction statement is evaluated using the first evaluation function, and the enhanced prediction statement with the highest evaluation score is taken as the final enhanced statement.
[0085] The first evaluation function is used to evaluate the combined value of semantic similarity and content difference between the statement to be enhanced and the predicted enhanced statement.
[0086] Specifically, the first evaluation function includes the following equations (2)-(4):
[0087] T1=Min(J(A1,B1))+Max(Sim(A1,B1)) (2)
[0088] Wherein, J(A1,B1) is the content difference between the statement to be enhanced A1 and the enhanced prediction statement B1;
[0089]
[0090] Sim(A1,B1) represents the semantic similarity between the statement to be enhanced, A1, and the predicted enhanced statement, B1.
[0091]
[0092] For example, by inputting the processed statement to be enhanced into the intent classification model, five enhanced prediction statements are obtained. Then, the five enhanced prediction statements are evaluated using a first evaluation function, and the evaluation scores obtained are 0.8, 0.7, 0.65, 0.53, and 0.3, respectively. The enhanced prediction statement with an evaluation score of 0.8 is selected as the final enhanced statement.
[0093] 104. Input the final enhanced statement back into the intent classification model to determine the intent classification corresponding to the final enhanced statement.
[0094] It should be noted that the intent classification model in this embodiment can perform two tasks: augmentation prediction and intent classification.
[0095] For example, if the final enhanced statement is "find the route to Beijing", then the final intent category is determined to be "route query"; if the final enhanced statement is "find the weather in Beijing", then the final intent category is determined to be "weather query".
[0096] Correspondingly, by performing the two training tasks mentioned above on the intent classification model during the training phase, the robustness of the model can be improved, enabling the model to perform better when executing tasks.
[0097] The intent classification method provided in this invention uses a trained intent classification model to obtain multiple enhanced prediction statements based on the input statement to be enhanced. These enhanced prediction statements are then evaluated using a first evaluation function, and the statement with the highest evaluation score is selected as the final enhanced statement. The final enhanced statement is then input back into the intent classification model to determine the intent classification corresponding to it. The intent classification model is jointly trained by performing a word masking prediction task and an intent classification task. This not only effectively utilizes unlabeled statements in the initial sample statements, avoiding the negative impact of semantic changes caused by manual annotation on the model's training process, but also improves the robustness of the intent classification model, thereby enhancing its recognition performance.
[0098] After determining the intent category corresponding to the final enhanced statement, the enhanced statement carrying the intent category label and the statement to be enhanced are added to the training set as training corpus, and the intent classification model is retrained. The verification results are shown in Table 1 below:
[0099] Table 1
[0100] Training data Model Intent classification accuracy Original training set Bert 0.88 Added to the training set of enhanced sentences Bert 0.93
[0101] As can be seen from the data in the table, the enhanced statements generated by the method in this embodiment can significantly improve the accuracy and robustness of intent classification.
[0102] Furthermore, the training process of the intent classification model in this embodiment of the invention will be described below. The intent classification model in this embodiment of the invention includes two training tasks:
[0103] For the first training task, which is a word masking prediction task based on the initial sample sentences, see [link to training task]. Figure 3 ,include:
[0104] Step 301: Extract sample keywords from the initial sample statement.
[0105] Step 302: Mask the initial sample statement by removing sample keywords to obtain a masked sample statement.
[0106] Specifically, step 302 includes: determining the number of character units included in each of the sample keywords; setting the masking ratio of sample keywords corresponding to different numbers of character units; and masking the sample keywords corresponding to different numbers of character units in the initial sample statement based on the masking ratio to obtain the masked sample statement.
[0107] In this embodiment, an N-Gram masking task is performed on the sample keywords. For example, in one approach, the masking ratio of keywords with 1 character unit is determined to be 0.3, the masking ratio of keywords with 2 character units is 0.4, and the masking ratio of keywords with 3 character units is 0.3. Then, all keywords in the sentences to be enhanced in the text are masked proportionally, thereby increasing the difficulty of the training task and improving the training effect of the intent classification model.
[0108] Step 303: Input the masked sample statement into the intent classification model and output the augmented sample statement corresponding to each masked sample statement.
[0109] Step 304: Determine the content difference and semantic similarity between the initial sample statement and the enhanced sample statement.
[0110] Step 305: Based on the preset second evaluation function and the content difference and semantic similarity between the initial sample statement and the enhanced sample statement, train the intent classification model until the second evaluation function reaches the convergence condition.
[0111] The second evaluation function is used to evaluate the combined value of the content difference and semantic similarity between the initial sample statement and the enhanced sample statement, as shown in equations (5)-(7):
[0112] T2=Min(J(A2,B2))+Max(Sim(A2,B2)) (5)
[0113] Where J(A2,B2) is the content difference between the initial sample statement A2 and the enhanced sample statement B2;
[0114]
[0115] Sim(A2,B2) represents the semantic similarity between the statement to be enhanced, A2, and the predicted enhanced statement, B2.
[0116]
[0117] As can be seen from the above formula, in order to generate sentences with greater differences in content and higher semantics, the T2 second evaluation function is used as an evaluation method to select the optimal intent classification model during training.
[0118] In the first training task, the samples used for training are initial sample statements, where the initial sample statements include labeled statements and unlabeled statements.
[0119] For the second training task, through a preset loss function, the labeled statements and their corresponding intent classification labels are used to perform supervised training on the intent classification model until the loss value of the loss function is less than a preset value.
[0120] Among them, the loss function is shown in the following formula (8):
[0121]
[0122] Among them, x i represents the i-th labeled statement, y i represents the intent classification label corresponding to the i-th labeled statement, and h(x i ) represents the mapping function between the i-th labeled statement and its corresponding intent classification label; l represents the number of labeled statements.
[0123] To further illustrate the method of this embodiment, a specific example is used for illustrative explanation below.
[0124] See Figure 4 and Figure 5 , the method for intent classification of this embodiment includes:
[0125] 401. Extract keywords from the statement to be enhanced.
[0126] For example, extract keywords from the statement to be enhanced "Help me check the weather tomorrow", such as "weather". Correspondingly, both "day" and "weather" are used as keywords.
[0127] 402. Determine the number of character units included in each of the keywords.
[0128] Determine that the number of character units included in the keyword "day" is 1, and the number of character units included in the keyword "weather" is 2.
[0129] 403. Set the masking ratio of keywords corresponding to different numbers of character units.
[0130] 404. Based on the masking ratio, perform masking processing on the keywords corresponding to different numbers of character units in the statement to be enhanced respectively, to obtain the processed statement to be enhanced.
[0131] In this embodiment, the processed statement to be enhanced "Help me check tomorrow <mask> <mask> <mask>".
[0132] 405. Input the processed statement to be enhanced into the intent classification model to obtain multiple enhanced prediction statements.
[0133] In this embodiment, the obtained enhanced prediction statement includes:
[0134] Could you check the weather forecast for tomorrow?
[0135] Could you check the weather for tomorrow?
[0136] Could you please check the celestial phenomena for me tomorrow?
[0137] 406. The enhanced prediction statement is evaluated using the first evaluation function, and the enhanced prediction statement with the highest evaluation score is taken as the final enhanced statement.
[0138] The first evaluation function is used to evaluate the combined value of semantic similarity and content difference between the statement to be enhanced and the predicted enhanced statement.
[0139] The evaluation score of the enhanced prediction statement is as follows:
[0140] Please check tomorrow's weather forecast for me; the corresponding assessment score is 0.8.
[0141] Please check tomorrow's weather for me; the corresponding assessment score is 0.3.
[0142] Please check the weather for tomorrow; the corresponding assessment score is 0.
[0143] As can be seen from the above, any enhanced prediction statement that is completely identical to the statement to be enhanced should be excluded. Ultimately, "Check tomorrow's weather for me" was chosen as the final enhanced statement.
[0144] 407. Input the final enhanced statement "Help me check tomorrow's weather" back into the intent classification model, and determine that the intent classification corresponding to the final enhanced statement is "weather query".
[0145] The method in this embodiment also brings the following technical effects:
[0146] 1) By modifying the pre-training task to combine the two training tasks, the problems of semantic changes and grammatical incoherence caused by text modification enhancement in existing technologies can be effectively solved.
[0147] 2) It can utilize both labeled and unlabeled statements, reducing the cost of labeling resources.
[0148] 3) It can significantly improve the quality of text generated by text enhancement, ensure semantic consistency and grammatical fluency, and reduce sentence confusion.
[0149] 4) After adding the generated final augmented statements to the training data, the accuracy of the model's intent classification can be significantly improved.
[0150] The apparatus for classifying intent provided by the present invention will now be described. The apparatus for classifying intent described below can be referred to in correspondence with the method for classifying intent described above.
[0151] This invention discloses an apparatus for intent classification, see [link to relevant documentation]. Figure 6 ,include:
[0152] Extraction module 601 is used to extract keywords from the statement to be enhanced;
[0153] The enhancement prediction module 602 is used to mask the keywords to obtain the processed statement to be enhanced, and input the processed statement to be enhanced into the intent classification model to obtain multiple enhanced prediction statements.
[0154] Evaluation module 603 is used to evaluate the enhanced prediction statement through a first evaluation function, and take the enhanced prediction statement with the highest evaluation score as the final enhanced statement; wherein, the first evaluation function is used to evaluate the comprehensive value of semantic similarity and content difference between the statement to be enhanced and the enhanced prediction statement;
[0155] The intent classification module 604 is used to input the final enhanced statement back into the intent classification model to determine the intent classification corresponding to the final enhanced statement.
[0156] The intent classification model is obtained by performing a training task using initial sample statements, wherein the initial sample statements include labeled statements and unlabeled statements, and the training task includes a word masking prediction task based on the initial sample statements and an intent classification task based on the labeled statements.
[0157] Optionally, the extraction module 601 is specifically used for:
[0158] The sentence to be enhanced is segmented into multiple words;
[0159] Construct a connectivity weight graph between words, determine the weight ranking based on the connectivity weight graph between words, and determine the keywords based on the weight ranking;
[0160] or
[0161] The sentence to be enhanced is input into a pre-trained topic model, which outputs candidate keywords and the article topic corresponding to the sentence to be enhanced.
[0162] The similarity between the article topic and the candidate keywords is determined and sorted. The top n candidate keywords are used as the keywords, where n is an integer greater than 1.
[0163] Optionally, the enhanced prediction module 602 is specifically used for:
[0164] Determine the number of character units included in each keyword;
[0165] Set the keyword masking ratio corresponding to different numbers of character units;
[0166] Based on the masking ratio, keywords corresponding to different numbers of word units in the sentence to be enhanced are masked to obtain the processed sentence to be enhanced.
[0167] Optionally, the device further includes a first training module for:
[0168] Extract sample keywords from the initial sample statements;
[0169] The initial sample statements are masked by sample keywords to obtain masked sample statements. The masked sample statements are then input into the intent classification model, and the augmented sample statements corresponding to each masked sample statement are output.
[0170] Determine the content difference and semantic similarity between the initial sample statement and the enhanced sample statement;
[0171] The intent classification model is trained based on a preset second evaluation function and the content difference and semantic similarity between the initial sample statement and the enhanced sample statement until the second evaluation function reaches the convergence condition; wherein, the second evaluation function is used to evaluate the comprehensive value of the content difference and semantic similarity between the initial sample statement and the enhanced sample statement.
[0172] Optionally, the first training module is specifically used for:
[0173] Determine the number of character units included in each of the sample keywords;
[0174] Set the masking ratio of sample keywords corresponding to different numbers of character units;
[0175] Based on the masking ratio, the sample keywords corresponding to different numbers of word units in the initial sample statement are masked to obtain the masked sample statement.
[0176] Optionally, the device further includes a second training module for:
[0177] The intent classification model is trained in a supervised manner using the labeled statements and their corresponding intent classification labels through a preset loss function until the loss value of the loss function is less than a preset value.
[0178] Optionally, the first evaluation function includes:
[0179] T=Min(J(A1,B1))+Max(Sim(A1,B1))
[0180] Wherein, J(A1,B1) is the content difference between the statement to be enhanced A1 and the enhanced prediction statement B1;
[0181]
[0182] Sim(A1,B1) represents the semantic similarity between the statement to be enhanced, A1, and the predicted enhanced statement, B1.
[0183]
[0184] The intent classification apparatus provided in this embodiment of the invention obtains multiple enhanced prediction statements based on the input statement to be enhanced using a trained intent classification model. The enhanced prediction statements are then evaluated using a first evaluation function, and the enhanced prediction statement with the highest evaluation score is selected as the final enhanced statement. This final enhanced statement is then input back into the intent classification model to determine the intent classification corresponding to the final enhanced statement. The intent classification model is jointly trained by performing a word masking prediction task and an intent classification task. This not only effectively utilizes unlabeled statements in the initial sample statements, avoiding the negative impact of semantic changes caused by manual annotation on the model's training process, but also improves the robustness of the intent classification model, thereby enhancing the model's recognition performance.
[0185] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7 As shown, the electronic device may include: a processor 710, a communications interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communications interface 720, and the memory 730 communicate with each other via the communication bus 740. The processor 710 can invoke logical instructions in the memory 730 to execute an intent classification method, which includes:
[0186] Extract keywords from the sentences to be enhanced;
[0187] The keywords are masked to obtain the processed statement to be enhanced. The processed statement to be enhanced is then input into the intent classification model to obtain multiple enhanced prediction statements.
[0188] The enhanced prediction statement is evaluated using a first evaluation function, and the enhanced prediction statement with the highest evaluation score is taken as the final enhanced statement; wherein, the first evaluation function is used to evaluate the combined value of semantic similarity and content difference between the statement to be enhanced and the enhanced prediction statement;
[0189] The final enhanced statement is then input into the intent classification model to determine the intent classification corresponding to the final enhanced statement.
[0190] The intent classification model is obtained by performing a training task using initial sample statements, wherein the initial sample statements include labeled statements and unlabeled statements, and the training task includes a word masking prediction task based on the initial sample statements and an intent classification task based on the labeled statements.
[0191] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0192] On the other hand, the present invention also provides a computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to perform the intent classification method provided by the above methods, the method comprising:
[0193] Extract keywords from the sentences to be enhanced;
[0194] The keywords are masked to obtain the processed statement to be enhanced. The processed statement to be enhanced is then input into the intent classification model to obtain multiple enhanced prediction statements.
[0195] The enhanced prediction statement is evaluated using a first evaluation function, and the enhanced prediction statement with the highest evaluation score is taken as the final enhanced statement; wherein, the first evaluation function is used to evaluate the combined value of semantic similarity and content difference between the statement to be enhanced and the enhanced prediction statement;
[0196] The final enhanced statement is then input into the intent classification model to determine the intent classification corresponding to the final enhanced statement.
[0197] The intent classification model is obtained by performing a training task using initial sample statements, wherein the initial sample statements include labeled statements and unlabeled statements, and the training task includes a word masking prediction task based on the initial sample statements and an intent classification task based on the labeled statements.
[0198] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for classifying intents provided by the methods described above, the method comprising:
[0199] Extract keywords from the sentences to be enhanced;
[0200] The keywords are masked to obtain the processed statement to be enhanced. The processed statement to be enhanced is then input into the intent classification model to obtain multiple enhanced prediction statements.
[0201] The enhanced prediction statement is evaluated using a first evaluation function, and the enhanced prediction statement with the highest evaluation score is taken as the final enhanced statement; wherein, the first evaluation function is used to evaluate the combined value of semantic similarity and content difference between the statement to be enhanced and the enhanced prediction statement;
[0202] The final enhanced statement is then input into the intent classification model to determine the intent classification corresponding to the final enhanced statement.
[0203] The intent classification model is obtained by performing a training task using initial sample statements, wherein the initial sample statements include labeled statements and unlabeled statements, and the training task includes a word masking prediction task based on the initial sample statements and an intent classification task based on the labeled statements.
[0204] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0205] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0206] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.< / mask> < / mask> < / mask> < / mask> < / mask>
Claims
1. A method for classifying intents, characterized in that, include: Extract keywords from the sentences to be enhanced; The keywords are masked to obtain the processed statement to be enhanced. The processed statement to be enhanced is then input into the intent classification model to obtain multiple enhanced prediction statements. The enhanced prediction statement is evaluated using a first evaluation function, and the enhanced prediction statement with the highest evaluation score is taken as the final enhanced statement; wherein, the first evaluation function is used to evaluate the combined value of semantic similarity and content difference between the statement to be enhanced and the enhanced prediction statement; The final enhanced statement is then input into the intent classification model to determine the intent classification corresponding to the final enhanced statement. The intent classification model is obtained by performing a training task using initial sample sentences, which include labeled sentences and unlabeled sentences. The training task includes a word masking prediction task based on the initial sample sentences and an intent classification task based on the labeled sentences. Extract keywords from the statement to be enhanced, including: The sentence to be enhanced is input into a pre-trained topic model, which outputs candidate keywords and the article topic corresponding to the sentence to be enhanced. The similarity between the article topic and the candidate keywords is determined and sorted. The top n candidate keywords are used as the keywords, where n is an integer greater than 1.
2. The method for classifying intent according to claim 1, characterized in that, Extracting keywords from the statements to be enhanced also includes: The sentence to be enhanced is segmented into multiple words; Construct a connectivity weight graph between words, determine the weight ranking based on the connectivity weight graph between words, and determine the keywords based on the weight ranking.
3. The method for classifying intents according to claim 1, characterized in that, The keywords are masked to obtain the processed statement to be enhanced, including: Determine the number of character units included in each keyword; Set the keyword masking ratio corresponding to different numbers of character units; Based on the masking ratio, keywords corresponding to different numbers of word units in the sentence to be enhanced are masked to obtain the processed sentence to be enhanced.
4. The method for classifying intents according to claim 1, characterized in that, The intent classification model is trained based on the word masking prediction task of the initial sample sentences, including: Extract sample keywords from the initial sample statements; The initial sample statements are masked by sample keywords to obtain masked sample statements. The masked sample statements are then input into the intent classification model, and the augmented sample statements corresponding to each masked sample statement are output. Determine the content difference and semantic similarity between the initial sample statement and the enhanced sample statement; The intent classification model is trained based on a preset second evaluation function and the content difference and semantic similarity between the initial sample statement and the enhanced sample statement until the second evaluation function reaches the convergence condition; wherein, the second evaluation function is used to evaluate the comprehensive value of the content difference and semantic similarity between the initial sample statement and the enhanced sample statement.
5. The method for classifying intent according to claim 4, characterized in that, The initial sample statement is masked by masking sample keywords to obtain a masked sample statement, including: Determine the number of character units included in each of the sample keywords; Set the masking ratio of sample keywords corresponding to different numbers of character units; Based on the masking ratio, the sample keywords corresponding to different numbers of word units in the initial sample statement are masked to obtain the masked sample statement.
6. The method for classifying intents according to claim 1, characterized in that, Training the intent classification model based on the intent classification task of the labeled statements includes: The intent classification model is trained in a supervised manner using the labeled statements and their corresponding intent classification labels through a preset loss function until the loss value of the loss function is less than a preset value.
7. The method for classifying intents according to claim 1, characterized in that, The first evaluation function includes: T=Min(J(A1,B1))+Max(Sim(A1,B1)) Wherein, J(A1,B1) is the content difference between the statement to be enhanced A1 and the enhanced prediction statement B1; Sim(A1,B1) represents the semantic similarity between the statement to be enhanced, A1, and the predicted enhanced statement, B1. 。 8. An apparatus for classifying intended data, characterized in that, include: The extraction module is used to extract keywords from the statements to be enhanced; The enhancement prediction module is used to mask the keywords to obtain the processed statement to be enhanced, and input the processed statement to be enhanced into the intent classification model to obtain multiple enhanced prediction statements. An evaluation module is used to evaluate the enhanced prediction statement through a first evaluation function, and to take the enhanced prediction statement with the highest evaluation score as the final enhanced statement; wherein, the first evaluation function is used to evaluate the combined value of semantic similarity and content difference between the statement to be enhanced and the enhanced prediction statement; The intent classification module is used to input the final enhanced statement back into the intent classification model to determine the intent classification corresponding to the final enhanced statement. The intent classification model is obtained by performing a training task using initial sample sentences, wherein the initial sample sentences include labeled sentences and unlabeled sentences, and the training task includes a word masking prediction task based on the initial sample sentences and an intent classification task based on the labeled sentences. The extraction module is specifically used for: The sentence to be enhanced is input into a pre-trained topic model, which outputs candidate keywords and the article topic corresponding to the sentence to be enhanced. The similarity between the article topic and the candidate keywords is determined and sorted. The top n candidate keywords are used as the keywords, where n is an integer greater than 1.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the intention classification method as described in any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the intention classification method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Data processing method and device
CN111611790A
Conversation intention intelligent identification model construction method, and device, equipment
CN112131890A
Object query method and device based on keyword extraction, medium and equipment
CN112818091A
Intention recognition model updating method and related equipment
CN113792540A