Method and apparatus for multi-label classification of text data
By splitting the multi-level progressive label system into a first label item string and a second label item string, a parallel multi-label model is established, which solves the problem of low prediction efficiency of the multi-level progressive label system in the existing technology and achieves more efficient text data classification.
Patent Information
- Application Number
- CN202111391312.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-23
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2041-11-23
AI Technical Summary
Existing multi-label classification methods are inefficient when dealing with label systems that contain multi-level hierarchical relationships, especially when the number of label items is large, resulting in excessively long model training and data prediction times.
The multi-level progressive label system is split into a first label item string and a second label item string, and a first-level multi-label model and multiple second-level multi-label models are established respectively. By parallel training and prediction, the number of label items is reduced, thereby improving the model's relevance and efficiency.
It significantly improved the model's predictive performance, reduced training and data prediction time, and mitigated the impact of imbalanced samples.
Smart Images

Figure CN114036944B_ABST
Abstract
Description
Technical Field
[0001] This application relates to data processing, and in particular to methods and apparatus for classifying text data whose categories are indicated by labels that imply multi-level hierarchical relationships. Background Technology
[0002] In data classification, labels are commonly used to indicate the category to which data belongs. Currently, there are two main labeling systems: one is a single, independent, and fragmented labeling system, such as the labeling system of NetEase Cloud Music, which includes labels like "Chinese," "Japanese," "Cantonese," "Pop," "Rock," and "Folk." In this fragmented system, each label contains only one tag item, and they are independent of each other with no connection. The other type is a labeling system with multi-level progressive relationships. In this system, each label contains multiple tag items separated by delimiters and arranged in a progressive order, forming a series of alternating tag items and delimiters. For example, in a customer review label set for the catering industry, the label "Negative - Service - Poor Waiter / Customer Service Attitude - Insufficient Service Initiative" uses a hyphen "-" as a delimiter and contains four tag items: "Negative," "Service," "Poor Waiter / Customer Service Attitude," and "Insufficient Service Initiative," implying a four-level progressive relationship. Within this framework, the two tags before and after each separator "-", such as "Negative" and "Service", "Service" and "Poor Waiter / Customer Service Attitude", and "Poor Waiter / Customer Service Attitude" and "Insufficiently Proactive Service", have a progressive relationship. That is, the later tag is a subordinate tag of the earlier tag, and the scope of the category it indicates is further narrowed. A part of a complete tag that contains at least one tag is called a sub-tag, while the entire tag is called a full-level tag. For example, "Negative-Service-Poor Waiter / Customer Service Attitude-Insufficiently Proactive Service" is a full-level tag.
[0003] Existing multi-label text classification methods basically predict the entire label, i.e., the full-level label. Since the output space of multi-label classification grows exponentially with the number of label items, this method of directly predicting the full-level label is time-consuming and inefficient when the number of label items is large.
[0004] Therefore, there is a need to improve existing multi-label classification methods. Summary of the Invention
[0005] In order to overcome at least one of the defects in the prior art mentioned above, embodiments of this application propose a method and apparatus for classifying text data, wherein the categories corresponding to the text data are represented by labels that imply multi-level progressive relationships.
[0006] According to one aspect of this application, a method for classifying text data is proposed. The method includes: predicting a first label string of text data, the first label string representing a first-level category of the text data, wherein the first label string includes one or more labels with a progressive relationship; predicting a second label string of text data based on the first-level category of the text data, the second label string representing a second-level category of the text data, the second-level category being a subcategory of the first-level category, wherein the second label string includes one or more labels with a progressive relationship; and concatenating the first label string and the second label string to obtain a classification result of the text data.
[0007] According to another aspect of this application, an apparatus for classifying text data is also proposed. The apparatus includes: a first module for predicting a first tag string of text data, the first tag string representing a first-level category of the text data, wherein the first tag string includes one or more levels of tag items with a progressive relationship; a second module for predicting a second tag string of text data based on the first-level category of the text data, the second tag string representing a second-level category of the text data, the second-level category being a subcategory of the first-level category, wherein the second tag string includes one or more levels of tag items with a progressive relationship; and a concatenation module for concatenating the first tag string and the corresponding second tag string to obtain a classification result of the text data.
[0008] According to another aspect of this application, a computer-readable storage medium is also provided, on which a computer program is stored, the computer program including executable instructions that, when executed by a processor, implement the method described above.
[0009] According to another aspect of this application, an electronic device for classifying text data is proposed, comprising a processor and a memory for storing executable instructions of the processor, wherein the processor is configured to execute the executable instructions to implement the method described above.
[0010] The multi-label classification scheme provided in this application fully considers the structure of the labels themselves in a label system containing multi-level progressive relationships. It analyzes the labels and splits the label set based on their inherent structure, reducing the number of label items in each predicted label. This allows the model to learn specific aspects more effectively, making predictions more targeted. As a result, the model's performance is significantly improved compared to directly predicting all labels, and both model training and data prediction time are greatly reduced. Furthermore, the reduced number of label items in each predicted label also mitigates the impact of imbalanced samples to some extent.
[0011] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit the scope of protection of this application. Attached Figure Description
[0012] Exemplary embodiments of this application will now be described in detail with reference to the accompanying drawings. In the drawings:
[0013] Figure 1 This illustrates a tagging system with a multi-level hierarchical relationship according to an embodiment of this application;
[0014] Figure 2 This application illustrates a tagging system for customer review data according to one embodiment of the present application;
[0015] Figure 3 An exemplary structural block diagram of an apparatus for multi-label classification of text data according to an embodiment of this application is shown;
[0016] Figure 4 An exemplary flowchart of a method for multi-label classification of text data according to an embodiment of this application is shown;
[0017] Figure 5 An exemplary structural block diagram of an electronic device for multi-label classification of text data according to an embodiment of this application is shown. Detailed Implementation
[0018] Exemplary embodiments of the present application will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided to make the present application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art. In the drawings, the dimensions of some elements may be exaggerated or modified for clarity. The same reference numerals in the drawings denote the same or similar structures, and therefore their detailed descriptions will be omitted.
[0019] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of the embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details described, or other methods, elements, etc., can be employed. In other instances, well-known structures, methods, or operations are not shown or described in detail to avoid obscuring the key content of this application.
[0020] As mentioned earlier, existing multi-label classification algorithms treat the full-level labels as the smallest granularity and directly perform classification prediction on the full-level labels. This includes the following steps:
[0021] - Establish a set of labels to be predicted, collect a training dataset, including text and its corresponding labels, and train a classification model;
[0022] - Perform text preprocessing on the text content;
[0023] - Extract key features from the text that reflect its characteristics, and vectorize the text; and
[0024] -Use the trained classification model to capture the mapping between features and categories to complete the final text multi-label classification.
[0025] As can be seen, existing algorithms treat label systems with multi-level progressive relationships as ordinary label systems for prediction. Most of these algorithms consider the symbiotic relationships between labels, the differences in the contribution of text content to labels, and the order of labels, but fail to take into account the inherent value of the label structure and the progressive relationships between labels.
[0026] The algorithm strategy of this application fully considers the structure of the labels themselves in the label system containing multi-level progressive relationships, analyzes them, and proposes a new multi-label classification method for label systems containing multi-level progressive relationships.
[0027] In a tagging system with multi-level progressive relationships, each tag is a sequence of alternating tag items and separators, where the two tag items before and after each separator have a progressive relationship. In this paper, each tag item separated by a separator constitutes a tag item level, and is referred to as the Xth level tag item according to its position in the entire tagging system. A progressive relationship means that the range of the category indicated by a later level tag item is a sub-range of the range of the category indicated by the previous level tag item; that is, it is contained within the range of the category indicated by the previous level tag item. Since each tag contains multiple levels of tag items, and the range of the categories indicated by each level tag item decreases progressively from the first level tag item, a complete tag contains multi-level progressive relationships. In other words, for each tag, the earlier tag items indicate the broad category to which the data belongs, while the later tag items indicate a smaller category range.
[0028] Suppose a tag contains at most M levels of tags, i.e., first-level tags, second-level tags, third-level tags, ..., Mth-level tags, such as... Figure 1 As shown, a full-level tag refers to a tag obtained by concatenating all tag levels, i.e., first-level tag items, second-level tag items, third-level tag items, ..., Mth-level tag items, such as... Figure 1"The first-level heading 1 - second-level heading 1 - third-level heading 1 -... - Mth-level heading 1" in is a full-level tag. In addition, a sub-tag that only contains the consecutive first N-level tag items starting from the first-level tag item is correspondingly called an N-level sub-tag. For example, a sub-tag that only contains the first-level tag item is a first-level sub-tag, such as "first-level heading 1", "first-level heading 2", or "first-level heading N"; a sub-tag that contains the first-level tag item and the second-level tag item is a second-level sub-tag, such as "first-level heading 1 - second-level heading 1", "first-level heading 1 - second-level heading 2", or "first-level heading N - second-level heading X"; a sub-tag that contains the first three-level tag items is a third-level sub-tag, such as "first-level heading 1 - second-level heading 1 - third-level heading 1", "first-level heading 1 - second-level heading 1 - third-level heading 2", or "first-level heading N - second-level heading X - third-level heading Y"; and so on. When M is relatively large, the model training and data prediction time of the algorithm strategy that directly predicts the full-level tag is relatively long, and the algorithm is relatively inefficient.
[0029] Therefore, in this application, it is proposed to observe the structure of the tag set of all training data and split each tag into a first tag item string and a second tag item string with a progressive relationship. Here, the first tag item string can contain the first N-level tag items of the entire tag, where N = 1, 2, 3,..., M - 1. That is to say, the first tag item string can only contain the first-level tag item, or it can also contain the first-level tag item to the N-level tag item (N < M). The second tag item string contains the remaining tag items of each level except the tag items contained in the first tag item string. Generally, each first tag item string contains the same number of tag items, that is, the last-level tag item of the first tag item string is at the same tag item level in their respective tags. For example, in Figure 1 an example of a tag set where a tag has at most M-level tag items as shown, the first tag item string is composed of the first two-level tag items, that is, the first-level tag item and the second-level tag item spliced together. At this time, the first tag item string can be, for example, "first-level heading 1 - second-level heading 1", "first-level heading 1 - second-level heading 2", "first-level heading N - second-level heading X", etc. (see Figure 1 the left dotted box). The second tag item string is composed of the third-level tag item to the Mth-level tag item spliced together, such as "third-level heading 1 -... - Mth-level heading 1", "third-level heading 1 -... - Mth-level heading 2", "third-level heading 2", "third-level heading Y -... - Mth-level heading Z", etc. (see Figure 1(The dashed box on the right). As can be seen from the diagram, each first tag string has multiple subordinate second tag strings, meaning each first tag string can correspond to multiple second tag strings. These second tag strings consist of all third-level to M-level tag strings following the last-level tag item (the second-level tag item in this example) of the first tag string. For example, Figure 1 All the second label strings within the solid line box, such as "Third-level Heading 1-...-Mth-level Heading 1", "Third-level Heading 1-...-Mth-level Heading 2", "Third-level Heading 2", etc., are the individual second label strings corresponding to the first label string "First-level Heading 1-Second-level Heading 1". This can be understood as follows: under the first-level category indicated by the first label string "First-level Heading 1-Second-level Heading 1", there are multiple second-level categories, each indicated by a separate second label string such as "Third-level Heading 1-...-Mth-level Heading 1", "Third-level Heading 2", etc. Therefore, the corresponding groups composed of second label strings that depend on their respective first label strings are independent of each other.
[0030] Alternatively, the last-level tags of each first-tag string can also be located at different tag levels. For example, in Figure 1 In the example shown, if the number of second tag strings corresponding to the first tag string "First-level Heading 1 - Second-level Heading 1" is much larger than the number of second tag strings corresponding to other first tag strings, then the first tag string can be adjusted to be composed of first-level, second-level, and third-level tags, such as "First-level Heading 1 - Second-level Heading 1 - Third-level Heading 1" and "First-level Heading 1 - Second-level Heading 1 - Third-level Heading 2". Correspondingly, the second tag strings corresponding to this adjusted first tag string will now only contain fourth-level to M-level tags. The remaining first tag strings are still composed of first-level and second-level tags, such as "First-level Heading 1 - Second-level Heading 2" and "First-level Heading N - Second-level Heading X", and the corresponding second tag strings contain third-level to M-level tags.
[0031] After separating the first and second label item strings, corresponding multi-label classification models are built for each. Here, a multi-label classification model is built for all first label item strings (hereinafter referred to as the first label set), which is called the first-level multi-label model. The first label set contains only the first label item strings. That is, the first-level multi-label model is trained using only the training data and its corresponding first label item strings, and the prediction result of this first-level multi-label model is therefore only one or more of the first label item strings. Then, for each first label item string, a multi-label classification model is built for all its corresponding second label item strings (hereinafter referred to as the second label set), which is called the second-level multi-label model. The second label set of each second-level multi-label model contains only all the second label item strings corresponding to a corresponding first label item string, that is, the group composed of these second label item strings. In other words, the data used to train the second-level multi-label model corresponding to a certain first label item string is only the training data whose original full-level labels contain that first label item string and its corresponding second label item strings. Since each group of the second label item string is independent of each other and depends only on its own first label item string, each second-level multi-label model can be trained independently of each other, that is, the training of the second-level multi-label models can be carried out in parallel.
[0032] After constructing and training the first-level and second-level multi-label models, when performing data prediction and classification, a piece of data to be predicted is first fed into the first-level multi-label model to predict the first label item string corresponding to the data. Then, the data is fed into the second-level multi-label model corresponding to the first label item string to predict the second label item string under the first label item string. Similarly, similar to the model training process, when predicting and classifying multiple data, the predictions of each second-level multi-label model can be performed independently and in parallel.
[0033] By concatenating the prediction results of the first-level multi-label model and the second-level multi-label model, a complete set of labels containing multi-level progressive relationships can be obtained. That is, each second label item string in the group corresponding to each first label item string is concatenated to the first label item string to obtain the complete label.
[0034] In the above method, assuming the number of first label item strings in the first label set is P, that is, the data can be divided into P categories when classified and predicted by the first-level multi-label model, then there are also a total of P second-level multi-label models. Therefore, the model structure of the algorithm in this application is "1+P", that is, one first-level multi-label model and P second-level multi-label models. As mentioned above, since the P second-level multi-label models are independent of each other, their training and prediction can be carried out in parallel, thereby significantly reducing the time spent on model training and data prediction.
[0035] In the "1+P" model structure of the algorithm in this application, the key is how to choose or determine the number P of the first label item strings. Here, P should not be too large or too small. Too large a P will result in a large number of second-level multi-label models, significantly increasing the workload. Too small a P will result in too few parallel-running second-level multi-label models, while each second-level multi-label model will need to predict too many second label item strings, failing to significantly improve the training and data prediction time of the entire system. The specific number of first-level label items to be merged into the first label item string should be adjusted based on the specific scenario.
[0036] For example, the number of first-level label items that the first label item string should contain can be determined based on the total number of labels in the training data's label set and / or the number of i-th level sub-labels, i.e., the number of sub-labels (i = 1, 2, 3, ..., M-1) formed by concatenating the first i-th level label items. One possible design is to determine the value of P based on the total number of labels in the training data's label set. For example, when the total number of labels is several hundred to several thousand, P is chosen as an integer between 10 and 20, while when the total number of labels is less than 100, P is chosen as an integer between 2 and 5.
[0037] Alternatively, for cases where each first tag string contains the same number of tag items, the total number of tags n can be calculated sequentially. T The number of i-th level sub-tags n i The ratio s i (i = 1, 2, ..., M-1). Suppose that when i = j, the ratio s j When the ratio s exceeds a predetermined threshold δ and i = j + 1, the ratio s j+1 Less than or equal to the threshold δ, i.e., s j =n T / n j ≥δ and s j+1 =n T / n j+1 If the threshold δ is less than 10, then the first j-level tag items are merged into the first tag item string. In this case, the number P of the first tag item string is equal to the number of sub-tags formed by concatenating the first j-level tag items. The threshold δ can be, for example, 10.
[0038] In other words, the algorithm in this application merges consecutive levels of labels to obtain new "labels," and establishes corresponding multi-label classification models for each new "label," thereby simplifying the multi-level progressive relationships that need to be processed when directly classifying all levels of labels. This can be understood as follows: first, the first-level multi-label model is used to predict the first label item string, roughly dividing the data into P first-level categories, i.e., P major categories; then, for the data under each first-level category, the corresponding second-level multi-label model is used to independently predict the second label item string under each first label item string, further classifying the data into various second-level categories, i.e., various minor categories.
[0039] The following is for reference. Figure 2 Taking a specific application scenario, such as multi-label customer review data in the catering industry, as an example, this paper illustrates the algorithm strategy described above. Customer review data is primarily in the form of text data in sentences or paragraphs that conform to linguistic conventions. For example... Figure 2 As shown, in the customer review data tag set, a single tag has a maximum of five levels of hierarchical relationship, i.e., M=5. The figure shows that the first-level tags include "negative" and "positive". Second-level tags include "food", "service", "second-level heading 3", "second-level heading 4", "second-level heading 5", etc. Third-level tags include "pizza", "hamburger", "waiter / customer service attitude", "service speed", "third-level heading R", etc. Fourth-level tags include "cooking time", "portion size", "fourth-level heading T", etc. Fifth-level tags include "burnt", "undercooked", etc. Here, there are, for example, two first-level sub-tags composed of the first-level tags: "negative" and "positive". There are, for example, ten second-level sub-tags composed of the first and second-level tags, including "negative-food", "negative-service", "negative-second-level heading 3", "negative-second-level heading 4", "negative-second-level heading 5", "positive-food", "positive-service", "positive-second-level heading 3", "positive-second-level heading 4", and "positive-second-level heading 5". There are 71 sub-tags composed of the first three levels of tags, such as "Negative-Food-Pizza", etc. ... There are 457 full-level tags composed of all levels of tags, such as "Negative-Food-Pizza-Cooking-Burnt" and "Positive-Food-Pizza-Perfectly Cooked", etc.
[0040] First, determine how many levels of tags should be merged into the first tag string; that is, determine the value of the number P of the first tag string. Here, as mentioned above, the number n of level i sub-tags... i (i = 1, 2, ..., M-1) represent the number of first-level sub-tags n1 = 2, the number of second-level sub-tags n2 = 10, the number of third-level sub-tags n3 = 71, ..., the total number of tags n T=457. Assume the threshold δ is 10.
[0041] Calculate the total number of tags n sequentially. T The number of i-th level sub-tags n i The ratio s i :
[0042] s1=n T / n1=457 / 2=228.5>δ=10,
[0043] s2=n T / n2=457 / 10=45.7>δ=10,
[0044] s3=n T / n3=457 / 71=6.4<δ=10,
[0045] ...
[0046] Since the ratio s2 exceeds the threshold δ when i=2 and the ratio s3 is less than the threshold δ when i=3, it can be determined that j=2. That is, when splitting the full-level tags with the above five-level progressive relationship into the first tag item string and the second tag item string of this application, the first two levels of tag items, i.e., the first-level tag items and the second-level tag items, are merged into the first tag item string. At this time, the number P of the first tag item string is equal to the number n2 of the second-level sub-tags, i.e., P=10. The 10 first-level tag strings are: first-level tag string 101 "Negative - Food", first-level tag string 102 "Negative - Service", first-level tag string 103 "Negative - Second-level Heading 3", first-level tag string 104 "Negative - Second-level Heading 4", first-level tag string 105 "Negative - Second-level Heading 5", first-level tag string 201 "Positive - Food", first-level tag string 202 "Positive - Service", first-level tag string 203 "Positive - Second-level Heading 3", first-level tag string 204 "Positive - Second-level Heading 4", and first-level tag string 205 "Positive - Second-level Heading 5". The remaining third-level, fourth-level, and fifth-level tags are combined into second-level tag strings.
[0047] Therefore, a 1+P multi-label model is constructed for the first and second label item strings, where P=10. First, a first-level multi-label model is constructed or trained for all first-label item strings, with the following label sets to be predicted: first-label item string 101, first-label item string 102, first-label item string 103, first-label item string 104, first-label item string 105, first-label item string 201, first-label item string 202, first-label item string 203, first-label item string 204, and first-label item string 205. For the second-label item strings, 10 second-level multi-label models are constructed or trained: 101, 102, 103, 104, 105, 201, 202, 203, 204, and 205.
[0048] After training 1+P models, during data prediction and classification, the customer review data to be predicted is first fed into a first-level multi-label model to predict the first label item string corresponding to that customer review data. Then, the dataset of customer review data with a predicted first label item string is fed into the corresponding second-level multi-label model to predict the second label item string under that first label item string. Finally, the prediction results from the first-level and second-level multi-label models are concatenated to obtain a complete multi-level progressive label. Here, these 10 second-level multi-label models can perform predictions on their respective datasets in parallel.
[0049] Although the above uses customer review data from the catering industry as an example to introduce the multi-label classification method of this application, those skilled in the art should understand that the multi-label classification scheme of this application can be applied to other applicable application scenarios, such as citizen / resident opinions and suggestions, product and service consultations, product evaluations, and new product trial feedback in other service industries.
[0050] For text data classification, Natural Language Processing (NLP) models can be used, typically the BERT model as a first-level multi-label model and P second-level multi-label models. NLP models, as typical deep learning models, can extract text features from text data (i.e., text vectorization) and determine corresponding labels indicating the category of the text data based on these features. However, those skilled in the art should understand that the first-level and second-level multi-label models in this application are not limited to NLP models, but include any model suitable for text data classification; nor are they limited to machine learning models or deep learning models (such as various neural network models of DNN), but can also include other models that implement classification functions and have a training process, such as tree structures.
[0051] Furthermore, besides text data, the multi-label classification scheme of this application can also be applied to other applicable data types, such as image data and audio data, as long as the multiple label items used to indicate the category corresponding to the data have a multi-level progressive relationship. In this case, a classification model suitable for the data type is used.
[0052] First-level and second-level multi-label models can have the same structure or framework, but they can also have different structures or frameworks, i.e., they can use different models. When the structure or framework of the second-level multi-label model is the same as that of the first-level multi-label model, the data itself may not be fed into the second-level multi-label model corresponding to the predicted first label item string. Instead, the intermediate results obtained in the process of predicting the first label item string in the first-level multi-label model can be directly used in the corresponding second-level multi-label model, such as the text feature vector in a text classification model.
[0053] If a data point is predicted to have multiple first-label item strings in a first-level multi-label model, that is, a data point contains multiple aspects of content, then for each predicted first-label item string, the data point will be sent to the second-level multi-label model corresponding to that first-label item string.
[0054] Alternatively, you can first train a first-level multi-label model, and then train P second-level multi-label models, or you can train a first-level multi-label model and P second-level multi-label models simultaneously.
[0055] exist Figure 3 In the exemplary embodiment of this application shown, an apparatus 300 is provided for multi-label classification of text data 601, 602, 603, ..., wherein the category of the text data determined by the apparatus is represented by a label 700 containing multiple levels of label items with a progressive relationship.
[0056] The device 300 includes a first module 310, which is used to predict the first tag item strings 710, 712, 713, ... representing the first level category of the text data 601, 602, 603, ... Each first tag item string 711, 712, 713, ... contains one or more levels of tag items with a progressive relationship.
[0057] The device 300 further includes a plurality of second modules 3201, 3202, 3203, ..., each of the second modules being used to predict, based on the first-level category of the text data 601, 602, 603, ..., the second tag item strings 721, 722, 723, ... representing its second-level category, wherein the second-level category belongs to a sub-category of the first-level category, and each second tag item string 721, 722, 723, ... contains one or more levels of tag items with a progressive relationship.
[0058] Here, each second module 3201, 3202, 3203, ... is used independently to predict those second tag strings that have a progressive relationship with a first tag string. When predicting the second tag strings of text data 601, 602, 603, ..., only the text data 601, 602, 603, ... is sent to the second module 3201, 3202, 3203, ... corresponding to the first tag string predicted by the first module 310. That is, each second module 3201, 3202, 3203, ... only performs classification prediction on text data where the first tag string predicted by the first module 310 is the same as the first tag string corresponding to that second module. For example, suppose that in the first module 310, the predicted first tag strings of text data 601 and 603 correspond to the second module 3202, while the predicted first tag string of text data 602 corresponds to the second module 3201. Then, in order to predict the second tag strings of the corresponding text data, text data 601 and 603 are sent to the second module 3202, while text data 602 is sent to the second module 3201. Preferably, each of the second modules 3201, 3202, 3203, ... can be designed to perform the prediction of the second tag strings in parallel with each other.
[0059] In other words, the first module 310 and each of the second modules 3201, 3202, 3203, ... can independently perform data classification. The output of the first module 310 is the first label item strings 711, 712, 713, ... The output of each second module 3201, 3202, 3203 is the second label item string 721, 722, 723, ... corresponding to the corresponding first label item string.
[0060] In addition, the device 300 also includes a splicing module 330, which is used to splice the first tag item strings 711, 712, 713, ... and the corresponding second tag item strings 721, 722, 723, ... to obtain the classification results of text data 601, 602, 603, ...
[0061] According to one embodiment of this application, the total number of second modules 3201, 3202, 3203, ... is the same as the number of first-level categories that can be predicted by the first module 310. The number of first-level categories that can be predicted by the first module may be related to the total number of data categories represented by labels in the label set of training data used to train the first module and / or the second module. For example, this number may be in the range of 5 to 20.
[0062] Alternatively, the number of first-level categories that can be predicted by the first module can be equal to the total number n of data categories represented by the labels in the label set of the training data. T and the number n of data categories represented by i-level sub-labels i The i-th level sub-label is the label item string composed of the first i consecutive label items in the label set of the training data.
[0063] For example, the number of first-level categories can be determined by the total number n of data categories represented by the labels in the label set. T The number n of data categories represented by the i-th level sub-label i The ratio s i =n T / n i To determine. In an exemplary embodiment, it can be specified that: if the ratio s is such that when i = j i The ratio s exceeds a predetermined threshold δ and i = j + 1. i Less than or equal to the threshold δ, that is, s j =n T / n j ≥δ and s j+1 =n T / n j+1 If the threshold δ is less than 10, then the first label string is determined to include the first j-level labels of the training data. The threshold δ can be, for example, 10.
[0064] Each first tag string predicted by the first module 310 may contain the same number of tag items. However, the number of tag items contained in each string may also differ from one another.
[0065] The first module 310 and each of the second modules 3201, 3202, 3203, ... may have the same structure or framework, but may also use different structures or frameworks for each other.
[0066] If multiple first label item strings are predicted by the first module 310, the text data is sent to the second modules 3201, 3202, 3203, ... corresponding to each predicted first label item string.
[0067] Multiple second modules 3201, 3202, 3203, ... are trained only after the first module 310 is trained. Advantageously, each second module 3201, 3202, 3203, ... is trained in parallel.
[0068] The text data that can be categorized by the device 300 includes customer review data from the catering industry.
[0069] According to embodiments of this application, in Figure 4 The image shows a method 400 for classifying text data, which includes the following steps:
[0070] Predict the first tag item string of the S410 text data, the first tag item string is used to represent the first level category of the text data, wherein the first tag item string includes one or more levels of tag items with a progressive relationship;
[0071] Based on the first-level category of the text data, predict the second tag item string of the text data in S420. The second tag item string represents the second-level category of the text data, which is a subcategory of the first-level category. The second tag item string includes one or more levels of tag items with a progressive relationship.
[0072] By concatenating the first tag string and the corresponding second tag string (S430), the classification result of the text data is obtained.
[0073] In an exemplary embodiment, the first tag item string is predicted by the first module 310, and / or the second tag item string is predicted by each of the second modules 3201, 3202, 3203, ..., wherein, when predicting the second tag item string, the corresponding text data is sent to the second module corresponding to the first tag item string predicted by the first module.
[0074] In another exemplary embodiment, when predicting the first tag item string and / or the second tag item string in S410 and S420, the method 400 of this application may also be implemented nested, that is, firstly predicting the sub-first tag item string of the first tag item string and / or the second tag item string for representing its sub-first level category, then predicting the sub-second tag item string of the first tag item string and / or the second tag item string for representing its sub-second level category according to the sub-first level category of the first tag item string and / or the second tag item string, and then concatenating the sub-first tag item string and the corresponding sub-second tag item string to obtain the corresponding first tag item string and / or the second tag item string.
[0075] In exemplary embodiments of this application, a computer-readable storage medium is also provided, on which a computer program is stored, the program including executable instructions that, when executed by, for example, a processor, can implement the steps of the method for classifying text data described in the above embodiments. In some possible implementations, various aspects of this application can also be implemented as a program product including program code that, when run on a terminal device, causes the terminal device to perform the steps described in the text data classification method according to various exemplary embodiments of this application.
[0076] In an exemplary embodiment of this application, an electronic device is also provided, which may include a processor and a memory for storing executable instructions of the processor. The processor is configured to perform the steps of the method for classifying text data in the above embodiments by executing the executable instructions.
[0077] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."
[0078] The following reference Figure 5 To describe an electronic device 500 according to this embodiment of the present application. Figure 5 The electronic device 500 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0079] like Figure 5 As shown, the electronic device 500 is presented in the form of a general-purpose computing device. The components of the electronic device 500 may include, but are not limited to: at least one processing unit 510, at least one storage unit 520, a bus 530 connecting different system components (including storage unit 520 and processing unit 510), a display unit 540, etc.
[0080] The storage unit stores program code that can be executed by the processing unit 510, causing the processing unit 510 to perform the steps described in the business data classification method of this specification according to various exemplary embodiments of this application. For example, the processing unit 510 can perform actions such as... Figure 4 The corresponding steps of the method shown.
[0081] The storage unit 520 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 5201 and / or a cache storage unit 5202, and may further include a read-only memory unit (ROM) 5203.
[0082] The storage unit 520 may also include a program / utility 5204 having a set (at least one) program module 5205, such program module 5205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0083] Bus 530 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0084] Electronic device 500 can also communicate with one or more external devices 590 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 500, and / or with any device that enables electronic device 500 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 550. Furthermore, electronic device 500 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 560. Network adapter 560 can communicate with other modules of electronic device 500 via bus 530. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0085] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, or network device, etc.) to execute the business data classification method according to the embodiments of this application.
[0086] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this application are indicated by the appended claims.
Claims
1. A method for classifying text data, characterized in that, The method includes: Predict the first tag string of the text data, the first tag string being used to represent the first-level category of the text data, wherein the first tag string includes one or more levels of tag items with a progressive relationship. Based on the first-level category of the text data, a second label item string is predicted for the text data. The second label item string represents the second-level category of the text data, which is a subcategory of the first-level category. The second label item string includes one or more levels of labels with a progressive relationship. The first label item string is predicted by a first module, and / or the second label item string is predicted by a second module. The number of first-level categories that can be predicted by the first module is equal to the total number n of data categories represented by the labels in the label set of the training data. T and by i The number of data categories represented by the sub-label n i Related to, among them i The level sub-tag is the first of the tags in the tag set. i A string of consecutive label items, the training data being used to train a first module and / or a second module, wherein the total number n of data categories represented by the labels in the label set. T with by i The number of data categories represented by the sub-label n i The ratio s i = n T / n i Determine the number of first-level categories. The classification result of the text data is obtained by concatenating the first tag string and the second tag string.
2. The method according to claim 1, characterized in that, When predicting the second tag item string, the corresponding text data is sent to the second module corresponding to the first tag item string predicted by the first module.
3. The method according to claim 2, characterized in that, Each of the second modules is designed to predict the second tag item string corresponding to the corresponding first tag item string in parallel with each other.
4. The method according to claim 2 or 3, characterized in that, The total number of the second module is the same as the number of first-level categories that can be predicted by the first module.
5. The method according to claim 2 or 3, characterized in that, The number of first-level categories that can be predicted by the first module is related to the total number of data categories represented by labels in the label set of the training data, which is used to train the first module and / or the second module.
6. The method according to claim 2 or 3, characterized in that, The number of first-level categories that can be predicted by the first module is in the range of 5 to 20.
7. The method according to claim 1, characterized in that, If when i = j The ratio s mentioned at that time i Exceeding a predetermined threshold and i = j The ratio s when +1 i Less than or equal to the threshold That is, s j = n T / n j ≥ And s j+1 = n T / n j+1 < If so, then it is determined that the first label item string includes the first j-level label items of the training data.
8. The method according to claim 7, characterized in that, The threshold It is 10.
9. The method according to claim 2 or 3, characterized in that, The first tag strings predicted by the first module contain the same number of tag items, or the first tag strings predicted by the first module contain different numbers of tag items.
10. The method according to claim 2 or 3, characterized in that, The first module and the second module have the same structure or architecture, or the first module and the second module have different structures or architectures.
11. The method according to claim 2 or 3, characterized in that, If the text data is predicted to produce multiple first label item strings through the first module, the text data is then sent to the second module corresponding to each predicted first label item string.
12. The method according to claim 2 or 3, characterized in that, After the first module is trained, the second module is trained.
13. The method according to claim 2 or 3, characterized in that, Each of the second modules is trained in parallel.
14. The method according to any one of claims 1 to 3, characterized in that, The text data includes customer review data from the catering industry.
15. An apparatus for classifying text data, characterized in that, The device includes: The first module is used to predict a first tag item string of the text data. The first tag item string represents the first-level category of the text data, wherein the first tag item string includes one or more levels of tag items with a progressive relationship. The second module is used to predict a second label item string of the text data based on the first-level category of the text data. The second label item string represents the second-level category of the text data, which is a subcategory of the first-level category. The second label item string includes one or more levels of labels with a progressive relationship. The first label item string is predicted by the first module, and / or the second label item string is predicted by the second module. The number of first-level categories that can be predicted by the first module is equal to the total number n of data categories represented by the labels in the label set of the training data. T and by i The number of data categories represented by the sub-label n i Related to, among them i The level sub-tag is the first of the tags in the tag set. i A string of consecutive label items, the training data being used to train a first module and / or a second module, wherein the total number n of data categories represented by the labels in the label set. T with by i The number of data categories represented by the sub-label n i The ratio s i = n T / n i Determine the number of first-level categories. The concatenation module is used to concatenate the first tag item string and the corresponding second tag item string to obtain the classification result of the text data.
16. A computer-readable storage medium having a computer program stored thereon, the computer program including executable instructions that, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 14.
17. An electronic device for classifying text data, characterized in that, The electronic device includes: Processor; and Memory for storing the executable instructions of the processor; The processor is configured to execute the executable instructions to implement the method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Multi-level progressive classification method and system based on neural network and Bayesian model
CN109784387A
Data classification method and device, model training method and device and electronic equipment
CN111783861A