Text classification method and device

By obtaining and expanding sample questions of sub-intentions, and merging sub-intentions according to the confusion matrix, the problem of long time-consuming text classification and low accuracy in the customer service robot dialogue system is solved, automated and efficient classification is achieved, and the efficiency of business expansion is improved.

CN112256844BActive Publication Date: 2024-09-20BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201911148366.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-11-21
Publication Date
2024-09-20
Estimated Expiration
2039-11-21

AI Technical Summary

Technical Problem

In the customer service robot dialogue system, the existing text classification method is time-consuming and has low accuracy during business expansion, requiring a lot of manpower to label and adjust the classification model.

Method used

By obtaining the example questions corresponding to each sub-intent in the current scenario, use the text matching algorithm to expand the example questions, and merge the sub-intentions according to the confusion matrix and confusion degree, and automatically classify until the preset accuracy and recall thresholds are reached.

Benefits of technology

It achieves automatic and reasonable classification of online corpus in new scenarios, reduces manual time-consuming, improves classification accuracy, and reduces the cost of business expansion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112256844B
    Figure CN112256844B
Patent Text Reader

Abstract

The present application provides a text classification method and device. The method includes: obtaining example questions corresponding to each sub-intention in the current scenario, the example questions are standard questions for a type of question, expanding the example questions corresponding to each sub-intention according to the questions input by the user in the current scenario and the text matching algorithm, obtaining the example questions corresponding to each sub-intention after expansion, merging all sub-intentions according to the confusion matrix, the confusion between every two sub-intentions and the example questions corresponding to each sub-intention after expansion, and obtaining N sub-intentions, where N is a positive integer. This realizes automatic and reasonable classification of online corpus in new scenarios, which is time-saving compared to manual work and improves accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a text classification method and device. Background Art

[0002] At present, in the customer service robot dialogue system, text classification is mainly used to identify the intention of user queries, and plays a very important role in the customer service robot dialogue system. The process of text classification is: first, manually take online corpus (that is, the questions entered by the user) for annotation, and after the annotation is completed, the annotated data is confuse-tuned to adjust the classification, so that the classification is more reasonable, and finally the classification model is obtained by training the classification algorithm to adjust the classified data.

[0003] Business expansion in the customer service robot dialogue system usually requires a lot of manpower for labeling and adjusting classification, and training new classification models to adapt to new scenarios. In the prior art, when expanding business, business personnel will analyze online corpus, then classify online corpus according to business type, and then label all online corpus of new scenarios according to the classification results. Similarly, after labeling, the labeled data is obfuscated and optimized to adjust the classification, so that the classification is more reasonable. Finally, the classification model is obtained by training the classified data through the classification algorithm.

[0004] When business personnel classify online corpus according to business types, they usually merge some sub-intents (referring to a type of question that a customer service robot can directly answer in a scenario) into a large category according to the business type. Manual classification is time-consuming and has low accuracy. Summary of the invention

[0005] The present application provides a text classification method and device to solve the problem that the existing methods are time-consuming and have low accuracy during business development.

[0006] In a first aspect, the present application provides a text classification method, comprising:

[0007] Obtaining example questions corresponding to each sub-intent in the current scenario, where the example questions are standard questions for a certain type of question;

[0008] Expanding the example questions corresponding to each sub-intent according to the question input by the user in the current scenario and the text matching algorithm to obtain the expanded example questions corresponding to each sub-intent;

[0009] According to the confusion matrix, the degree of confusion between every two sub-intentions and the example questions corresponding to each expanded sub-intention, all sub-intentions are merged to obtain N sub-intentions, where N is a positive integer.

[0010] Furthermore, the example questions corresponding to each sub-intent are expanded according to the question input by the user in the current scenario and the text matching algorithm to obtain the expanded example questions corresponding to each sub-intent, including:

[0011] Filtering, by a text matching algorithm, the questions input by the user in the current scenario to find example questions that match the example questions corresponding to each sub-intent;

[0012] The screened example questions that match the example questions corresponding to each sub-intent are used as the example questions corresponding to each expanded sub-intent.

[0013] Furthermore, according to the confusion matrix, the confusion degree between every two sub-intents and the example problem corresponding to each sub-intent after expansion, all sub-intents are merged to obtain N sub-intents, including:

[0014] S1. Input the example questions corresponding to each sub-intent into the confusion matrix in turn, and obtain the sub-intent predicted by each example question, the harmonic mean of the precision and recall of each sub-intent, and the harmonic mean of the overall precision and recall of all sub-intents;

[0015] S2, calculate the confusion degree of any two sub-intentions among all sub-intentions based on the actual example questions and predicted example questions corresponding to the sub-intentions;

[0016] S3. Merge the M sub-intentions with the largest confusion to obtain a new sub-intention, where M is a preset positive integer, and the number of example questions corresponding to the new sub-intention is the sum of the number of example questions corresponding to the M sub-intentions with the largest confusion;

[0017] Continue to execute S1-S3 according to the new sub-intent and sub-intents other than the M sub-intents until the number of all sub-intents reaches N, where N is a preset value; or,

[0018] Continue to execute S1-S3 according to the new sub-intention and sub-intentions other than the M sub-intentions until the harmonic mean of the precision and recall of each of the N sub-intentions is greater than the first preset threshold, and the harmonic mean of the overall precision and recall of the N sub-intentions is greater than the second preset threshold.

[0019] Furthermore, the calculation of the confusion degree of any two sub-intentions among all sub-intentions according to the actual example questions and the predicted example questions corresponding to the sub-intentions includes:

[0020] According to the actual example questions and predicted example questions corresponding to the sub-intents, the confusion degree of any two sub-intents catei and catej in all sub-intents is calculated by the following calculation formula:

[0021]

[0022] Among them, N catei,catej N is the number of example questions where the actual sub-intention is catei but is predicted to be catej. catei Indicates the number of actual example problems of catei, Indicates the number of example questions predicted to be catei.

[0023] Furthermore, before calculating the confusion degree of any two sub-intentions among all sub-intentions according to the actual example questions and the predicted example questions corresponding to the sub-intentions, the method further includes:

[0024] Determine that the harmonic mean of the precision and recall of each sub-intention is less than the first preset threshold, and the harmonic mean of the overall precision and recall of all sub-intentions is less than the second preset threshold.

[0025] In a second aspect, the present application provides a text classification device, comprising:

[0026] An acquisition module is used to obtain example questions corresponding to each sub-intent in the current scenario, where the example questions are standard questions of a type;

[0027] A question expansion module, used to expand the example questions corresponding to each sub-intent according to the question input by the user in the current scenario and the text matching algorithm, to obtain the example questions corresponding to each sub-intent after expansion;

[0028] A processing module is used to merge all sub-intentions according to the confusion matrix, the degree of confusion between every two sub-intentions and the example questions corresponding to each expanded sub-intention to obtain N sub-intentions, where N is a positive integer.

[0029] Furthermore, the question expansion module is used to:

[0030] Filtering, by a text matching algorithm, the questions input by the user in the current scenario to find example questions that match the example questions corresponding to each sub-intent;

[0031] The screened example questions that match the example questions corresponding to each sub-intent are used as the example questions corresponding to each expanded sub-intent.

[0032] Furthermore, the processing module is used to perform the following operations:

[0033] S1. Input the example questions corresponding to each sub-intent into the confusion matrix in turn, and obtain the sub-intent predicted by each example question, the harmonic mean of the precision and recall of each sub-intent, and the harmonic mean of the overall precision and recall of all sub-intents;

[0034] S2, calculate the confusion degree of any two sub-intentions among all sub-intentions based on the actual example questions and predicted example questions corresponding to the sub-intentions;

[0035] S3. Merge the M sub-intentions with the largest confusion to obtain a new sub-intention, where M is a preset positive integer, and the number of example questions corresponding to the new sub-intention is the sum of the number of example questions corresponding to the M sub-intentions with the largest confusion;

[0036] Continue to execute S1-S3 according to the new sub-intent and sub-intents other than the M sub-intents until the number of all sub-intents reaches N, where N is a preset value; or,

[0037] Continue to execute S1-S3 according to the new sub-intention and sub-intentions other than the M sub-intentions until the harmonic mean of the precision and recall of each of the N sub-intentions is greater than the first preset threshold, and the harmonic mean of the overall precision and recall of the N sub-intentions is greater than the second preset threshold.

[0038] Furthermore, the processing module is specifically used for:

[0039] According to the actual example questions and predicted example questions corresponding to the sub-intents, the confusion degree of any two sub-intents catei and catej in all sub-intents is calculated by the following calculation formula:

[0040]

[0041] Among them, N catei,catej N is the number of example questions where the actual sub-intention is catei but is predicted to be catej. catei Indicates the number of actual example problems of catei, Indicates the number of example questions predicted to be catei.

[0042] Furthermore, the processing module is also used for:

[0043] Before calculating the confusion degree of any two sub-intentions among all sub-intentions based on the actual example questions and predicted example questions corresponding to the sub-intentions, determine that the harmonic mean of the precision and recall of each sub-intention is less than the first preset threshold, and the harmonic mean of the overall precision and recall of all sub-intentions is less than the second preset threshold.

[0044] The text classification method and device provided by the present application obtains the example questions corresponding to each sub-intention in the current scenario, expands the example questions corresponding to each sub-intention according to the questions input by the user in the current scenario and the text matching algorithm, obtains the example questions corresponding to each sub-intention after expansion, and finally merges all sub-intentions according to the confusion matrix, the confusion degree between every two sub-intentions and the example questions corresponding to each sub-intention after expansion, to obtain N sub-intentions. According to the confusion degree, multiple sub-intentions with more serious confusion are merged into one classification, thereby realizing automatic and reasonable classification of online corpus in new scenarios, which is time-saving compared to manual work and improves accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0046] Figure 1 A schematic diagram of an application scenario of this application;

[0047] Figure 2 A flowchart of an embodiment of a text classification method provided by the present application;

[0048] Figure 3 A flowchart of an embodiment of a text classification method provided by the present application;

[0049] Figure 4 A structural diagram of a text classification device provided in this application;

[0050] Figure 5 A schematic diagram of the hardware structure of the electronic device provided in this application. DETAILED DESCRIPTION

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

[0052] First, some terms in the embodiments of the present application are explained below to facilitate understanding by those skilled in the art.

[0053] 1. Example questions: These are standard questions that represent a certain type of question. For example, two example questions under the sub-intent of modifying the invoice header: 1. I want to modify the invoice header. 2. I want to modify the company name on the invoice header.

[0054] 2. Sub-intent refers to a type of question that the customer service robot can directly answer in a scenario.

[0055] 3. Online corpus, which is the questions entered by users when talking to the customer service robot.

[0056] In the existing text classification methods, when business is expanded, business personnel usually classify online corpus according to business types, merge some sub-intentions (i.e., corpus sets under a type of scenario) into a large category according to business types, and then annotate all online corpus of the new scenario according to the classification results. After the annotation is completed, the annotated data is confuse-tuned to adjust the classification, so that the classification is more reasonable, and finally the classification model is obtained by training and adjusting the classified data through the classification algorithm. However, manual classification takes a long time and has low accuracy. To solve this problem, the present application provides a text classification method and device. After obtaining the example questions corresponding to each sub-intention in the current scenario, the example questions corresponding to each sub-intention are expanded according to the questions input by the user in the current scenario and the text matching algorithm, and the example questions corresponding to each sub-intention after expansion are obtained. The expanded example questions can basically contain all the sub-intentions of the current scenario. Finally, according to the confusion matrix, the confusion between every two sub-intentions, and the example questions corresponding to each sub-intention after expansion, all sub-intentions are merged to obtain N sub-intentions. Thus, the online corpus in the new scenario can be automatically and reasonably classified, which is time-saving and has higher accuracy than manual classification. The specific implementation process of the text classification method in the embodiment of the present application is described in detail below with reference to the accompanying drawings.

[0057] In the embodiment of the present application, the customer service robot is a machine device used to automatically perform conversation work, and can specifically be a terminal device such as a smart phone, tablet computer, laptop computer, or other machine devices with specific appearance and functions.

[0058] The text classification method of the present application may be performed by a text classification device. Figure 1 This is a schematic diagram of an application scenario of the present application, such as Figure 1As shown, in the process of dialogue between the customer service robot and the user, online corpus (i.e., questions input by the user) is generated. When expanding new scenarios, the relevant operators will first analyze the online corpus to obtain the example questions corresponding to each sub-intention in the current new scenario, and then input them into the text classification device provided by this application. After the text classification device provided by this application obtains the example questions corresponding to each sub-intention in the current new scenario, the sub-intentions are merged according to the text classification method provided by this application to obtain the classification results. After obtaining the classification results, the business personnel can then annotate all the online corpus of the new scenario according to the classification results. After the annotation is completed, the annotated data is obfuscated and optimized to adjust the classification, so as to make the classification more reasonable. Finally, the classification model is obtained by training the adjusted classified data through the classification algorithm.

[0059] Figure 2 A flowchart of an embodiment of a text classification method provided in this application, such as Figure 2 As shown, the method of this embodiment may include:

[0060] S101. Obtain example questions corresponding to each sub-intent in the current scenario, where the example questions are standard questions for a type of question.

[0061] Among them, when expanding new scenarios, relevant operators will first analyze the online corpus to obtain example questions corresponding to each sub-intention in the current new scenario. Usually, due to limited labor costs, the number of example questions obtained will be very small. In order to obtain more questions for the current scenario, S102 is then executed.

[0062] S102. Expand the example questions corresponding to each sub-intent according to the question input by the user in the current scenario and the text matching algorithm to obtain the expanded example questions corresponding to each sub-intent.

[0063] Specifically, S102 may specifically be: filtering out example questions that match the example questions corresponding to each sub-intention from the questions input by the user in the current scenario through a text matching algorithm, and using the screened out example questions that match the example questions corresponding to each sub-intention as the example questions corresponding to each expanded sub-intention. The text matching algorithm may be, for example, some similarity matching algorithms. After obtaining the example questions corresponding to each expanded sub-intention through the text matching algorithm, manual cleaning may be performed to improve accuracy. For example, the example questions corresponding to the sub-intentions obtained by the operator's analysis are usually 2-10, and the example questions corresponding to the sub-intentions obtained after expansion are 10-200, and the types of questions asked in the expanded example questions can basically cover all types of questions in this new scenario.

[0064] S103. According to the confusion matrix, the degree of confusion between every two sub-intentions and the example questions corresponding to each expanded sub-intention, all sub-intentions are merged to obtain N sub-intentions, where N is a positive integer.

[0065] As an implementable method, S103 may specifically include:

[0066] S1. Input the example questions corresponding to each sub-intent into the confusion matrix in turn, and obtain the sub-intent predicted by each example question, the harmonic mean of the precision and recall of each sub-intent, and the harmonic mean of the overall precision and recall of all sub-intents.

[0067] Among them, the confusion matrix (confusion_matrix) is a tool that can obtain the accuracy and recall of each classification in text classification to distinguish whether the classification is reasonable. This tool usually cuts the data into several equal (or similar) groups, and then selects one of the groups as the test set and the others as the training set to obtain the prediction results of all the data.

[0068] For example, Figure 1 There are 20 corresponding sample questions. Figure 1 The corresponding example questions are input into the confusion matrix in turn, and the output is the sub-intention predicted by each example question, the harmonic mean of the precision and recall of each sub-intention, and the harmonic mean of the overall precision and recall of all sub-intentions. The sub-intention predicted by each example question is the sub-intention predicted for each example question, for example, Figure 1 The corresponding sub-intention of example question 1 is Figure 2 , Ziyi Figure 1 The corresponding sub-intention of example question 2 is Figure 1 itself, etc.

[0069] S2. Calculate the confusion degree of any two sub-intentions among all sub-intentions based on the actual example questions and predicted example questions corresponding to the sub-intentions.

[0070] As an implementable method, S2 may specifically be:

[0071] According to the actual example questions and predicted example questions corresponding to the sub-intents, the confusion degree of any two sub-intents catei and catej in all sub-intents is calculated by the following calculation formula:

[0072]

[0073] Among them, N catei,catej N is the number of example questions where the actual sub-intention is catei but is predicted to be catej. cateiIndicates the number of actual example problems of catei, Indicates the number of example questions predicted to be catei.

[0074] S3. Merge the M sub-intentions with the greatest confusion to obtain a new sub-intention, where M is a preset positive integer, and the number of example questions corresponding to the new sub-intention is the sum of the number of example questions corresponding to the M sub-intentions with the greatest confusion.

[0075] Specifically, the M sub-intentions with the greatest confusion are the M sub-intentions with more serious confusion. The M sub-intentions with more serious confusion are merged into one sub-intention, also called merging into a large category. The number of example questions corresponding to the merged sub-intention is the sum of the number of example questions corresponding to the M sub-intentions, where M is a preset positive integer, and M can be preset according to the business type of the current scenario.

[0076] Then, in an implementable manner, S1-S3 is continued to be executed according to the new sub-intention and the sub-intentions other than the M sub-intentions until the number of all sub-intentions is N, where N is a preset value.

[0077] For example, 50 sub-intentions are obtained in S102, and each sub-intention corresponds to multiple example questions, for example, M is 3. After the first merge, the three sub-intentions with the largest confusion are merged into a new sub-intention, and finally 48 sub-intentions are obtained. Then, S1-S3 are executed on this new sub-intention and the other 47 sub-intentions, and the merge is continued. For example, N is preset to 30, until the number of all sub-intentions is 30.

[0078] In another practicable manner, S1-S3 is continued to be executed according to the new sub-intention and sub-intentions other than the M sub-intentions until the harmonic mean of the precision and recall of each of the N sub-intentions obtained is greater than the first preset threshold, and the harmonic mean of the overall precision and recall of the N sub-intentions is greater than the second preset threshold.

[0079] For example, 60 sub-intentions are obtained in S102, and each sub-intention corresponds to multiple example questions, for example, M is 5. After the first merging, the 5 sub-intentions with the largest confusion are merged into a new sub-intention, and finally 46 sub-intentions are obtained. Then, S1-S3 are executed on this new sub-intention and the other 45 sub-intentions, and the merging is continued until the harmonic mean of the precision and recall of each of the N sub-intentions obtained is greater than the first preset threshold, and the harmonic mean of the overall precision and recall of the N sub-intentions is greater than the second preset threshold. For example, N that meets the above conditions is 35.

[0080] In this embodiment, optionally, before S2, the following may also be included:

[0081] Determine that the harmonic mean of the precision and recall of each sub-intention is less than a first preset threshold, and the harmonic mean of the overall precision and recall of all sub-intentions is less than a second preset threshold.

[0082] Specifically, after executing S1 to obtain the harmonic mean of the accuracy and recall of each sub-intention and the harmonic mean of the overall accuracy and recall of all sub-intentions, first determine whether the harmonic mean of the accuracy and recall of each sub-intention is less than the first preset threshold, and whether the harmonic mean of the overall accuracy and recall of all sub-intentions is less than the second preset threshold. If so, continue to execute S2. If not, it means that the classification of all sub-intentions obtained in S102 is reasonable and no further classification is required.

[0083] The text classification method provided in this embodiment obtains the example questions corresponding to each sub-intention in the current scenario, expands the example questions corresponding to each sub-intention according to the questions input by the user in the current scenario and the text matching algorithm, obtains the example questions corresponding to each sub-intention after expansion, and finally merges all sub-intentions according to the confusion matrix, the degree of confusion between every two sub-intentions and the example questions corresponding to each sub-intention after expansion to obtain N sub-intentions. Multiple sub-intentions with more serious confusion are merged into one category according to the degree of confusion, that is, sub-intentions with similar questions are merged into one category. Thereby, automatic and reasonable classification of online corpus in new scenarios is achieved, which is time-saving compared to manual work and improves accuracy.

[0084] A specific embodiment is used below. Figure 2 The technical solution of the method embodiment shown is described in detail.

[0085] Figure 3 A flowchart of an embodiment of a text classification method provided in this application, such as Figure 3 As shown, the method of this embodiment may include:

[0086] S201. Obtain example questions corresponding to each sub-intent in the current scenario, where the example questions are standard questions for a type of question.

[0087] S202. Expand the example questions corresponding to each sub-intent according to the question input by the user in the current scenario and the text matching algorithm to obtain the expanded example questions corresponding to each sub-intent.

[0088] S203. Input the example questions corresponding to each sub-intention into the confusion matrix in turn to obtain the sub-intention predicted by each example question, the harmonic mean of the precision and recall of each sub-intention, and the harmonic mean of the overall precision and recall of all sub-intentions.

[0089] S204. Determine whether the harmonic mean of the precision and recall of each sub-intention is less than the first preset threshold, and whether the harmonic mean of the overall precision and recall of all sub-intentions is less than the second preset threshold. If so, execute S205. If not, it can be determined that the classification of all sub-intentions obtained in S202 is reasonable and no further classification is required.

[0090] S205. Calculate the degree of confusion between any two sub-intentions among all sub-intentions based on the actual example questions and predicted example questions corresponding to the sub-intentions.

[0091] Specifically, the confusion degree of any two sub-intents catei and catej in all sub-intents is calculated according to the actual example questions and predicted example questions corresponding to the sub-intents by the following calculation formula:

[0092]

[0093] Among them, N catei,catej N is the number of example questions where the actual sub-intention is catei but is predicted to be catej. catei Indicates the number of actual example problems of catei, Indicates the number of example questions predicted to be catei.

[0094] S206. Merge the M sub-intentions with the greatest confusion to obtain a new sub-intention, where M is a preset positive integer, and the number of example questions corresponding to the new sub-intention is the sum of the number of example questions corresponding to the M sub-intentions with the greatest confusion.

[0095] S207. Continue to execute S203-S206 according to the new sub-intent and sub-intents other than the M sub-intents until the number of all sub-intents is N, where N is a preset value.

[0096] Alternatively, continue to execute S203-S206 according to the new sub-intention and sub-intentions other than the M sub-intentions until the harmonic mean of the precision and recall of each of the N sub-intentions obtained is greater than the first preset threshold, and the harmonic mean of the overall precision and recall of the N sub-intentions is greater than the second preset threshold.

[0097] After S207 is executed to obtain N sub-intents, optionally, business personnel can make another adjustment based on these N sub-intents in combination with the business, and finally obtain the initial definition result of the classification, that is, some sub-intents of similar questions are merged into one classification.

[0098] It has been verified that the existing manual classification method needs more than 3 rounds of confusion tuning after labeling to meet the requirements (the first preset threshold is 0.7, and the second preset threshold is 0.85). With the method provided by this application, only 1-2 rounds of confusion tuning are needed after labeling to meet the requirements. Overall, according to actual statistics, the labor efficiency can be improved by 30%.

[0099] Figure 4 A structural diagram of a text classification device provided in this application, such as Figure 4 As shown, the device of this embodiment may include: an acquisition module 11, a question expansion module 12 and a processing module 13, wherein:

[0100] The acquisition module 11 is used to obtain the example questions corresponding to each sub-intent in the current scenario, where the example questions are standard questions of a type of question;

[0101] The question expansion module 12 is used to expand the example question corresponding to each sub-intent according to the question input by the user in the current scenario and the text matching algorithm to obtain the example question corresponding to each sub-intent after expansion;

[0102] The processing module 13 is used to merge all sub-intentions according to the confusion matrix, the degree of confusion between every two sub-intentions and the example questions corresponding to each expanded sub-intention, so as to obtain N sub-intentions, where N is a positive integer.

[0103] Optionally, the question expansion module 12 is used to:

[0104] Using a text matching algorithm, select example questions that match the example questions corresponding to each sub-intent from the questions entered by the user in the current scenario;

[0105] The screened example questions that match the example questions corresponding to each sub-intent are used as the example questions corresponding to each expanded sub-intent.

[0106] Optionally, the processing module 13 is used to perform the following operations:

[0107] S1. Input the example questions corresponding to each sub-intent into the confusion matrix in turn, and obtain the sub-intent predicted by each example question, the harmonic mean of the precision and recall of each sub-intent, and the harmonic mean of the overall precision and recall of all sub-intents;

[0108] S2, calculate the confusion degree of any two sub-intentions among all sub-intentions based on the actual example questions and predicted example questions corresponding to the sub-intentions;

[0109] S3. Merge the M sub-intentions with the largest confusion to obtain a new sub-intention, where M is a preset positive integer, and the number of example questions corresponding to the new sub-intention is the sum of the number of example questions corresponding to the M sub-intentions with the largest confusion;

[0110] Continue to execute S1-S3 according to the new sub-intention and the sub-intentions other than the M sub-intentions until the number of all sub-intentions reaches N, where N is a preset value; or,

[0111] Continue to execute S1-S3 according to the new sub-intention and sub-intentions other than the M sub-intentions until the harmonic mean of the precision and recall of each of the N sub-intentions obtained is greater than the first preset threshold, and the harmonic mean of the overall precision and recall of the N sub-intentions is greater than the second preset threshold.

[0112] Optionally, the processing module 13 is specifically used for:

[0113] According to the actual example questions and predicted example questions corresponding to the sub-intents, the confusion degree of any two sub-intents catei and catej in all sub-intents is calculated by the following calculation formula:

[0114]

[0115] Among them, N catei,catej N is the number of example questions where the actual sub-intention is catei but is predicted to be catej. catei Indicates the number of actual example problems of catei, Indicates the number of example questions predicted to be catei.

[0116] Optionally, the processing module 13 is further used for:

[0117] Before calculating the confusion degree of any two sub-intentions among all sub-intentions based on the actual example questions and predicted example questions corresponding to the sub-intentions, determine that the harmonic mean of the precision and recall of each sub-intention is less than a first preset threshold, and the harmonic mean of the overall precision and recall of all sub-intentions is less than a second preset threshold.

[0118] The device provided in the embodiment of the present application can execute the above method embodiment. Its specific implementation principle and technical effects can be found in the above method embodiment, and this embodiment will not be repeated here.

[0119] Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in this application. Figure 5 As shown, the electronic device 20 of this embodiment may include: a memory 21 and a processor 22;

[0120] A memory 21, used for storing computer programs;

[0121] The processor 22 is used to execute the computer program stored in the memory to implement the text classification method in the above embodiment. For details, please refer to the relevant description in the above method embodiment.

[0122] Optionally, the memory 21 may be independent or integrated with the processor 22 .

[0123] When the memory 21 is a device independent of the processor 22, the electronic device 20 may further include:

[0124] The bus 23 is used to connect the memory 21 and the processor 22 .

[0125] Optionally, this embodiment further includes: a communication interface 24, which can be connected to the processor 22 through the bus 23. The processor 22 can control the communication interface 23 to implement the above-mentioned receiving and sending functions of the electronic device 20.

[0126] The electronic device provided in this embodiment can be used to execute the above method, and its implementation method and technical effect are similar, which will not be described in detail in this embodiment.

[0127] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules 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 an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0128] The modules described as separate components may or may not be physically separated, and the components shown as modules 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 modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0129] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.

[0130] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the methods of various embodiments of the present application.

[0131] It should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented by a hardware processor or implemented by a combination of hardware and software modules in the processor.

[0132] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0133] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0134] The computer-readable storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium may be any available medium that can be accessed by a general or special purpose computer.

[0135] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0136] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A text classification method, characterized in that: include: Obtaining example questions corresponding to each sub-intent in the current scenario, where the example questions are standard questions for a certain type of question; Expanding the example questions corresponding to each sub-intent according to the question input by the user in the current scenario and the text matching algorithm to obtain the expanded example questions corresponding to each sub-intent; According to the confusion matrix, the confusion degree between every two sub-intents and the example questions corresponding to each expanded sub-intent, all sub-intents are merged to obtain N sub-intents, where N is a positive integer; According to the confusion matrix, the degree of confusion between every two sub-intents and the example questions corresponding to each expanded sub-intent, all sub-intents are merged to obtain N sub-intents, including: S1. Input the example questions corresponding to each sub-intent into the confusion matrix in turn, and obtain the sub-intent predicted by each example question, the harmonic mean of the precision and recall of each sub-intent, and the harmonic mean of the overall precision and recall of all sub-intents; S2. Calculate the confusion degree of any two sub-intents catei and catej among all sub-intents according to the actual example questions and predicted example questions corresponding to the sub-intents by using the following calculation formula; Among them, N catei,catej N is the number of example questions where the actual sub-intention is catei but is predicted to be catej. catei Indicates the number of actual example problems of catei, Indicates the number of example questions predicted to be catei; S3. Merge the M sub-intentions with the largest confusion to obtain a new sub-intention, where M is a preset positive integer, and the number of example questions corresponding to the new sub-intention is the sum of the number of example questions corresponding to the M sub-intentions with the largest confusion; Continue to execute S1-S3 according to the new sub-intent and sub-intents other than the M sub-intents until the number of all sub-intents reaches N, where N is a preset value; or, Continue to execute S1-S3 according to the new sub-intention and sub-intentions other than the M sub-intentions until the harmonic mean of the precision and recall of each of the N sub-intentions is greater than the first preset threshold, and the harmonic mean of the overall precision and recall of the N sub-intentions is greater than the second preset threshold.

2. The method according to claim 1, characterized in that The example questions corresponding to each sub-intent are expanded according to the question input by the user in the current scenario and the text matching algorithm to obtain the expanded example questions corresponding to each sub-intent, including: Filtering, by a text matching algorithm, the questions input by the user in the current scenario to find example questions that match the example questions corresponding to each sub-intent; The screened example questions that match the example questions corresponding to each sub-intent are used as the example questions corresponding to each expanded sub-intent.

3. The method according to claim 1, characterized in that Before calculating the confusion degree of any two sub-intentions among all sub-intentions according to the actual example questions and the predicted example questions corresponding to the sub-intentions, the method further includes: Determine that the harmonic mean of the precision and recall of each sub-intention is less than the first preset threshold, and the harmonic mean of the overall precision and recall of all sub-intentions is less than the second preset threshold.

4. A text classification device, characterized in that: include: An acquisition module is used to obtain example questions corresponding to each sub-intent in the current scenario, where the example questions are standard questions of a type; A question expansion module, used to expand the example questions corresponding to each sub-intent according to the question input by the user in the current scenario and the text matching algorithm, to obtain the example questions corresponding to each sub-intent after expansion; A processing module, used for merging all sub-intents according to the confusion matrix, the confusion degree between every two sub-intents and the example questions corresponding to each sub-intent after expansion, to obtain N sub-intents, where N is a positive integer; The processing module is used to perform the following operations: S1. Input the example questions corresponding to each sub-intent into the confusion matrix in turn, and obtain the sub-intent predicted by each example question, the harmonic mean of the precision and recall of each sub-intent, and the harmonic mean of the overall precision and recall of all sub-intents; S2. Calculate the confusion degree of any two sub-intents catei and catej among all sub-intents according to the actual example questions and predicted example questions corresponding to the sub-intents by using the following calculation formula; Among them, N catei,catej N is the number of example questions where the actual sub-intention is catei but is predicted to be catej. catei Indicates the number of actual example problems of catei, Indicates the number of example questions predicted to be catei; S3. Merge the M sub-intentions with the largest confusion to obtain a new sub-intention, where M is a preset positive integer, and the number of example questions corresponding to the new sub-intention is the sum of the number of example questions corresponding to the M sub-intentions with the largest confusion; Continue to execute S1-S3 according to the new sub-intent and sub-intents other than the M sub-intents until the number of all sub-intents reaches N, where N is a preset value; or, Continue to execute S1-S3 according to the new sub-intention and sub-intentions other than the M sub-intentions until the harmonic mean of the precision and recall of each of the N sub-intentions is greater than the first preset threshold, and the harmonic mean of the overall precision and recall of the N sub-intentions is greater than the second preset threshold.

5. The device according to claim 4, characterized in that The question expansion module is used to: Filtering, by a text matching algorithm, the questions input by the user in the current scenario to find example questions that match the example questions corresponding to each sub-intent; The screened example questions that match the example questions corresponding to each sub-intent are used as the example questions corresponding to each expanded sub-intent.

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

7. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the text classification method according to any one of claims 1 to 3 by executing the executable instructions.