Text classification model training method, text classification method, device and electronic equipment

By adjusting the text classification model and optimizing the sample set, the problems of inaccurate prediction and high computational cost in multi-level, multi-label text classification were solved, achieving more efficient text classification results.

CN114424186BActive Publication Date: 2026-01-23SHENZHEN HEYTAP TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201980100570.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-16
Publication Date
2026-01-23
Estimated Expiration
2039-12-16

AI Technical Summary

Technical Problem

Existing technologies for multi-level, multi-label text classification suffer from problems such as inaccurate prediction results, inability to iterate and learn, and high computational cost and time consumption.

Method used

By acquiring a text sample set, predicting text categories and comparing them with the actual results, the text classification model is adjusted until the prediction results meet the preset conditions. A new text sample set is then generated using preset processing methods, and training continues until the model's prediction results meet the conditions.

Benefits of technology

It improves the accuracy and efficiency of multi-level, multi-label text classification while reducing computational load and training time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114424186B_ABST
    Figure CN114424186B_ABST
Patent Text Reader

Abstract

A text classification model training method, a text classification method, a device and an electronic device. The training method comprises: obtaining a first text sample set (101), inputting the first text sample set into a text classification model to obtain a first prediction result (102), adjusting the text classification model if the first prediction result does not satisfy a preset condition (105), inputting a second sample set into the adjusted text classification model until the prediction result of the text classification model satisfies the preset condition (107).
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a text classification model training method, text classification method, apparatus and electronic equipment. Background Technology

[0002] With the rapid development of the internet and mobile internet, the number of documents to be analyzed has increased dramatically. Classifying and tagging text at different granularities (such as sentences, paragraphs, and documents) is crucial for information discovery, browsing, and analysis. For example, many business processes in content distribution rely on fine-grained tags for better performance. Fine-grained tags can enrich the user profile tag library, more accurately depict user characteristics, and support more granular recommendations in information streams. In actual business operations, tens of thousands of effective tags can be discovered, with thousands being particularly important. Therefore, the technology to tag text using large-scale, multi-level tag sets of thousands is especially crucial.

[0003] Currently, there are several approaches: one is to build a separate text classification model for each level of label and then integrate the inference results of multiple models; another is to use neural networks to build a multi-level text multi-label classification model and obtain the text category prediction results of the training text based on the model; yet another approach is to input the text to be classified into multiple trained text classification models, calculate the probability of each level of text, use the product of the probabilities of each level to infer the last level label, and use the label relationship between levels to infer the labels of each level.

[0004] However, the existing model solutions have several problems. First, they cannot achieve good prediction results for a large number of labels. Second, they cannot iteratively learn the model based on changes in labels and cannot predict the hierarchical relationship of labels well. Third, the computational load is large and the time consumption is long when processing a large number of labels. Summary of the Invention

[0005] This application provides a text classification model training method, a text classification method, an apparatus, and an electronic device to improve the accuracy of classifying multi-level, multi-label text.

[0006] In a first aspect, embodiments of this application provide a method for training a text classification model, including:

[0007] Obtain the first text sample set;

[0008] The first text sample set is input into the text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample;

[0009] The first prediction result is compared with the actual result to determine whether the first prediction result meets the preset conditions.

[0010] If the first prediction result does not meet the preset conditions, the text classification model is adjusted to obtain an adjusted text classification model.

[0011] According to the preset processing method, the target texts in the first text sample set whose first prediction results do not meet the preset conditions are processed to obtain the second text sample set;

[0012] The second text sample set is input into the adjusted text classification model for further training until the prediction result of the text classification model meets the preset conditions.

[0013] Secondly, this application provides a text classification method, including:

[0014] Get the text set to be classified;

[0015] Call the pre-trained text classification model;

[0016] The text set to be classified is input into the pre-trained text classification model to obtain the classification result of the text to be classified;

[0017] The text classification model mentioned therein is a text classification model obtained by using the training method of the text classification model provided in the embodiments of this application.

[0018] Thirdly, embodiments of this application provide a training apparatus for a text classification model, comprising:

[0019] The first acquisition module is used to acquire the first text sample set;

[0020] The prediction module is used to input the first text sample set into the text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample;

[0021] The judgment module is used to compare the first prediction result with the actual result and determine whether the first prediction result meets the preset conditions.

[0022] An adjustment module is used to adjust the text classification model if the first prediction result does not meet the preset conditions, so as to obtain an adjusted text classification model.

[0023] The processing module is used to process the target texts in the first text sample set whose first prediction results do not meet the preset conditions according to the preset processing method, so as to obtain the second text sample set.

[0024] The training module is used to input the second text sample set into the adjusted text classification model for further training until the prediction result of the text classification model meets the preset conditions.

[0025] Fourthly, embodiments of this application provide a text classification device, including:

[0026] The second acquisition module is used to acquire the text set to be classified;

[0027] The calling module is used to invoke a pre-trained text classification model;

[0028] The classification module is used to input the text set to be classified into the pre-trained text classification model to obtain the classification result of the text to be classified.

[0029] The text classification model mentioned therein is a text classification model obtained by using the training method of the text classification model provided in the embodiments of this application.

[0030] Fifthly, embodiments of this application provide a storage medium storing a computer program thereon, wherein when the computer program is executed on a computer, the computer causes the computer to execute the training method or text classification method of the text classification model provided in this embodiment.

[0031] Sixthly, embodiments of this application provide an electronic device, including a memory and a processor. The memory stores a computer program, and the processor executes the following by calling the computer program stored in the memory:

[0032] Obtain the first text sample set;

[0033] The first text sample set is input into the text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample;

[0034] The first prediction result is compared with the actual result to determine whether the first prediction result meets the preset conditions.

[0035] If the first prediction result does not meet the preset conditions, the text classification model is adjusted to obtain an adjusted text classification model.

[0036] According to the preset processing method, the target texts in the first text sample set whose first prediction results do not meet the preset conditions are processed to obtain the second text sample set;

[0037] The second text sample set is input into the adjusted text classification model for further training until the prediction result of the text classification model meets the preset conditions.

[0038] In a seventh aspect, embodiments of this application provide an electronic device, including a memory and a processor. The memory stores a computer program, and the processor executes the following by calling the computer program stored in the memory:

[0039] Get the text set to be classified;

[0040] Call the pre-trained text classification model;

[0041] The text set to be classified is input into the pre-trained text classification model to obtain the classification result of the text to be classified;

[0042] The text classification model mentioned therein is a text classification model obtained by using the training method of the text classification model provided in the embodiments of this application. Attached Figure Description

[0043] The technical solution and other beneficial effects of this application will become apparent from the following detailed description of specific embodiments in conjunction with the accompanying drawings.

[0044] Figure 1 This is a schematic diagram of the first process of the text classification model training method provided in the embodiments of this application.

[0045] Figure 2 This is a schematic diagram of the second process of the text classification model training method provided in the embodiments of this application.

[0046] Figure 3 This is a schematic diagram of the third process of the text classification model training method provided in the embodiments of this application.

[0047] Figure 4 This is a flowchart illustrating the text classification method provided in an embodiment of this application.

[0048] Figure 5 This is a schematic diagram of the structure of the text classification model training method provided in the embodiments of this application.

[0049] Figure 6 This is a schematic diagram of the structure of the text classification device provided in the embodiments of this application.

[0050] Figure 7 This is a first structural schematic diagram of the electronic device provided in the embodiments of this application.

[0051] Figure 8 This is a schematic diagram of the second structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0052] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and not for limiting the scope of the application. Furthermore, it should be noted that, for ease of description, only the parts relevant to the present application are shown in the drawings, not the entire structure.

[0053] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments. Unless the context clearly indicates otherwise, the singular forms “a” and “an” as used herein are also intended to include the plural. It should also be understood that the terms “comprising” and / or “including” as used herein specify the presence of the stated features, integers, steps, operations, units, and / or components, without excluding the presence or addition of one or more other features, integers, steps, operations, units, components, and / or combinations thereof.

[0054] This application provides a method for training a text classification model and a text classification method, which are applied to electronic devices. The electronic device can be a smartphone, tablet computer, PDA, laptop computer, or desktop computer, or any other device equipped with a processor and possessing processing capabilities.

[0055] Please see Figure 1 , Figure 1 This is a schematic diagram of the first process of the text classification model training method provided in this application embodiment. The text classification model training method may include the following process:

[0056] 101. Obtain the first text sample set.

[0057] The first text sample set contains multiple first texts. In the process of obtaining the first text sample set, the text to be processed can be obtained first, and then the text to be processed can be segmented to obtain multiple first texts. The first texts can be encoded to obtain multiple first tags. The first texts and the first tags corresponding to the first texts constitute the first text sample set.

[0058] For example, if the acquired text to be processed contains multiple segments of text, it can be segmented into words. For instance, when browsing articles or news, multiple text contents on the browsing page can be captured. The text contents to be processed can be hundreds, thousands, or tens of thousands of words. These text contents are used as the text to be processed. By segmenting the text to be processed, multiple first texts can be obtained.

[0059] In some implementations, multiple database texts can be obtained from the database, and then a text to be processed can be randomly selected from the database texts. The text to be processed is then processed to obtain the target database text, and the target database text and the first text are combined to form a first text sample set.

[0060] 102. Input the first text sample set into the text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample.

[0061] After obtaining the first text sample set, the first text sample set is input into the text classification model. The text classification model can identify multiple first texts, thereby classifying the first texts and obtaining the first prediction result corresponding to each first text. Each first text has its own corresponding prediction result.

[0062] 103. Compare the first prediction result with the actual result to determine whether the first prediction result meets the preset conditions.

[0063] After obtaining the first prediction result, it can be determined whether the first prediction result corresponding to the first text meets the preset conditions. If it does, the text classification model has been trained successfully, and the process proceeds to step 104, achieving the expected text classification effect. If the training result does not meet the preset conditions, the process proceeds to step 105.

[0064] For example, if the preset condition is to determine whether the first prediction result reaches 80% of the preset result, then if the first prediction result reaches 80% of the preset result, it means that the prediction result of the text classification model is accurate; if the first prediction result is less than 80% of the preset result, it means that the prediction result of the text classification model is not very accurate, and the text classification model needs to be trained again.

[0065] 104. If the first prediction result meets the preset conditions, then the text classification model has been trained.

[0066] Understandably, if the first prediction result meets the preset conditions, the training of the text classification model will stop, at which point the text classification model has been trained.

[0067] In some implementations, to further determine whether the text classification model has been trained, an additional set of text samples can be obtained, for example, from a database or randomly obtained from the network, and then input into the text classification model. If the prediction result meets the preset conditions, it indicates that the text classification model has been trained.

[0068] 105. If the first prediction result does not meet the preset conditions, the text classification model is adjusted to obtain the adjusted text classification model.

[0069] It is understandable that if the first prediction result differs significantly from the actual result, it may be that the text classification model is not suitable for classifying the first text sample set, or that the text classification model cannot classify the first text sample set on its own. In such cases, other models need to be added, or some structures in the text classification model may need to be deleted or added to adjust the structure of the text classification model.

[0070] In some implementations, when a text classification model includes a convolutional neural network, the number of convolutional or pooling layers in the convolutional neural network can be adjusted to achieve different feature extractions, and finally, a second label classification model is obtained after adjustment.

[0071] In some implementations, if the text classification model includes a neural network, the loss function in the text classification model can be adjusted based on the training results to obtain a second label classification model. Specifically, the loss function can be weighted.

[0072] In some implementations, if the text classification model includes a neural network, the parameters of the neural network model can be adjusted based on the training results, the loss function of the neural network, and preset results. Specifically, the loss value can be obtained based on the training results, the loss function of the neural network, and preset results. Then, the direction of adjustment to the neural network can be determined based on the loss value. Finally, the parameters of the neural network can be adjusted to obtain the second label classification model.

[0073] 106. Process the target texts in the first text sample set whose first prediction results do not meet the preset conditions according to the preset processing method to obtain the second text sample set.

[0074] In some implementations, target texts that do not meet preset conditions can be obtained from the first text. Multiple target texts can be segmented according to a preset length to obtain multiple second texts. For example, if one of the first texts is "The Yuanmingyuan Horse Head has a medical examination report released today, with white scale attached inside," and the preset length is 4 characters, then the first text can be segmented to obtain the second texts "Yuanmingyuan Horse Head, released today, medical examination report, attached inside, white scale," and multiple second texts can be combined into a second text sample set.

[0075] It should be noted that in practical applications, the preset length can be set to several hundred or several thousand characters. For example, when the preset length is 300 characters, the first text can be split into multiple second texts according to the preset length of 300 characters.

[0076] In some implementations, target text that does not meet preset conditions can also be obtained, as well as predictable real text data from the database. The first label and the predictable real text data are then combined to form a second text sample set.

[0077] 107. Input the second text sample set into the adjusted text classification model and continue training until the prediction results of the text classification model meet the preset conditions.

[0078] Understandably, after obtaining the second text sample set, the second text sample set can be input into the adjusted text classification model to continue predicting the second text sample set. Then, the second prediction result corresponding to the second text is obtained. The second prediction result is compared with the real result corresponding to the second text to determine whether the second prediction result meets the preset conditions. If the second prediction result meets the preset conditions, the training of the text classification model is stopped. At this time, the text classification model can accurately classify the input file.

[0079] If the second prediction result still does not meet the preset conditions, proceed to step 105 to continue training the text classification model until the prediction result of the text classification model meets the preset conditions, indicating that the text classification model has been successfully trained. By modifying the input text sample set and adjusting the text classification model, the trained text classification model can accurately classify and recognize multi-label text.

[0080] During the training process of the text classification model, by adjusting and optimizing the input text samples and the text classification model itself, the text classification model can accurately achieve text classification results in the prediction of multi-label text.

[0081] As described above, by obtaining a first sample set, the first sample set is input into the text classification model for text category prediction. The first prediction result is compared with the true result to determine whether the first prediction result meets the preset conditions. If the preset conditions are not met, the text classification model is adjusted to obtain an adjusted text classification model. Target texts in the first text sample set whose first prediction results do not meet the preset conditions are processed according to the preset processing method to obtain a second text sample set. The second text sample set is input into the adjusted text classification model for further training until the prediction results of the text classification model meet the preset conditions. The trained text classification model can classify multi-label text and improve the accuracy of text classification.

[0082] Please continue reading. Figure 2 , Figure 2This is a schematic diagram of the second process of the training method for the text classification model provided in this application embodiment. Before obtaining the first text sample set, the training method for the text classification model includes the following process:

[0083] 201. Obtain the text to be processed, and perform word segmentation on the text to be processed to obtain multiple first texts.

[0084] In one implementation, the acquired text to be processed may consist of characters, words, paragraphs, or articles. The number of characters in the text to be processed may be hundreds, thousands, or tens of thousands. After acquiring the text to be processed, it can be segmented into words, for example, by dividing words in a paragraph or sentences in an article. Alternatively, a word segmenter can be used to segment the text. After segmentation, the resulting text is called the first text, which may include multiple instances.

[0085] It should be noted that the text to be processed can be determined based on the specific model used by the text classification model. For example, when the text classification model does not require word segmentation, such as the BERT model, word segmentation is not necessary, and multiple texts to be processed can be directly input into the text classification model as the first text sample. When the text classification model requires word segmentation, such as the convolutional neural network model, word segmentation is required to obtain multiple first text samples.

[0086] 202. Encode the first text to obtain the corresponding first tag.

[0087] Understandably, after obtaining multiple first texts, each first text needs to be encoded so that each first text has its own corresponding tag, thus distinguishing the multiple first texts from each other.

[0088] 203. Obtain the target first tag whose tag level is lower than the lowest tag level in the preset tag levels.

[0089] When there are many first texts, the tags corresponding to the first texts can be integrated, and multiple tags can be concatenated into one tag. However, when there are many first tags of the same type, target first tags below the lowest tag level can be obtained and processed in subsequent steps.

[0090] Understandably, actual business data is often unbalanced, and the large number of fine-grained labels necessitates some aggregation to the next higher level of labels. If the amount of business data corresponding to a fine-grained label is zero or nearly zero, the prediction results for these labels actually affect the overall prediction results. These labels can be called invalid labels or low-data-volume labels, and they need to be aggregated to their next higher level of labels and not processed further.

[0091] 204. Place the target's first tag into the first tag of the lowest tag level.

[0092] In some embodiments, when there are many first tags of the same type, tags below the lowest tag level can be retrieved. For example, if the preset tag level is 5, but there are 7 first tags of the same type, and these 7 first tags are arranged from highest to lowest level as A, B, C, D, E, F, and G, then with the preset tag level of 5, tags F and G are lower than the lowest tag level tag E. In this case, tags F and G can be identified as target first tags, and target first tags F and G can be assigned to the lowest tag level first tag E. This is how tail tags are processed.

[0093] 205. Integrate multiple first tags of the same type according to the preset tag hierarchy to obtain the first text sample set.

[0094] In some embodiments, tags of the same type can be integrated according to a preset tag hierarchy. For example, tags of the same type can be obtained from multiple first tags, such as five first tags A, B, C, D, and E. The first tags can be integrated according to the preset tag hierarchy. The text corresponding to the five first tags A, B, C, D, and E are "current affairs", "domestic current affairs", "mainland current affairs", "policies", and "agriculture, rural areas and farmers", respectively. If the preset tag hierarchy is five levels and the first tags need to be spliced ​​from the highest level to the lowest level, the spliced ​​and integrated tag is "ABCDE", where the text corresponding to this tag is "current affairs-domestic current affairs-mainland current affairs-policies-agriculture, rural areas and farmers". Similarly, multiple first tags of the same type can be integrated to form multiple integrated tags, thereby reducing the number of tags.

[0095] Multiple integrated tags can be tagged with encoding. For example, one-hot encoding can be used to encode the integrated tags. Finally, the integrated tags and the text corresponding to the integrated tags form the first text sample set.

[0096] Please continue reading. Figure 3 , Figure 3 This is a schematic diagram of the third step in the training method of the text classification model provided in this application embodiment. The training method of the text classification model may include the following steps:

[0097] 301. Obtain the first text sample set.

[0098] Before obtaining the first text sample set, invalid characters in the text to be processed can be filtered and deleted to ensure the authenticity of the data. Then, the filtered text to be processed is segmented to obtain multiple first texts. The multiple first texts are text encoded to obtain multiple first tags. Considering that there are many first tags, tags of the same type can be integrated to form integrated tags. Finally, the multiple integrated tags are coded, and the integrated tags and the text corresponding to the integrated tags form the first text sample set.

[0099] 302. Input the first text sample set into the text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample.

[0100] After obtaining the first text sample set, it is input into the text classification model. The text classification model can identify multiple first texts, thereby classifying them and obtaining the first prediction result corresponding to each first text. Each first text has its own corresponding prediction result, and the accuracy value of the first prediction result can be calculated using the sigmoid function.

[0101] 303. If the first prediction result does not meet the preset conditions, adjust the text classification model.

[0102] After obtaining the first prediction result, the first prediction result can be compared with the actual result corresponding to the first text to determine whether the first prediction result meets the preset conditions. For example, it can be determined whether the accuracy of the first prediction result reaches the preset accuracy. If the accuracy of the first prediction result does not reach the preset accuracy, the text classification model is adjusted.

[0103] In some implementations, the parameters of the text classification model can be adjusted. For example, the loss function of the text classification model can be obtained, and the first predicted result and the true result can be input into the loss function to obtain the loss value. The parameters of the text classification model can be adjusted according to the target loss value so that the loss value of the text classification model is less than or equal to the target loss value.

[0104] In some implementations, the text classification model can be chained with a preset model to adjust the text classification model. For example, if the text classification model before adjustment uses the BERT model, a convolutional neural network model can be chained after the BERT model to form a new text classification model.

[0105] In some implementations, the structure of the text classification model can be adjusted. For example, if the text classification model is an ensemble model consisting of a BERT model and a convolutional neural network model, then multi-scale convolutional kernels or multiple different pooling operations can be applied to the convolutional neural network model, and the number of layers in the convolutional neural network can also be changed.

[0106] 304. Obtain the preset parameters of the text classification model and set the preset parameters in the adjusted model.

[0107] Understandably, some parameters in the previous text classification model were set correctly and do not need further adjustment. These parameters are preset parameters. During the adjustment of the text classification model, the preset parameters of the previous text classification model can be obtained, allowing the text classification model to perform transfer learning based on these preset parameters. This ensures that the training time and number of training iterations are reduced during the training process of the text classification model. At the same time, the text classification model can continue to be adjusted based on these preset parameters. Finally, the adjusted text classification model can continue to be used for the next training until the prediction results output by the text classification model meet the preset conditions.

[0108] 305. Perform text segmentation on the target text according to the preset length to obtain multiple segmented texts.

[0109] It is understandable that there will be some texts in the first text sample set that cannot be predicted by the text classification model. At this time, it is necessary to segment the target texts whose first prediction results do not meet the preset conditions according to the preset length to obtain multiple segmented texts.

[0110] In some implementations, target tags are integrated by pre-setting tag levels to obtain the tail tags of the target tags, and some tail tags of target tags can be selected and included in the target tags of the lowest tag level.

[0111] In some implementations, unlabeled text can be selected from the database as input samples, and then these unlabeled texts are input into the text classification model before adjustment. Texts corresponding to labels with predicted probabilities greater than a preset threshold are selected as high-confidence texts, and the high-confidence texts and the target text are used together as a new text sample set, that is, the second text sample set.

[0112] 306. Encode multiple segmented texts to obtain a second text sample set.

[0113] In some implementations, the segmented text is encoded to obtain target labels, the target labels are integrated through a preset label hierarchy, the tail labels of the target labels are obtained, some of the tail labels of the target labels can be selected and included in the target labels of the lowest label hierarchy, or highly confident text can be selected from the database and combined with the target text to form a second text sample set.

[0114] 307. Input the second text sample set into the adjusted text classification model and continue training until the prediction results of the text classification model meet the prediction conditions.

[0115] Understandably, after obtaining the second text sample set, the second text sample set can be input into the adjusted text classification model to continue predicting the second text sample set. Then, the second prediction result corresponding to the second text is obtained. The second prediction result is compared with the real result corresponding to the second text to determine whether the second prediction result meets the preset conditions. If the second prediction result meets the preset conditions, the training of the text classification model is stopped. At this time, the text classification model can accurately classify the input file.

[0116] If the second prediction result still does not meet the preset conditions, repeat the above steps to continue training the text classification model until the prediction result of the text classification model meets the preset conditions, indicating that the text classification model has been successfully trained. By changing the data of the input text sample set and adjusting the text classification model, the trained text classification model can accurately classify and recognize multi-label text.

[0117] As described above, in this embodiment, a first text sample set is input into a text classification model to predict the text category, thereby obtaining a first prediction result corresponding to the first text sample. If the first prediction result does not meet the preset conditions, the text classification model is adjusted. Preset parameters of the text classification model are obtained and set in the adjusted model. The target text is segmented according to a preset length to obtain multiple segmented texts. The multiple segmented texts are encoded to obtain a second text sample set. The second text sample set is input into the adjusted text classification model for further training until the prediction result of the text classification model meets the prediction conditions. Thus, a trained text classification model is obtained. The trained text classification model can classify multi-level, multi-label text, and the prediction accuracy of the text classification model can achieve the expected results.

[0118] Please continue reading. Figure 4 , Figure 4 This application provides a text classification method. The method includes the following steps:

[0119] 401. Obtain the text set to be classified.

[0120] Invalid characters in the text to be classified can be filtered and deleted to ensure the authenticity of the text data. Multiple texts to be classified are text-encoded to obtain multiple text tags. Considering that there are many texts to be classified, tags of the same type can be integrated to form integrated text tags. Finally, multiple integrated text tags to be classified are coded, and the integrated text tags and the texts to be classified form a set of texts to be classified.

[0121] 402. Call the pre-trained text classification model.

[0122] It should be noted that after the text classification model is trained, it can accurately predict most texts. However, to improve the accuracy of text classification, a sub-model can be chained after the main text classification model. This sub-model can adjust the accuracy of text classification according to actual needs.

[0123] 403. Input the text set to be classified into a pre-trained text classification model to obtain the classification results of the text to be classified.

[0124] Understandably, when the text set to be classified is input into a pre-trained text classification model, the accuracy of the classification results is not very high, but it has reached a high level of accuracy and can classify multi-level, multi-label texts.

[0125] 404. Obtain the lowest-level label corresponding to the text to be classified, and continue to classify the text corresponding to the lowest-level label.

[0126] In some embodiments, the lowest-level tail label of the text to be classified can be input into the text classification sub-model, thereby realizing text classification of the text corresponding to the lowest-level tail label of the text to be classified, thus achieving a more accurate text classification effect.

[0127] As described above, in this embodiment, the following steps are taken: a text set to be classified is obtained; a pre-trained text classification model is invoked; the text set to be classified is input into the pre-trained text classification model to obtain the classification result of the text to be classified; the lowest-level label corresponding to the text to be classified is obtained, and text classification is further performed on the text corresponding to the lowest-level label. This achieves classification of multi-level, multi-label text, improving the accuracy of text classification.

[0128] Please see Figure 5 , Figure 5This is a schematic diagram of the structure of a training device for a text classification model provided in an embodiment of this application. The training device 500 for the text classification model includes: a first acquisition module 510, a prediction module 520, a judgment module 530, an adjustment module 540, a processing module 550, and a training module 560.

[0129] The first acquisition module 510 is used to acquire the first text sample set;

[0130] The prediction module 520 is used to input the first text sample set into the text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample;

[0131] The judgment module 530 is used to compare the first prediction result with the actual result and determine whether the first prediction result meets the preset conditions.

[0132] The adjustment module 540 is used to adjust the text classification model if the first prediction result does not meet the preset conditions, so as to obtain the adjusted text classification model.

[0133] The processing module 550 is used to process the target texts in the first text sample set whose first prediction results do not meet the preset conditions according to the preset processing method, so as to obtain the second text sample set.

[0134] The training module 560 is used to input the second text sample set into the adjusted text classification model for further training until the prediction result of the text classification model meets the preset conditions.

[0135] In some embodiments, the first acquisition module 510 is specifically used to acquire the text to be processed, perform word segmentation on the text to be processed to obtain multiple first texts; encode the first texts to obtain first tags corresponding to the first texts; and integrate multiple first tags according to a preset tag level to obtain the first text sample set.

[0136] In some embodiments, the first acquisition module 510 is specifically used to acquire a target first tag whose tag level is lower than the lowest tag level in the preset tag levels; to classify the target first tag into the first tag of the lowest tag level; and to integrate multiple first tags of the same type according to the preset tag levels to obtain a first text sample set.

[0137] In some embodiments, the adjustment module 540 is specifically used to input the first prediction result and the true result into the loss function of the text classification model to obtain a loss value; and to adjust the parameters of the text classification model according to the loss value.

[0138] In some embodiments, the adjustment module 540 is specifically used to adjust the network structure of the text classification model based on the first prediction result and the true result; and to connect a preset model in series with the adjusted text classification model.

[0139] In some embodiments, the adjustment module 540 is specifically used to obtain the loss function of the text classification model; and to perform weighted processing on the loss function based on the first prediction result and the true result.

[0140] In some embodiments, the adjustment module 540 is specifically used to obtain preset parameters of the text classification model and set the preset parameters in the adjusted text classification model.

[0141] As described above, in this embodiment, the first acquisition module 510 acquires a first sample set, and the prediction module 520 inputs the first sample set into a text classification model for text category prediction. The judgment module 530 compares the obtained first prediction result with the actual result to determine whether the first prediction result meets preset conditions. When the first prediction result does not meet the preset conditions, the adjustment module 540 adjusts the text classification model to obtain an adjusted text classification model. The processing module 550 processes the target texts in the first text sample set whose first prediction results do not meet the preset conditions according to a preset processing method to obtain a second text sample set. The training module 560 inputs the second text sample set into the adjusted text classification model for further training until the prediction result of the text classification model meets the preset conditions. The trained text classification model can accurately classify multi-level, multi-label text.

[0142] Please continue reading. Figure 6 , Figure 6 This is a schematic diagram of the structure of the text classification device provided in the embodiments of this application. The text classification device 600 specifically includes: a second acquisition module 610, a calling module 620, and a classification module 630.

[0143] The second acquisition module 610 is used to acquire the target text set;

[0144] Call module 620 to invoke the pre-trained text classification model;

[0145] The classification module 630 is used to input the target text set into the pre-trained text classification model to obtain the classification result of the target text;

[0146] The text classification model is a text classification model obtained by the training method of the text classification model provided in the embodiments of this application.

[0147] The classification module 630 is also used to input the lowest-level tail label of the text to be classified into the text classification sub-model, so as to realize the text classification of the text corresponding to the lowest-level tail label of the text to be classified, thereby achieving a more accurate text classification effect.

[0148] As described above, in this embodiment, the second acquisition module 610 acquires the text set to be classified; the invocation module 620 invokes a pre-trained text classification model; the classification module 630 inputs the text set to be classified into the pre-trained text classification model to obtain the classification result of the text to be classified; the classification module 630 can also acquire the lowest-level label corresponding to the text to be classified, and continue to classify the text corresponding to the lowest-level label. This achieves classification of multi-level, multi-label text, improving the accuracy of text classification.

[0149] It should be noted that the image attribute recognition device provided in this application embodiment and the image attribute recognition method in the above embodiment belong to the same concept. The image attribute recognition device can run any of the methods provided in the method embodiment. For details of its specific implementation process, please refer to the image processing method embodiment, which will not be repeated here.

[0150] This application provides a computer-readable storage medium storing a computer program thereon. When the computer program stored thereon is executed on a computer, it causes the computer to perform a training method for a network model or an image processing method as provided in this application.

[0151] The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0152] This application also provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor executes a network model training method or an image attribute recognition method as provided in this application by calling the computer program stored in the memory.

[0153] For example, the aforementioned electronic devices can be mobile terminals such as tablets or smartphones. See also Figure 7 , Figure 7 This is a schematic diagram of a first structure of an electronic device provided in an embodiment of this application.

[0154] The electronic device 700 may include components such as a memory 701 and a processor 702. Those skilled in the art will understand that... Figure 7The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0155] The memory 701 can be used to store software programs and modules. The processor 702 executes various functional applications and data processing by running the computer programs and modules stored in the memory 701. The memory 701 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, computer programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc.

[0156] The processor 702 is the control center of the electronic device. It connects various parts of the electronic device through various interfaces and lines. By running or executing the application program stored in the memory 701 and calling the data stored in the memory 701, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole.

[0157] Furthermore, memory 701 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory 701 may also include a memory controller to provide processor 702 with access to memory 701.

[0158] In this embodiment, the processor 702 in the electronic device loads the executable code corresponding to the processes of one or more applications into the memory 701 according to the following instructions, and the processor 702 runs the applications stored in the memory 701, thereby realizing the process:

[0159] Obtain the first text sample set;

[0160] The first text sample set is input into the text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample;

[0161] The first prediction result is compared with the actual result to determine whether the first prediction result meets the preset conditions.

[0162] If the first prediction result does not meet the preset conditions, the text classification model is adjusted to obtain an adjusted text classification model.

[0163] According to the preset processing method, the target texts in the first text sample set whose first prediction results do not meet the preset conditions are processed to obtain the second text sample set;

[0164] The second text sample set is input into the adjusted text classification model for further training until the prediction result of the text classification model meets the preset conditions.

[0165] In some implementations, when processor 702 adjusts the text classification model, it may perform the following:

[0166] The first prediction result and the true result are input into the loss function of the text classification model to obtain the loss value;

[0167] The parameters of the text classification model are adjusted based on the loss value.

[0168] In some implementations, when processor 702 adjusts the text classification model, it may perform the following:

[0169] The network structure of the text classification model is adjusted based on the first prediction result and the actual result;

[0170] The adjusted text classification model is then linked with a preset model.

[0171] In some implementations, when processor 702 adjusts the text classification model, it may perform the following:

[0172] Obtain the loss function of the text classification model;

[0173] The loss function is weighted based on the first prediction result and the actual result.

[0174] Specifically, when processor 702 adjusts the text classification model, it can perform the following:

[0175] Obtain the preset parameters of the text classification model;

[0176] Set the preset parameters in the adjusted text classification model.

[0177] In some implementations, when the processor 702 processes target texts in the first text sample set whose first prediction results do not meet preset conditions according to a preset processing method, it may perform the following:

[0178] The target text is segmented according to a preset length to obtain multiple segmented texts;

[0179] The segmented text is encoded to obtain the second text sample set.

[0180] In some implementations, the processor 702 may perform the following before acquiring the first set of text samples:

[0181] Obtain the text to be processed, and perform word segmentation on the text to be processed to obtain multiple first texts;

[0182] Encode the first text to obtain the first tag corresponding to the first text;

[0183] The first text sample set is obtained by integrating multiple first tags according to a preset tag hierarchy.

[0184] In some implementations, when processor 702 performs the task of integrating multiple first tags according to a preset tag hierarchy to obtain the first text sample set, it may execute:

[0185] Obtain the target first tag whose tag level is lower than the lowest tag level in the preset tag levels;

[0186] The target first label is assigned to the first label of the lowest label level;

[0187] Multiple first tags of the same type are integrated according to the preset tag hierarchy to obtain a first text sample set.

[0188] In this embodiment, the processor 702 in the electronic device loads the executable code corresponding to the processes of one or more applications into the memory 701 according to the following instructions, and the processor 702 runs the applications stored in the memory 701, thereby realizing the process:

[0189] Get the text set to be classified;

[0190] Call the pre-trained text classification model;

[0191] The text set to be classified is input into the pre-trained text classification model to obtain the classification result of the text to be classified;

[0192] The text classification model is a text classification model obtained by the training method of the text classification model provided in the embodiments of this application.

[0193] Please refer to Figure 8 , Figure 8 This is a second structural schematic diagram of the electronic device provided in the embodiments of this application, and... Figure 7 The difference in the illustrated electronic device is that it also includes: a camera assembly 703, a radio frequency circuit 704, an audio circuit 705, and a power supply 706. The display 703, radio frequency circuit 704, audio circuit 705, and power supply 706 are electrically connected to the processor 702.

[0194] The display 703 can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces, which can be composed of graphics, text, icons, video, and any combination thereof. The display 703 may include a display panel, which in some embodiments may be configured as a liquid crystal display (LCD) or an organic light-emitting diode (OLED).

[0195] The radio frequency circuit 704 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other electronic devices, and to transmit and receive signals with network devices or other electronic devices.

[0196] The audio circuit 705 can be used to provide an audio interface between a user and electronic devices via a speaker or microphone.

[0197] The power supply 706 can be used to power various components of the electronic device 600. In some embodiments, the power supply 706 can be logically connected to the processor 702 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system.

[0198] although Figure 8 As not shown, the electronic device 600 may further include a camera component, a Bluetooth module, etc. The camera component may include an image processing circuit, which can be implemented using hardware and / or software components and may include various processing units that define an image signal processing (ISP) pipeline. The image processing circuit may include at least: multiple cameras, an image signal processor (ISP processor), a control logic unit, an image memory, and a display, etc. Each camera may include at least one or more lenses and an image sensor. The image sensor may include a color filter array (such as a Bayer filter). The image sensor can acquire light intensity and wavelength information captured by each imaging pixel of the image sensor and provide a set of raw image data that can be processed by the image signal processor.

[0199] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the detailed description of the training method / text classification method for the text classification model above, which will not be repeated here.

[0200] The text classification model training device / text classification device provided in this application embodiment belongs to the same concept as the text classification model training method / text classification method in the above embodiment. Any of the methods provided in the text classification model training method / text classification method embodiment can be run on the text classification model training device / text classification device. For details of its implementation process, please refer to the network model training method / image processing method embodiment, which will not be repeated here.

[0201] It should be noted that, regarding the text classification model training method / text classification method described in the embodiments of this application, those skilled in the art will understand that all or part of the process of implementing the network model training method / image processing method described in the embodiments of this application can be accomplished by a computer program controlling related hardware. The computer program can be stored in a computer-readable storage medium, such as a memory, and executed by at least one processor. During execution, it can include the process of the embodiments of the network model training method / image processing method. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), etc.

[0202] For the network model training device / image processing device described in the embodiments of this application, its functional modules can be integrated into a single processing chip, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0203] The text classification model training method, text classification method, device, and electronic device provided in the embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A training method for a text classification model, characterized in that, The method includes: The process involves: acquiring the text to be processed; performing word segmentation on the text to obtain multiple first text samples; encoding the first text samples to obtain the first tags corresponding to the first text samples; acquiring target first tags whose tag level is lower than the lowest tag level in the preset tag levels; classifying the target first tags into the first tags of the lowest tag level; and integrating multiple first tags of the same type according to the preset tag levels to obtain a first text sample set. Obtain the first text sample set; The first text sample set is input into the text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample; The first prediction result is compared with the actual result to determine whether the first prediction result meets the preset conditions. If the first prediction result does not meet the preset conditions, the text classification model is adjusted to obtain an adjusted text classification model. According to a preset processing method, the target text in the first text sample set whose first prediction result does not meet the preset conditions is processed. Specifically, the target text is segmented according to a preset length to obtain multiple segmented texts. The segmented texts are encoded to obtain target tags. The target tags are integrated through a preset tag hierarchy to obtain the tail tags of the target tags. The tail tags are then assigned to the target tags of the lowest tag hierarchy in the preset tag hierarchy to obtain the second text sample set. The second text sample set is input into the adjusted text classification model for further training until the prediction result of the text classification model meets the preset conditions.

2. The training method for the text classification model according to claim 1, characterized in that, The adjustment of the text classification model includes: The first prediction result and the true result are input into the loss function of the text classification model to obtain the loss value; The parameters of the text classification model are adjusted based on the loss value.

3. The training method for the text classification model according to claim 1, characterized in that, The adjustment of the text classification model includes: The network structure of the text classification model is adjusted based on the first prediction result and the actual result; The adjusted text classification model is then linked with a preset model.

4. The training method for the text classification model according to claim 1, characterized in that, The adjustment of the text classification model includes: Obtain the loss function of the text classification model; The loss function is weighted based on the first prediction result and the actual result.

5. The training method for the text classification model according to any one of claims 1 to 4, characterized in that, The adjustment of the text classification model includes: Obtain the preset parameters of the text classification model; Set the preset parameters in the adjusted text classification model.

6. A text classification method, characterized in that, include: Get the text set to be classified; Call the pre-trained text classification model; The text set to be classified is input into the pre-trained text classification model to obtain the classification result of the text to be classified; The text classification model is a text classification model obtained by using the training method of the text classification model according to any one of claims 1 to 5.

7. A training device for a text classification model, characterized in that, include: The first acquisition module is used to acquire the text to be processed and perform word segmentation on the text to be processed to obtain multiple first text samples; Encode the first text sample to obtain the first tag corresponding to the first text sample; obtain the target first tag whose tag level is lower than the lowest tag level in the preset tag levels; The target first tag is assigned to the first tag of the lowest tag level; multiple first tags of the same type are integrated according to the preset tag level to obtain a first text sample set; and the first text sample set is obtained. The prediction module is used to input the first text sample set into the text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample; The judgment module is used to compare the first prediction result with the actual result and determine whether the first prediction result meets the preset conditions. An adjustment module is used to adjust the text classification model if the first prediction result does not meet the preset conditions, so as to obtain an adjusted text classification model. The processing module is used to process target texts in the first text sample set whose first prediction results do not meet preset conditions according to a preset processing method. The target text is segmented according to a preset length to obtain multiple segmented texts. The segmented texts are encoded to obtain target tags. The target tags are integrated through a preset tag hierarchy to obtain the tail tags of the target tags. The tail tags are assigned to the target tags of the lowest tag hierarchy in the preset tag hierarchy to obtain a second text sample set. The training module is used to input the second text sample set into the adjusted text classification model for further training until the prediction result of the text classification model meets the preset conditions.

8. A text classification device, characterized in that, include: The second acquisition module is used to acquire the text set to be classified; The calling module is used to invoke a pre-trained text classification model; The classification module is used to input the text set to be classified into the pre-trained text classification model to obtain the classification result of the text to be classified. The text classification model is a text classification model obtained by using the training method of the text classification model according to any one of claims 1 to 5.

9. A storage medium, characterized in that, The storage medium stores a computer program that, when run on a computer, causes the computer to execute the training method of the text classification model according to any one of claims 1 to 5 or the text classification method according to claim 6.

10. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing a computer program, and the processor executing the following by calling the computer program stored in the memory: Obtain the text to be processed, perform word segmentation on the text to be processed to obtain multiple first text samples; encode the first text samples to obtain the first tags corresponding to the first text samples; obtain the target first tag whose tag level is lower than the lowest tag level in the preset tag levels; The target first tag is assigned to the first tag of the lowest tag level; multiple first tags of the same type are integrated according to the preset tag level to obtain a first text sample set; Obtain the first text sample set; The first text sample set is input into a text classification model to predict the text category, so as to obtain the first prediction result corresponding to the first text sample; The first prediction result is compared with the actual result to determine whether the first prediction result meets the preset conditions. If the first prediction result does not meet the preset conditions, the text classification model is adjusted to obtain an adjusted text classification model. According to a preset processing method, the target text in the first text sample set whose first prediction result does not meet the preset conditions is processed. Specifically, the target text is segmented according to a preset length to obtain multiple segmented texts. The segmented texts are encoded to obtain target tags. The target tags are integrated through a preset tag hierarchy to obtain the tail tags of the target tags. The tail tags are then assigned to the target tags of the lowest tag hierarchy in the preset tag hierarchy to obtain the second text sample set. The second text sample set is input into the adjusted text classification model for further training until the prediction result of the text classification model meets the preset conditions.

11. The electronic device according to claim 10, characterized in that, The processor is used to execute: The first prediction result and the true result are input into the loss function of the text classification model to obtain the loss value; The parameters of the text classification model are adjusted based on the loss value.

12. The electronic device according to claim 10, characterized in that, The processor is used to execute: The network structure of the text classification model is adjusted based on the first prediction result and the actual result; The adjusted text classification model is then linked with a preset model.

13. The electronic device according to any one of claims 10 to 12, characterized in that, The processor is used to execute: Obtain the preset parameters of the text classification model; Set the preset parameters in the adjusted text classification model.

14. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing a computer program, and the processor executing the following by calling the computer program stored in the memory: Get the text set to be classified; Call the pre-trained text classification model; The text set to be classified is input into the pre-trained text classification model to obtain the classification result of the text to be classified; The text classification model is a text classification model obtained by using the training method of the text classification model according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Training method and apparatus of text regularization model anda text regularization method and apparatus

    CN107705784A

  • Training method, apparatus, apparatus and medium for cross-domain text emotion classification model

    CN109308318A