Content classification method, device, electronic device and computer-readable storage medium
By first-level and second-level classification of content and using the label classification system to constrain, the problem of insufficient accuracy of content classification in the existing technology is solved, and the accuracy of secondary labels and overall classification accuracy are improved.
Patent Information
- Application Number
- CN202110770656.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-08
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-07-08
AI Technical Summary
The existing content classification method has insufficient classification accuracy, especially because the classification of upper-level categories with coarse granularity is less difficult but has high accuracy, while the classification label with the smallest output level is low, resulting in the accuracy of content classification. insufficient.
By obtaining the text characteristics of the content to be classified, first perform first-level classification to obtain the first-level classification label, then determine the second-level classification parameters based on the first-level classification label, perform the second-level classification, and finally classify the content based on the second-level classification label, fully Use the label classification system to constrain and improve the accuracy of secondary labels.
The accuracy of content classification is improved, and the lower-level target labels are constrained through the upper-level target labels, which increases the accuracy of the secondary labels and improves the accuracy of the overall classification.
Smart Images

Figure CN113821632B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a content classification method, device, electronic device and computer-readable storage medium. Background Art
[0002] In recent years, with the rapid development of Internet technology, a huge amount of content has emerged. In order to facilitate the management of these contents, it is often necessary to classify the content. The classification categories can often include multiple classification levels, for example, they can be divided into primary and secondary levels, etc. Existing content classification methods often use classification models to classify content in multiple ways, directly output the classification label with the smallest level (i.e., the smallest granularity), and then use the results to trace back the classification labels of other levels to complete content classification.
[0003] In the process of research and practice of the prior art, the inventors of the present invention found that for the classification model, the higher the category system, the coarser the granularity, but the classification difficulty will be simpler, and a higher classification accuracy can often be obtained. The classification accuracy of the classification label with the smallest direct output level is relatively the lowest, thus resulting in insufficient accuracy in content classification. Summary of the invention
[0004] Embodiments of the present invention provide a content classification method, device, electronic device, and computer-readable storage medium, which can improve the accuracy of content classification.
[0005] A content classification method, comprising:
[0006] Acquire content to be classified, wherein the content to be classified includes text content;
[0007] Extracting features from the text content to obtain text features of the text content, and classifying the text features to obtain at least one primary classification label for the content to be classified;
[0008] Determining secondary classification parameters of the content to be classified according to the primary classification label;
[0009] Based on the secondary classification parameters, the text features are classified to obtain secondary classification labels of the content to be classified;
[0010] The content to be classified is classified according to the secondary classification label.
[0011] Accordingly, an embodiment of the present invention provides a content classification device, including:
[0012] An acquisition unit, used for acquiring content to be classified, wherein the content to be classified includes text content;
[0013] A primary classification unit, used to extract features from the text content to obtain text features of the text content, and classify the text features to obtain at least one primary classification label for the content to be classified;
[0014] A determination unit, configured to determine a secondary classification parameter of the content to be classified according to the primary classification label;
[0015] A secondary classification unit, used to classify the text features based on the secondary classification parameters to obtain a secondary classification label of the content to be classified;
[0016] The content classification unit is used to classify the content to be classified according to the secondary classification label.
[0017] Optionally, in some embodiments, the first-level classification unit can be specifically used to use the first-level classification network of the trained content classification model to normalize the text features to obtain normalized text features; determine the probability information corresponding to the preset first-level classification label set based on the normalized text features; and based on the probability information, screen out at least one first-level classification label of the content to be classified from the preset first-level classification labels.
[0018] Optionally, in some embodiments, the determination unit can be specifically used to obtain attribute information of the secondary classification network in the trained content classification model; identify the network identifier of each secondary classification network in the attribute information; filter out the network identifier corresponding to the primary classification label from the network identifiers to obtain the target network identifier, and use the target network identifier as the secondary classification parameter of the content to be classified.
[0019] Optionally, in some embodiments, the secondary classification unit can be specifically used to screen out at least one target secondary classification network in the secondary classification network according to the secondary classification parameters; use the target secondary classification network to classify the text features to obtain classification information of the text features; and fuse the classification information to obtain a secondary classification label for the content to be classified.
[0020] Optionally, in some embodiments, the secondary classification unit can be specifically used to fuse the candidate secondary classification label set to obtain a target secondary classification label set for the content to be classified; fuse the probability distribution information to obtain the classification probability of each secondary classification label in the target secondary classification label set; and screen out the secondary classification labels of the content to be classified in the target secondary classification label set based on the classification probability.
[0021] Optionally, in some embodiments, the content classification device may further include a training unit, which may be specifically used to obtain content samples and perform feature extraction on text in the content samples to obtain sample text features, wherein the content samples include content marked with primary classification labels and secondary classification labels; the sample text features are classified using a primary classification network of a preset content classification model to obtain at least one predicted primary classification label of the content sample; the text features are classified using a secondary classification network corresponding to the predicted primary classification label in the preset content classification model to obtain a predicted secondary classification label of the content sample; the preset content classification model is converged according to the marked primary classification labels and secondary classification labels, as well as the predicted primary classification labels and predicted secondary classification labels to obtain the trained content classification model.
[0022] Optionally, in some embodiments, the training unit can be specifically used to determine the first-level classification loss information of the content sample based on the marked first-level classification label and the predicted first-level classification label; determine the second-level classification loss information of the content sample based on the marked second-level classification label and the predicted second-level classification label; determine the classification level loss information of the content sample based on the predicted first-level classification label and the predicted second-level classification label; fuse the first-level classification loss information, the second-level classification loss information and the classification level loss information, and converge the preset content classification model based on the fused loss information to obtain a trained content classification model.
[0023] Optionally, in some embodiments, the training unit can be specifically used to compare the marked first-level classification label with the predicted first-level classification label to obtain a first prediction result parameter of the first-level classification label; obtain a first prediction probability of each predicted first-level classification label, and fuse the first prediction probability with the first prediction result parameter to obtain the first-level classification loss information of the content sample.
[0024] Optionally, in some embodiments, the training unit can be specifically used to fuse the first prediction probability with the first prediction result parameter to obtain initial first-level classification loss information of each predicted first-level classification label; fuse the initial first-level classification loss information, and invert the fused first-level classification loss information to obtain the first-level classification loss information of the content sample.
[0025] Optionally, in some embodiments, the training unit can be specifically used to compare the marked secondary classification label with the predicted secondary classification label to obtain a second prediction result parameter of the secondary classification label; obtain the second prediction probability of each predicted secondary classification label, and fuse the second prediction probability with the second prediction result parameter to obtain the secondary classification loss information of the content sample.
[0026] Optionally, in some embodiments, the training unit can be specifically used to respectively calculate the predicted probability difference between the predicted first-level classification label and the predicted second-level classification label; obtain the preset prediction probability parameter corresponding to the content sample, and fuse the predicted probability difference with the predicted probability parameter to obtain the classification level loss information of the content sample.
[0027] Optionally, in some embodiments, the training unit can be specifically used to fuse the predicted probability difference with the predicted probability parameter to obtain an initial classification level loss value; compare the initial classification level loss value with a preset loss value threshold, and determine the target classification level loss value of the content sample based on the comparison result; fuse the target classification level loss value to obtain the classification level loss information of the content sample.
[0028] In addition, an embodiment of the present invention further provides an electronic device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to implement the content classification method provided by the embodiment of the present invention.
[0029] In addition, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor to execute the steps in any one of the content classification methods provided by the embodiments of the present invention.
[0030] The embodiment of the present application obtains the content to be classified, extracts features from the text content in the content to be classified, obtains text features of the text content, and classifies the text features to obtain at least one first-level classification label for the content to be classified, and then, based on the first-level classification label, determines the second-level classification parameters of the content to be classified, and then, based on the second-level classification parameters, classifies the text features to obtain the second-level classification labels of the content to be classified, and finally, classifies the content to be classified based on the second-level classification labels; because the scheme first classifies the first-level labels of the content to be classified, and then determines the second-level classification labels of the content to be classified based on the first-level classification labels, it makes full use of the label classification system, adopts the upper-level category labels (first-level labels) to constrain the lower-level label categories (secondary labels), increases the accuracy of the second-level labels, and therefore can improve the accuracy of content classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0032] Figure 1 is a schematic diagram of a scenario of a content classification method provided by an embodiment of the present invention;
[0033] Figure 2 is a flow chart of a content classification method provided by an embodiment of the present invention;
[0034] Figure 3 is a schematic diagram of the structure of a hierarchical classification model provided by an embodiment of the present invention;
[0035] Figure 4 is another flowchart of the content classification method provided by an embodiment of the present invention;
[0036] Figure 5 is a schematic diagram of hierarchical classification based on video titles provided by an embodiment of the present invention;
[0037] Figure 6 is a structural diagram of a content classification device provided by an embodiment of the present invention;
[0038] Figure 7 is another structural schematic diagram of a content classification device provided by an embodiment of the present invention;
[0039] Figure 8 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0041] The embodiment of the present invention provides a content classification method, device, electronic device and computer-readable storage medium. The content classification device can be integrated in an electronic device, which can be a server or a terminal.
[0042] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0043] For example, see Figure 1 Taking the content classification device integrated in an electronic device as an example, after obtaining the content to be classified, the electronic device extracts features of the text content in the content to be classified to obtain text features of the text content, and classifies the text features to obtain at least one primary classification label of the content to be classified, and then, based on the primary classification label, determines the secondary classification parameters of the content to be classified, and then, based on the secondary classification parameters, classifies the text features to obtain the secondary classification labels of the content to be classified, and then, based on the secondary classification parameters, classifies the content to be classified, thereby improving the accuracy of content classification.
[0044] It should be noted that the content classification method provided in the embodiment of the present application involves natural language processing technology in the field of artificial intelligence, that is, in the embodiment of the present application, the natural language processing technology of artificial intelligence can be used to extract features of text content, and the classified content can be classified based on the extracted text features.
[0045] Artificial Intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, as well as machine learning / deep learning, autonomous driving, and smart transportation.
[0046] Among them, natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0047] It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0048] This embodiment will be described from the perspective of a content classification device, which can be specifically integrated into an electronic device, which can be a server or a terminal. The terminal can include a tablet computer, a laptop computer, a personal computer (PC), a wearable device, a virtual reality device, or other smart devices that can perform content classification.
[0049] A content classification method, comprising:
[0050] Obtain content to be classified, which includes text content, perform feature extraction on the text content to obtain text features of the text content, classify the text features to obtain at least one primary classification label for the content to be classified, determine secondary classification parameters of the content to be classified based on the primary classification labels, classify the text features based on the secondary classification parameters to obtain secondary classification labels for the content to be classified, and classify the content to be classified based on the secondary classification labels.
[0051] like Figure 2 As shown, the specific process of the content classification method is as follows:
[0052] 101. Obtain content to be classified.
[0053] Among them, the content to be classified includes text content. There can be multiple types of content to be classified, for example, it can be video content, text content, image content or audio content, etc. The text content can be the title of the content to be classified, a certain paragraph of text in the content, etc. For example, taking the content to be classified as video content as an example, the text content can be the title of the video content. Taking the content to be classified as text content as an example, the text content can be the title of the text content or one or more paragraphs of text in the content.
[0054] There are many ways to obtain the content to be classified. For example, the content to be classified can be obtained directly, or when the amount of the content to be classified is large or the memory is large, the content to be classified can be obtained indirectly, which can be as follows:
[0055] (1) Directly obtain the content to be classified.
[0056] For example, the content to be classified uploaded by the user through the terminal may be directly obtained, or the original content may be directly obtained from the network or content database, and the content containing text may be screened out from the original content to obtain the content to be classified.
[0057] (2) Indirectly obtain the content to be classified.
[0058] For example, a content classification request sent by a terminal is received, the content classification request carries a storage address of the content to be classified, and the content to be classified is obtained from a memory, a cache, or a third-party database according to the storage address.
[0059] Optionally, after obtaining the content to be classified, text content can be extracted from the content to be classified. There can be multiple ways to extract, for example, identifying content in the form of text in the content to be classified to obtain text content, or identifying content in the form of text in the content to be classified to obtain initial text content, and preprocessing the initial text content, for example, performing stop word filtering, deduplication and other preprocessing methods on the initial text content to obtain text content.
[0060] 102. Perform feature extraction on the text content to obtain text features of the text content, and classify the text features to obtain at least one primary classification label for the content to be classified.
[0061] Among them, the first-level classification label can be the first-level classification label for classifying the content to be classified. The first-level classification label is the largest level (that is, the coarsest granularity). The next-level classification label of the first-level classification label can be the second-level classification label. The first-level classification label and the second-level classification label have a superior-subordinate relationship. The superior label is the parent of the subordinate label, and the granularity becomes finer as you go down.
[0062] There are many ways to perform primary classification on the content to be classified. For example, a feature extraction network of a trained content classification model is used to extract features from text content to obtain text features of the text content, and a primary classification network of a trained content classification model is used to classify the text features to obtain at least one primary classification label of the content to be classified. Specifically, the following method can be used:
[0063] S1. Extract features from the text content to obtain text features of the text content.
[0064] For example, the feature extraction network of the trained content classification model can be used to semantically encode the text content, thereby obtaining a semantic vector of the encoded text content, and the encoded semantic vector is used as the text feature of the text content.
[0065] There may be multiple feature extraction networks for semantic encoding of text content, for example, multiple network structures including CNN (convolutional neural network), LSTM (long short-term memory network) or LSTM+Attention (attention network).
[0066] S2. Classify the text features to obtain at least one first-level classification label for the content to be classified.
[0067] For example, the first-level classification network of the trained content classification model can be used to normalize the text features to obtain normalized text features, and the probability information corresponding to the preset first-level classification label set can be determined based on the normalized text features. Based on the probability information, at least one first-level classification label for the content to be classified can be screened out from the preset first-level classification labels.
[0068] There are many ways to normalize text features. For example, a softmax function (a normalization function) can be used to map text features to values between 0 and 1, and then the mapped values are normalized to obtain normalized text features.
[0069] After obtaining the normalized text features, the probability information corresponding to the preset first-level classification label set can be determined, wherein the probability information can be the classification probability of each preset first-level classification label in the preset first-level classification label set. There can be multiple ways to determine it. For example, the normalized text features can be used as the probability distribution corresponding to the preset first-level classification label set to obtain the probability information corresponding to the preset first-level classification label set. Alternatively, the normalized text features can be associated with the preset first-level classification label set to obtain the probability distribution corresponding to the preset first-level classification label set, and the classification probability of each preset first-level classification label is extracted from the probability distribution to obtain the probability information corresponding to the preset first-level classification label set.
[0070] After determining the probability information corresponding to the preset first-level classification tag set, at least one first-level classification tag of the content to be classified can be screened out from the preset first-level classification tag set based on the probability information. There can be multiple ways of screening. For example, the preset first-level classification tags can be sorted according to the classification probability of each preset first-level classification tag in the preset first-level classification tag set. According to the sorting result, the first-level classification tags within the preset sorting range are screened out from the preset first-level classification tag set as the first-level classification tags of the content to be classified. The preset sorting range can be the top N rankings, for example, the first ranking, or the top three, or the top ten, etc. Therefore, the first-level classification tag of the content to be classified can be one or more. When TOP N is ranked first, the first-level classification tag of the content to be classified can be one. When TOP N is ranked in the top two or other sorting ranges, the first-level classification tags of the content to be classified can be multiple.
[0071] The trained content classification model can be set according to the needs of actual applications. In addition, it should be noted that the trained content classification model can be set in advance by maintenance personnel, or can be trained by the content classification device itself, that is, before the step of "normalizing the text features using the primary classification network of the trained content classification model to obtain normalized text features", the content classification method can also include:
[0072] A content sample is obtained, and text features in the content sample are extracted to obtain sample text features, wherein the content sample includes content marked with a primary classification label and a secondary classification label, and the sample text features are classified using a primary classification network of a preset content classification model to obtain at least one predicted primary classification label of the content sample, and the text features are classified using a secondary classification network corresponding to the predicted primary classification label in the preset content classification model to obtain a predicted secondary classification network of the content sample, and the preset content classification model is converged according to the marked primary classification label and the secondary classification label, and the predicted primary classification label and the predicted secondary classification label to obtain a trained content classification model, which can be specifically as follows:
[0073] (1) Obtain a content sample and perform feature extraction on the text in the content sample to obtain sample text features.
[0074] Among them, content samples include content marked with primary classification labels and secondary classification labels.
[0075] There are many ways to obtain content samples. For example, you can directly receive content samples sent by users or content servers, or obtain original content from the network or content database, and send the text content of the original content to the annotation server for annotation, and receive the first-level classification label and second-level classification label of the text content returned by the annotation server to obtain content samples.
[0076] After obtaining the content sample, the feature extraction can be performed on the text in the content sample. There are many ways to extract the feature. For example, the feature extraction network of the preset content classification model can be used to semantically encode the text content, so as to obtain the semantic vector of the encoded text content, and the encoded semantic vector is used as the text feature of the text content. The specific extraction method is mentioned above, which will not be elaborated here.
[0077] (2) Using a first-level classification network of a preset content classification model to classify sample text features, at least one predicted first-level classification label of the content sample is obtained.
[0078] For example, the first-level classification network of the preset content classification model can be used to normalize the sample text features to obtain the normalized sample text features, and the probability information corresponding to the preset first-level classification label set can be determined based on the normalized sample text features. Based on the probability information, at least one predicted first-level classification label of the content sample is screened out from the preset first-level classification labels. The specific classification method is described above and will not be described here one by one.
[0079] (3) The text features are classified using the secondary classification network corresponding to the predicted primary classification label in the preset content classification model to obtain the predicted secondary classification label of the content sample.
[0080] For example, a secondary classification network corresponding to a predicted primary classification label can be screened out in a preset content classification model to obtain a target secondary classification network, and the target secondary classification network is used to classify text features to obtain a predicted secondary classification label for the content sample.
[0081] There are many ways to filter out the target secondary classification network. For example, the attribute information of the secondary classification network in the preset content classification model can be obtained, the network identifier of each secondary classification network can be identified in the attribute information, the network identifier corresponding to the predicted primary classification label can be filtered out from the network identifier, the network identifier can be obtained, and the secondary classification network corresponding to the filtered network identifier can be activated.
[0082] After screening out the target secondary classification network corresponding to the predicted primary classification label, the target secondary classification network can be used to classify the text features. There are many ways of classification. For example, the target secondary classification network can be used as an expert network to perform secondary classification on the text features, output a set of candidate secondary classification labels of preset dimensions and candidate probability distribution information corresponding to the candidate secondary classification label set, use the candidate secondary classification label set and the candidate probability distribution information as the classification information output by the expert network, and fuse the classification information output by each expert network to obtain the predicted secondary classification label set of the content sample and the target probability information corresponding to the predicted secondary classification label set. Identify the classification probability corresponding to each predicted secondary classification label in the target probability information, and screen out the predicted secondary classification label of the content sample in the predicted secondary classification label set based on the classification probability. The specific screening process can be found above, and will not be described here one by one.
[0083] Among them, the network structure of the secondary classification network (expert network) can be multiple, for example, it can be a preset number of DNN (deep neural network), CNN (convolutional neural network) or residual network, etc. The preset number can be set according to the actual application, for example, it can be 1, 2 or more.
[0084] (4) Based on the labeled first-level classification labels and the second-level classification labels, as well as the predicted first-level classification labels and the predicted second-level classification labels, the preset content classification model is converged to obtain a trained content classification model.
[0085] For example, the first-level classification loss information of the content sample can be determined based on the marked first-level classification labels and the predicted first-level classification labels, the second-level classification loss information of the content sample can be determined based on the marked second-level classification labels and the predicted second-level classification labels, the classification level loss information of the content sample can be determined based on the predicted first-level classification labels and the predicted second-level classification labels, the first-level classification loss information, the second-level classification loss information and the classification level loss information are fused, and the preset content classification model is converged based on the fused loss information to obtain the trained content classification model.
[0086] Among them, there are many ways to determine the first-level classification loss information of the content sample. For example, the marked first-level classification label can be compared with the predicted first-level classification label to obtain the first prediction result parameter of the first-level classification label, obtain the first prediction probability of each predicted first-level classification label, and merge the first prediction probability with the first prediction result parameter to obtain the first-level classification loss information of the content sample.
[0087] Among them, the prediction result parameter is used to indicate whether the prediction of the predicted first-level classification label is correct. When the predicted first-level classification label and the marked first-level classification label are the same, it can be determined that the prediction is correct. Otherwise, the prediction is incorrect. The correct prediction corresponds to a preset parameter value, and the incorrect prediction corresponds to another preset parameter value. For example, the prediction result parameter corresponding to the correct prediction can be 1, and the prediction result parameter corresponding to the incorrect prediction can be 0, or other prediction values can be used to represent that the prediction result parameters corresponding to the correct prediction and the incorrect prediction are different.
[0088] There are many ways to fuse the first prediction probability with the first prediction result. For example, the first prediction probability and the first prediction result parameter can be fused to obtain initial first-level classification loss information of each predicted first-level classification label, and the initial first-level classification loss information is fused, and the fused first-level classification loss information is inverted to obtain the first-level classification loss information of the content sample, as shown in formula (1):
[0089]
[0090] Among them, loss cls1 is the first-level classification loss information, y i is the first prediction result parameter, a i is the first predicted probability of predicting the first-level classification label, and n is the number of predicted first-level classification labels.
[0091] There are many ways to determine the secondary classification loss information of the content sample. For example, the marked secondary classification label is compared with the predicted secondary classification label to obtain the second prediction result parameter of the classification label, the second prediction probability of each predicted secondary classification label is obtained, and the second prediction probability is merged with the second prediction result parameter to obtain the secondary classification loss information of the content sample, as shown in formula (2):
[0092]
[0093] Among them, loss cls2 is the secondary classification loss information, y j is the second prediction result parameter, a j is the second predicted probability of predicting the secondary classification label, m is the number of predicted secondary classification labels, and the specific calculation process can be found above, which will not be repeated here.
[0094] Among them, there are many ways to determine the classification level loss information of the content sample. For example, the predicted probability difference between the predicted first-level classification label and the predicted second-level classification label can be calculated respectively, the predicted probability parameter corresponding to the content sample can be obtained, and the predicted probability difference can be merged with the predicted probability parameter to obtain the classification level loss information of the content sample.
[0095] Among them, there are many ways to calculate the predicted probability difference between the predicted first-level classification label and the predicted second-level classification label. For example, the difference between the first predicted probability of each predicted first-level classification label and the second predicted probability of each predicted second-level classification label is calculated respectively to obtain the predicted probability difference. Alternatively, the first weighting coefficient corresponding to the predicted first-level classification label can be determined according to the first predicted probability, and the second weighting coefficient corresponding to the predicted second-level classification label can be determined according to the second predicted probability. The first predicted probability is weighted according to the first weighting coefficient, and the second predicted probability is weighted according to the second weighting coefficient. Then, the difference between the weighted first predicted probability and the weighted second predicted probability is settled respectively to obtain the predicted probability difference.
[0096] After obtaining the predicted probability difference, the predicted probability difference and the predicted probability parameter can be fused to obtain the classification level loss information of the content sample. There are many ways to fuse them. For example, the predicted probability difference and the predicted probability parameter can be fused to obtain the initial classification level loss value. The initial classification level loss value is compared with the preset loss value threshold, and the target classification level loss value of the content sample is determined according to the comparison result. The target classification level loss value is fused to obtain the classification level loss information of the content sample, as shown in formula (3):
[0097]
[0098] Among them, loss h is the classification level loss information, λ is the prediction probability parameter, l2 score is the second probability, l1 score For the first prediction probability, the classification level loss information is mainly to ensure the consistency of the two-level classification results. The loss information obtained by adding a loss structure assumes that the upper-level categories are always easy to obtain fine-grained lower-level classification results, that is, the fine-grained difficulty should be greater. Therefore, the hinge loss function is added to ensure that the probability of the first-level classification should always be greater than the corresponding second-level classification result.
[0099] After obtaining the first-level classification loss information, the second-level classification loss information and the classification level loss information, these loss information can be fused. There are many ways to fuse them. For example, the weighting parameters corresponding to the first-level classification loss information, the second-level classification loss information and the classification level loss information can be obtained. According to the weighting parameters, the first-level classification loss information, the second-level classification loss information and the classification level loss information are weighted respectively, and the weighted first-level classification loss information, the second-level classification loss information and the classification level loss information are fused to obtain the fused loss information, as shown in formula (4):
[0100] Loss = λ1loss cls1 +λ2loss cls2 +λ3loss h (4)
[0101] Among them, Loss is the loss information after fusion, loss cls1 is the first-level classification loss information, loss cls2 is the secondary classification loss information, loss h is the classification level loss information, λ1, λ2 and λ3 are the weighting parameters corresponding to the first-level classification loss information, the second-level classification loss information and the classification level loss information respectively.
[0102] After obtaining the fused loss information, the preset content classification model can be converged based on the fused loss information. There are many ways to converge. For example, based on the fused loss information, a gradient update algorithm can be used to update the network parameters of the preset content classification model to converge the preset content classification model, and then obtain the trained content classification model. Alternatively, based on the fused loss information, other update algorithms can be used to update the network parameters of the preset content classification model to converge the preset content classification model, and then obtain the trained content classification model.
[0103] 103. Determine the secondary classification parameters of the content to be classified based on the primary classification label.
[0104] The secondary classification parameter may be a parameter for performing secondary classification on the content to be classified using a secondary classification network, and the parameter may be information such as a network identifier of the secondary classification network used for performing secondary classification on the content to be classified.
[0105] For example, the attribute information of the secondary classification network in the trained content classification model can be obtained, the network identifier of each secondary classification network can be identified in the attribute information, the network identifier corresponding to the primary classification label can be screened out from the network identifiers, the target network identifier can be obtained, and the target network identifier can be used as the secondary classification parameter of the content to be classified.
[0106] Among them, there can be multiple ways to identify the network identification of each secondary classification network in the attribute information. For example, the target attribute information corresponding to each secondary classification network can be extracted from the attribute information, and the identification information or identity information of each secondary classification network can be identified in the target attribute information, so as to obtain the network identification of each secondary classification network.
[0107] 104. Based on the secondary classification parameters, the text features are classified to obtain the secondary classification labels of the content to be classified.
[0108] For example, according to the secondary classification parameters, at least one target secondary classification network is selected from the secondary classification network, and the target secondary classification network is used to classify text features to obtain classification information of the text features, and the classification information is fused to obtain the secondary classification label of the content to be classified.
[0109] Among them, there are many ways to classify text features using the target secondary classification network. For example, the target secondary classification network can be used as an expert network, and the expert network can be used to perform secondary classification on text features, output a set of candidate secondary classification labels of preset dimensions and probability distribution information corresponding to the candidate secondary classification label set, and use the candidate secondary classification label set and probability distribution information as classification information output by the expert network.
[0110] After obtaining the classification information, the classification information of each secondary classification network can be fused. There are many ways to fuse them. For example, the candidate secondary classification label sets can be fused to obtain the target secondary classification label set of the content to be classified. The probability distribution information can be fused to obtain the classification probability of each secondary classification label in the target secondary classification label set. According to the classification probability, the secondary classification labels of the content to be classified can be screened out in the target secondary classification label set.
[0111] Among them, there are many ways to filter out the secondary classification labels of the content to be classified in the target secondary classification label set according to the classification probability. For example, according to the classification probability, the secondary classification label with the largest classification probability can be filtered out in the target secondary classification label set as the secondary classification label of the content to be classified. Alternatively, according to the classification probability, the secondary classification labels in the target secondary classification label set can be sorted, and the TOPN secondary classification labels can be filtered out from the sorted secondary classification labels as candidate secondary classification labels. The candidate secondary classification labels are classified to obtain a candidate secondary classification label set corresponding to each first-level classification label, and the candidate secondary classification label set with the largest number of secondary classification labels can be filtered out from the candidate secondary classification label set, and the secondary classification label with the largest classification probability can be filtered out from the filtered candidate secondary classification label set as the secondary classification label of the content to be classified.
[0112] 105. Classify the content according to the secondary classification labels.
[0113] For example, the content to be classified may be sent to a content set corresponding to a secondary classification tag to complete the classification of the content to be classified, or the secondary classification tag may be added to the content to be classified to complete the classification of the content to be classified.
[0114] Optionally, before sending the content to be classified to the content set corresponding to the secondary classification tag, the content to be classified can also be preprocessed, and the processed content to be classified can be sent to the content set corresponding to the secondary classification tag. There can be many ways of preprocessing, such as obtaining attribute information of the content set corresponding to the secondary classification tag, identifying the storage rules of the content set in the attribute information, compressing the content to be classified based on the storage rules, or converting the format of the content to be classified into a preset content format corresponding to the content set, and so on.
[0115] It should be noted that the preset content model can be a multi-expert hierarchical classification model, such as Figure 3As shown in the figure, the model uses a conventional multi-classification model on the first-level category, encodes the sentence as input to obtain a semantic vector, and then performs softmax multi-classification. For each first-level category, several expert neural network systems will be constructed to classify the second-level categories corresponding to the first-level category, making full use of the label classification system. The upper-level category labels constrain the lower-level category labels. Moreover, the upper-level prediction results with low prediction difficulty can be used as the prior knowledge of the lower-level model. Therefore, the label category level can be two layers or multiple layers. When it is multiple layers, the third-level classification parameters can be determined according to the second-level classification labels, and the text features can be classified using the three-level classification parameters. By analogy, the classification labels of the lowest level of the content to be classified are finally obtained, thereby completing the classification of the content to be classified. The loss function loss consists of three parts, among which the first-level category uses the negative logarithmic loss function as the loss function, and the final result of the second-level classification also uses the negative logarithmic loss function. In addition, a hinge loss function is added to ensure that the probability of the first-level classification should always be greater than the corresponding second-level classification result. This model can effectively utilize the correlation of the hierarchical category system and introduce the difference between the first-level and second-level classification results into the loss function to constrain the consistency of multi-level category results.
[0116] From the above, it can be seen that after obtaining the content to be classified, the embodiment of the present application performs feature extraction on the text content in the content to be classified to obtain text features of the text content, and classifies the text features to obtain at least one first-level classification label of the content to be classified, and then, according to the first-level classification label, determines the second-level classification parameters of the content to be classified, and then, based on the second-level classification parameters, classifies the text features to obtain the second-level classification labels of the content to be classified, and then, according to the second-level classification labels, classifies the content to be classified; because the scheme first classifies the first-level labels of the content to be classified, and then determines the second-level classification labels of the content to be classified based on the first-level classification labels, it makes full use of the label classification system, adopts the upper-level category labels (first-level labels) to constrain the lower-level label categories (secondary labels), increases the accuracy of the second-level labels, and therefore, can improve the accuracy of content classification.
[0117] According to the method described in the above embodiment, the following is further described in detail with examples.
[0118] In this embodiment, the content classification device is specifically integrated in an electronic device, the electronic device is a server, the content to be classified is a video to be classified, and the text content is a video title of the video to be classified.
[0119] (1) The server trains the preset content classification model
[0120] (1) The server obtains a video sample and extracts features of the video title in the video sample to obtain sample text features.
[0121] For example, the server can directly receive the video sample sent by the user or the content server, or obtain the original video from the network or content database, and send the video title of the original video to the annotation server for annotation, and receive the video title with the first-level classification label and the second-level classification label returned by the annotation server, so as to obtain the video sample. The training data of the video sample can be shown in Table (1):
[0122] Table 1 Training data
[0123]
[0124] The server can use a feature extraction network of a preset content classification model to semantically encode the video title, thereby obtaining a semantic vector of the encoded video title, and use the encoded semantic vector as a text feature of the video title.
[0125] (2) The server uses a first-level classification network of a preset content classification model to classify sample text features and obtain at least one predicted first-level classification label of the content sample.
[0126] For example, the server can use the first-level classification network of the preset content classification model to normalize the sample text features to obtain the normalized sample text features, determine the probability information corresponding to the preset first-level classification label set based on the normalized sample text features, and based on the probability information, screen out at least one predicted first-level classification label of the video sample from the preset first-level classification labels.
[0127] (3) The server uses the secondary classification network corresponding to the predicted primary classification label in the preset content classification model to classify the text features and obtain the predicted secondary classification label of the video sample.
[0128] For example, the server obtains the attribute information of the secondary classification network in the preset content classification model, identifies the network identifier of each secondary classification network in the attribute information, selects the network identifier corresponding to the predicted primary classification label from the network identifier, obtains the network identifier, and activates the secondary classification network corresponding to the selected network identifier. The network structure of the secondary classification network can be a two-layer DNN network. The activated secondary classification network is used as an expert network, and the expert network is used to perform secondary classification on the text features, and the candidate secondary classification label set of the preset dimension and the candidate probability distribution information corresponding to the candidate secondary classification label set are output. The candidate secondary classification label set and the candidate probability distribution information are used as the classification information output by the expert network. The classification information output by each expert network is fused to obtain the predicted secondary classification label set of the video sample and the target probability information corresponding to the predicted secondary classification label set. The classification probability corresponding to each predicted secondary classification label is identified in the target probability information. Based on the classification probability, the predicted secondary classification label of the video sample is selected from the predicted secondary classification label set.
[0129] (4) The server converges the preset content classification model based on the labeled first-level classification labels and the second-level classification labels, as well as the predicted first-level classification labels and the predicted second-level classification labels, to obtain a trained content classification model.
[0130] For example, the server can compare the annotated first-level classification label with the predicted first-level classification label. When the predicted first-level classification label and the annotated first-level classification label are the same, it can be determined that the prediction is correct. Otherwise, the prediction is incorrect. The correct prediction corresponds to a preset parameter value, and the incorrect prediction corresponds to another preset parameter value. For example, the prediction result parameter corresponding to the correct prediction can be 1, and the prediction result parameter corresponding to the incorrect prediction can be 0. The first prediction probability is fused with the first prediction result parameter to obtain the initial first-level classification loss information of each predicted first-level classification label. The initial first-level classification loss information is fused, and the fused first-level classification loss information is inverted to obtain the first-level classification loss information of the video sample, as shown in formula (1).
[0131] The server compares the marked secondary classification label with the predicted secondary classification label to obtain the second prediction result parameter of the classification label, obtains the second prediction probability of each predicted secondary classification label, and fuses the second prediction probability with the second prediction result parameter to obtain the secondary classification loss information of the video sample, as shown in formula (2).
[0132] The server calculates the difference between the first prediction probability of each predicted first-level classification label and the second prediction probability of each predicted second-level classification label, thereby obtaining the prediction probability difference. Alternatively, the server may determine the first weighting coefficient corresponding to the predicted first-level classification label according to the first prediction probability, and determine the second weighting coefficient corresponding to the predicted second-level classification label according to the second prediction probability, weight the first prediction probability according to the first weighting coefficient, and weight the second prediction probability according to the second weighting coefficient, and then respectively calculate the difference between the weighted first prediction probability and the weighted second prediction probability, thereby obtaining the prediction probability difference. The server fuses the prediction probability difference with the prediction probability parameter to obtain the initial classification level loss value, compares the initial classification level loss value with the preset loss value threshold, and determines the target classification level loss value of the content sample according to the comparison result, fuses the target classification level loss value, and obtains the classification level loss information of the content sample, as shown in formula (3).
[0133] The server obtains the weighting parameters corresponding to the first-level classification loss information, the second-level classification loss information and the classification level loss information, and weights the first-level classification loss information, the second-level classification loss information and the classification level loss information according to the weighting parameters, and fuses the weighted first-level classification loss information, the second-level classification loss information and the classification level loss information to obtain the fused loss information, as shown in formula (4).
[0134] Based on the fusion loss information, the server uses a gradient update algorithm to update the network parameters of the preset content classification model to converge the preset content classification model, and then obtain the trained content classification model. Alternatively, based on the fusion loss information, the server uses other update algorithms to update the network parameters of the preset content classification model to converge the preset content classification model, and then obtain the trained content classification model.
[0135] (2) The server uses the trained content classification model to classify the videos.
[0136] The trained content classification model includes a primary classification network and multiple secondary classification networks.
[0137] like Figure 4 As shown, a content classification method, the specific process is as follows:
[0138] 201. The server obtains a video to be classified.
[0139] For example, the server may directly obtain the video to be classified uploaded by the user through the terminal, or may directly obtain the original video from the network or content database, and filter out the video containing the video title from the original video to obtain the video to be classified.
[0140] When the number of videos to be classified is large or the memory is large, the server can receive a video classification request sent by the terminal, which carries the storage address of the video to be classified, and obtain the video to be classified in the memory, cache or third-party database according to the storage address.
[0141] 202. The server extracts features of the video title to obtain text features of the video title.
[0142] For example, the server can use CNN, LSTM or LSTM+Attention of the trained content classification model as the feature extraction network to semantically encode the video title, thereby obtaining the encoded semantic vector of the video title, and use the encoded semantic vector as the text feature of the video title.
[0143] 203. The server classifies the text features to obtain at least one primary classification label of the video to be classified.
[0144] For example, the server can use the softmax function to map the text features to values between 0 and 1, and then normalize the mapped values to obtain normalized text features, and use the normalized text features as the probability distribution corresponding to the preset first-level classification label set, thereby obtaining the probability information corresponding to the preset first-level classification label set, or the normalized text features can be associated with the preset first-level classification label set to obtain the probability distribution corresponding to the preset first-level classification label set, and the classification probability of each preset first-level classification label is extracted from the probability distribution, thereby obtaining the probability information corresponding to the preset first-level classification label set.
[0145] The server sorts the preset first-level classification tags according to the classification probability of each preset first-level classification tag in the preset first-level classification tag set, and according to the sorting result, selects the first-level classification tags within the preset sorting range from the preset first-level classification tag set as the first-level classification tags of the content to be classified. The preset sorting range can be the top N rankings, for example, the first ranking, or the top three, or the top ten, etc. Therefore, the first-level classification tag of the video to be classified can be one or more. When TOP N is ranked first, the first-level classification tag of the video to be classified can be one. When TOP N is ranked in the top two or other sorting ranges, the first-level classification tags of the video to be classified can be multiple.
[0146] 204. The server determines secondary classification parameters of the video to be classified according to the primary classification label.
[0147] For example, the server can obtain the attribute information of the secondary classification network in the trained content classification model, extract the target attribute information corresponding to each secondary classification network from the attribute information, and respectively identify the identification information or identity information of each secondary classification network in the target attribute information, thereby obtaining the network identification of each secondary classification network. The network identification corresponding to the primary classification label is selected from the network identification to obtain the target network identification, and the target network identification is used as the secondary classification parameter of the video to be classified.
[0148] 205. The server classifies the text features based on the secondary classification parameters to obtain the secondary classification labels of the video to be classified.
[0149] For example, the server selects at least one target secondary classification network from the secondary classification network based on the secondary classification parameters, uses the target secondary classification network as the expert network, uses the expert network to perform secondary classification on text features, outputs a set of candidate secondary classification labels of preset dimensions and probability distribution information corresponding to the candidate secondary classification label set, and uses the candidate secondary classification label set and the probability distribution information as the classification information output by the expert network.
[0150] The server fuses the candidate secondary classification label sets to obtain the target secondary classification label set for the content to be classified, fuses the probability distribution information to obtain the classification probability of each secondary classification label in the target secondary classification label set, and screens out the secondary classification labels of the content to be classified in the target secondary classification label set based on the classification probability.
[0151] The server selects the secondary classification tag with the largest classification probability from the target secondary classification tag set according to the classification probability as the secondary classification tag of the video to be classified. Alternatively, the server may sort the secondary classification tags in the target secondary classification tag set according to the classification probability, select the TOP N secondary classification tags from the sorted secondary classification tags as candidate secondary classification tags, classify the candidate secondary classification tags to obtain a candidate secondary classification tag set corresponding to each first-level classification tag, select the candidate secondary classification tag set with the largest number of secondary classification tags from the candidate secondary classification tag set, and select the secondary classification tag with the largest classification probability from the selected candidate secondary classification tag set as the secondary classification tag of the video to be classified.
[0152] 206. The server classifies the video to be classified according to the secondary classification label.
[0153] For example, the server may send the video to be classified to a video set corresponding to the secondary classification tag to complete the classification of the video to be classified, or may add the secondary classification tag to the video to be classified to complete the classification of the video to be classified.
[0154] Optionally, before sending the content to be classified to the content set corresponding to the secondary classification tag, the attribute information of the content set corresponding to the secondary classification tag can also be obtained, and the storage rule of the content set can be identified in the attribute information. Based on the storage rule, the content to be classified can be compressed, or the format of the content to be classified can be converted into a preset content format corresponding to the content set. Finally, the processed content to be classified is sent to the content set corresponding to the secondary classification tag.
[0155] Among them, the video title is one of the main components of the video content. Parsing the text based on the title text content combined with basic algorithms such as natural language processing to enhance the understanding of the video semantic information is one of the core tasks of the entire video search system. Figure 5 As shown in the figure, giving the basic topic category of the video based on the video title and modeling the task of completing the title word weight task are the basis for understanding the content of the video. Hierarchical classification is an important task in multi-classification in the NLP\CV field. Its main feature is that the category labels have a hierarchical relationship. The upper label is the parent of the lower label, and the granularity is finer as it goes down. For the business in the video subsystem, two levels of categories are mainly constructed, of which there are 44 first-level categories, including coarse-grained categories such as sports, games, and entertainment. The first-level categories are further subdivided into multiple second-level categories, with a total of 305 fine-grained second-level categories.
[0156] From the above, it can be seen that after obtaining the video to be classified, the server of this embodiment extracts features of the video title in the video to be classified to obtain text features of the video title, and classifies the text features to obtain at least one first-level classification label to be classified, and then, according to the first-level classification label, determines the second-level classification parameters of the video to be classified, and then, based on the second-level classification parameters, classifies the text features to obtain the second-level classification labels of the video to be classified, and then, according to the second-level classification labels, classifies the video to be classified; because this scheme first classifies the first-level label of the video to be classified, and then determines the second-level classification label of the video to be classified based on the first-level classification label, it makes full use of the label classification system, adopts the upper-level category label (first-level label) to constrain the lower-level label category (secondary label), increases the accuracy of the second-level label, and therefore, can improve the accuracy of video classification.
[0157] In order to better implement the above method, an embodiment of the present invention further provides a content classification device, which can be integrated in an electronic device, such as a server or a terminal. The terminal can include a tablet computer, a laptop computer and / or a personal computer.
[0158] For example, Figure 6As shown, the content classification device may include an acquisition unit 301, a primary classification unit 302, a determination unit 303, a secondary classification unit 304 and a content classification unit 305, as follows:
[0159] (1) Acquisition unit 301;
[0160] The acquisition unit 301 is used to acquire content to be classified, where the content to be classified includes text content.
[0161] For example, the acquisition unit 301 can be used to directly acquire the content to be classified uploaded by the user through the terminal, or can also directly acquire the original content from the network or content database, and filter out the content containing text from the original content to obtain the content to be classified. When the amount of content to be classified is large or the memory is large, a content classification request sent by the receiving terminal is carried in the content classification request. The storage address of the content to be classified is obtained in the memory, cache or third-party database according to the storage address.
[0162] (2) primary classification unit 302;
[0163] The primary classification unit 302 is used to extract features from the text content to obtain text features of the text content, and to classify the text features to obtain at least one primary classification label for the content to be classified.
[0164] For example, the primary classification unit 302 can be specifically used to semantically encode the text content using the feature extraction network of the trained content classification model, thereby obtaining a semantic vector after the text content is encoded, and the encoded semantic vector is used as the text feature of the text content. The primary classification network of the trained content classification model is used to normalize the text features to obtain normalized text features, and the probability information corresponding to the preset primary classification label set is determined based on the normalized text features, and at least one primary classification label of the content to be classified is screened out from the preset primary classification labels based on the probability information.
[0165] (3) determining unit 303;
[0166] The determination unit 303 is used to determine the secondary classification parameters of the content to be classified according to the primary classification label.
[0167] For example, the determination unit 303 can be specifically used to obtain the attribute information of the secondary classification network in the trained content classification model, identify the network identifier of each secondary classification network in the attribute information, filter out the network identifier corresponding to the primary classification label in the network identifier, obtain the target network identifier, and use the target network identifier as the secondary classification parameter of the content to be classified.
[0168] (4) secondary classification unit 304;
[0169] The secondary classification unit 304 is used to classify the text features based on the secondary classification parameters to obtain the secondary classification labels of the content to be classified.
[0170] For example, the secondary classification unit 304 can be specifically used to screen out at least one target secondary classification network in the secondary classification network according to the secondary classification parameters, use the target secondary classification network to classify text features, obtain classification information of the text features, and fuse the classification information to obtain a secondary classification label for the content to be classified.
[0171] (5) content classification unit 305;
[0172] The content classification unit 305 is used to classify the content to be classified according to the secondary classification labels.
[0173] For example, the content classification unit 305 can be used to send the content to be classified to the content set corresponding to the secondary classification tag to complete the classification of the content to be classified, or can also add the secondary classification tag to the content to be classified to complete the classification of the content to be classified.
[0174] Optionally, the content classification device may further include a training unit 306, such as Figure 7 As shown, the specific details can be as follows:
[0175] The training unit 306 is used to train the preset content classification model to obtain a trained content classification model.
[0176] For example, the training unit 306 can be specifically used to obtain content samples, and perform feature extraction on text features in the content samples to obtain sample text features, use the first-level classification network of a preset content classification model to classify the sample text features to obtain at least one predicted first-level classification label of the content sample, use the second-level classification network corresponding to the predicted first-level classification label in the preset content classification model to classify the text features to obtain a predicted second-level classification network of the content sample, and based on the labeled first-level classification labels and the predicted first-level classification labels, as well as the predicted first-level classification labels and the predicted second-level classification labels, converge the preset content classification model to obtain a trained content classification model.
[0177] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0178] As can be seen from the above, in this embodiment, after the acquisition unit 301 acquires the content to be classified, the primary classification unit 302 performs feature extraction on the text content in the content to be classified to obtain the text features of the text content, and classifies the text features to obtain at least one primary classification label of the content to be classified, and then the determination unit 303 determines the secondary classification parameters of the content to be classified based on the primary classification label, and then the secondary classification unit 304 classifies the text features based on the secondary classification parameters to obtain the secondary classification labels of the content to be classified, and then the content classification unit 305 classifies the content to be classified based on the secondary classification labels; since this scheme first classifies the primary labels of the content to be classified, and then determines the secondary classification labels of the content to be classified based on the primary classification labels, it makes full use of the label classification system, adopts the upper category label (primary label) to constrain the lower category label category (secondary label), increases the accuracy of the secondary label, and therefore, can improve the accuracy of content classification.
[0179] The embodiment of the present invention further provides an electronic device, such as Figure 8 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present invention, specifically:
[0180] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0181] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data, thereby performing overall detection of the electronic device. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.
[0182] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0183] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0184] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0185] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:
[0186] Obtain content to be classified, which includes text content, perform feature extraction on the text content to obtain text features of the text content, classify the text features to obtain at least one primary classification label for the content to be classified, determine secondary classification parameters of the content to be classified based on the primary classification labels, classify the text features based on the secondary classification parameters to obtain secondary classification labels for the content to be classified, and classify the content to be classified based on the secondary classification labels.
[0187] For example, the electronic device can directly obtain the content to be classified uploaded by the user through the terminal, or can also directly obtain the original content from the network or content database, and filter out the content containing text in the original content to obtain the content to be classified. When the amount of content to be classified is large or the memory is large, a content classification request sent by the receiving terminal is carried out, and the content classification request carries the storage address of the content to be classified. According to the storage address, the content to be classified is obtained in the memory, cache or third-party database. The feature extraction network of the trained content classification model is used to semantically encode the text content, so as to obtain the semantic vector of the encoded text content, and the encoded semantic vector is used as the text feature of the text content. The first-level classification network of the trained content classification model is used to normalize the text features to obtain the normalized text features. According to the normalized text features, the probability information corresponding to the preset first-level classification label set is determined, and based on the probability information, at least one first-level classification label of the content to be classified is filtered out from the preset first-level classification labels. Obtain the attribute information of the secondary classification network in the trained content classification model, identify the network identifier of each secondary classification network in the attribute information, select the network identifier corresponding to the primary classification label from the network identifier, obtain the target network identifier, and use the target network identifier as the secondary classification parameter of the content to be classified. According to the secondary classification parameter, select at least one target secondary classification network from the secondary classification network, use the target secondary classification network to classify the text features, obtain the classification information of the text features, and fuse the classification information to obtain the secondary classification label of the content to be classified. Send the content to be classified to the content set corresponding to the secondary classification label to complete the classification of the content to be classified, or add the secondary classification label to the content to be classified to complete the classification of the content to be classified.
[0188] The specific implementation of the above operations can be found in the previous embodiments and will not be described in detail here.
[0189] From the above, it can be seen that after obtaining the content to be classified, the embodiment of the present invention performs feature extraction on the text content in the content to be classified to obtain text features of the text content, and classifies the text features to obtain at least one first-level classification label of the content to be classified, and then, according to the first-level classification label, determines the second-level classification parameters of the content to be classified, and then, based on the second-level classification parameters, classifies the text features to obtain the second-level classification labels of the content to be classified, and then, according to the second-level classification labels, classifies the content to be classified; because the scheme first classifies the first-level labels of the content to be classified, and then determines the second-level classification labels of the content to be classified based on the first-level classification labels, it makes full use of the label classification system, adopts the upper-level category labels (first-level labels) to constrain the lower-level label categories (secondary labels), increases the accuracy of the second-level labels, and therefore, can improve the accuracy of content classification.
[0190] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0191] To this end, an embodiment of the present invention provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any content classification method provided in the embodiment of the present invention. For example, the instructions can execute the following steps:
[0192] Obtain content to be classified, which includes text content, perform feature extraction on the text content to obtain text features of the text content, classify the text features to obtain at least one primary classification label for the content to be classified, determine secondary classification parameters of the content to be classified based on the primary classification labels, classify the text features based on the secondary classification parameters to obtain secondary classification labels for the content to be classified, and classify the content to be classified based on the secondary classification labels.
[0193] For example, the content to be classified uploaded by the user through the terminal is obtained, or the original content can be directly obtained from the network or content database, and the content containing text is screened out from the original content to obtain the content to be classified. When the amount of content to be classified is large or the memory is large, a content classification request sent by the receiving terminal is carried out, and the content classification request carries the storage address of the content to be classified. According to the storage address, the content to be classified is obtained in the memory, cache or third-party database. The feature extraction network of the trained content classification model is used to semantically encode the text content, so as to obtain the semantic vector of the encoded text content, and the encoded semantic vector is used as the text feature of the text content. The first-level classification network of the trained content classification model is used to normalize the text features to obtain the normalized text features. According to the normalized text features, the probability information corresponding to the preset first-level classification label set is determined, and based on the probability information, at least one first-level classification label of the content to be classified is screened out from the preset first-level classification labels. Obtain the attribute information of the secondary classification network in the trained content classification model, identify the network identifier of each secondary classification network in the attribute information, select the network identifier corresponding to the primary classification label from the network identifier, obtain the target network identifier, and use the target network identifier as the secondary classification parameter of the content to be classified. According to the secondary classification parameter, select at least one target secondary classification network from the secondary classification network, use the target secondary classification network to classify the text features, obtain the classification information of the text features, and fuse the classification information to obtain the secondary classification label of the content to be classified. Send the content to be classified to the content set corresponding to the secondary classification label to complete the classification of the content to be classified, or add the secondary classification label to the content to be classified to complete the classification of the content to be classified.
[0194] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0195] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0196] Since the instructions stored in the computer-readable storage medium can execute the steps in any content classification method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any content classification method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0197] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the methods provided in various optional implementations of the above-mentioned content classification or video classification.
[0198] The above is a detailed introduction to a content classification method, device, electronic device and computer-readable storage medium provided in an embodiment of the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A content classification method, characterized in that: include: Acquire content to be classified, wherein the content to be classified includes text content; Using the trained content classification model to perform feature extraction on the text content to obtain text features of the text content, and classifying the text features to obtain at least one primary classification label of the content to be classified; Determining secondary classification parameters of the content to be classified according to the primary classification label; Based on the secondary classification parameters, the text features are classified to obtain secondary classification labels of the content to be classified; Classifying the content to be classified according to the secondary classification label; The training process of the trained content classification model includes: obtaining content samples, and performing feature extraction on text in the content samples to obtain sample text features, wherein the content samples include content marked with primary classification labels and secondary classification labels; Using a primary classification network of a preset content classification model to classify the sample text features, and obtain at least one predicted primary classification label of the content sample; Using the secondary classification network corresponding to the predicted primary classification label in the preset content classification model to classify the text features, to obtain the predicted secondary classification label of the content sample; Determine the primary classification loss information of the content sample according to the marked primary classification label and the predicted primary classification label, and determine the secondary classification loss information of the content sample based on the marked secondary classification label and the predicted secondary classification label; Respectively calculating the predicted probability difference between the predicted primary classification label and the predicted secondary classification label, and obtaining the preset predicted probability parameter corresponding to the content sample, and fusing the predicted probability difference with the predicted probability parameter to obtain an initial classification level loss value; Comparing the initial classification level loss value with a preset loss value threshold, and determining a target classification level loss value of the content sample according to the comparison result; The target classification level loss values are merged to obtain classification level loss information of the content sample; The first-level classification loss information, the second-level classification loss information and the classification level loss information are fused, and the preset content classification model is converged based on the fused loss information to obtain a trained content classification model.
2. The content classification method according to claim 1, characterized in that: The adopting the trained content classification model to classify the text features to obtain at least one primary classification label of the content to be classified includes: Using the first-level classification network of the trained content classification model to normalize the text features to obtain normalized text features; Determine probability information corresponding to a preset first-level classification label set according to the normalized text features; Based on the probability information, at least one first-level classification label of the content to be classified is screened out from the preset first-level classification labels.
3. The content classification method according to claim 1, characterized in that: Determining the secondary classification parameters of the content to be classified according to the primary classification label includes: Obtaining attribute information of the secondary classification network in the trained content classification model; Identifying a network identifier of each secondary classification network in the attribute information; The network identifier corresponding to the primary classification label is screened out from the network identifiers to obtain a target network identifier, and the target network identifier is used as a secondary classification parameter of the content to be classified.
4. The content classification method according to claim 3, characterized in that: The step of classifying the text features based on the secondary classification parameters to obtain the secondary classification labels of the content to be classified includes: According to the secondary classification parameters, screening out at least one target secondary classification network from the secondary classification network; Using the target secondary classification network, classify the text features to obtain classification information of the text features; The classification information is integrated to obtain a secondary classification label for the content to be classified.
5. The content classification method according to claim 4, characterized in that: The classification information includes a candidate secondary classification label set and probability distribution information corresponding to the candidate secondary classification label set, and fusing the classification information to obtain the secondary classification label of the content to be classified includes: The candidate secondary classification label sets are merged to obtain a target secondary classification label set for the content to be classified; The probability distribution information is integrated to obtain the classification probability of each secondary classification label in the target secondary classification label set; According to the classification probability, the secondary classification label of the content to be classified is screened out from the target secondary classification label set.
6. The content classification method according to claim 1, characterized in that: The determining the primary classification loss information of the content sample according to the marked primary classification label and the predicted primary classification label includes: Compare the marked first-level classification label with the predicted first-level classification label to obtain a first prediction result parameter of the first-level classification label; A first prediction probability of each of the predicted primary classification labels is obtained, and the first prediction probability is fused with a first prediction result parameter to obtain primary classification loss information of the content sample.
7. The content classification method according to claim 6, characterized in that: The fusing the first prediction probability with the first prediction result parameter to obtain the primary classification loss information of the content sample includes: The first prediction probability is integrated with the first prediction result parameter to obtain initial first-level classification loss information of each predicted first-level classification label; The initial first-level classification loss information is fused, and the fused first-level classification loss information is inverted to obtain the first-level classification loss information of the content sample.
8. The content classification method according to claim 1, characterized in that: The determining of the secondary classification loss information of the content sample based on the annotated secondary classification label and the predicted secondary classification label includes: Compare the marked secondary classification label with the predicted secondary classification label to obtain a second prediction result parameter of the secondary classification label; A second prediction probability of each of the predicted secondary classification labels is obtained, and the second prediction probability is fused with a second prediction result parameter to obtain secondary classification loss information of the content sample.
9. A content classification device, characterized in that: include: An acquisition unit, used for acquiring content to be classified, wherein the content to be classified includes text content; The primary classification unit is used to use the trained content classification model to extract features from the text content to obtain text features of the text content, and classify the text features to obtain at least one primary classification label of the content to be classified. The training process of the trained content classification model includes: obtaining content samples, and extracting features from the text in the content samples to obtain sample text features, wherein the content samples include content marked with primary classification labels and secondary classification labels; using the primary classification network of the preset content classification model to classify the sample text features to obtain at least one predicted primary classification label of the content sample; using the secondary classification network corresponding to the predicted primary classification label in the preset content classification model to classify the text features to obtain the predicted secondary classification label of the content sample; determining according to the marked primary classification label and the predicted primary classification label The first-level classification loss information of the content sample; based on the marked second-level classification label and the predicted second-level classification label, determine the second-level classification loss information of the content sample; respectively calculate the predicted probability difference between the predicted first-level classification label and the predicted second-level classification label, and obtain the preset predicted probability parameter corresponding to the content sample, and fuse the predicted probability difference with the predicted probability parameter to obtain an initial classification level loss value; compare the initial classification level loss value with the preset loss value threshold, and determine the target classification level loss value of the content sample according to the comparison result; fuse the target classification level loss value to obtain the classification level loss information of the content sample; fuse the first-level classification loss information, the second-level classification loss information and the classification level loss information, and converge the preset content classification model based on the fused loss information to obtain a trained content classification model; A determination unit, configured to determine a secondary classification parameter of the content to be classified according to the primary classification label; A secondary classification unit, used to classify the text features based on the secondary classification parameters to obtain a secondary classification label of the content to be classified; The content classification unit is used to classify the content to be classified according to the secondary classification label.
10. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to execute the steps in the content classification method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the content classification method according to any one of claims 1 to 8.
